一维边缘检测

发布于 2025-01-04 22:40:18 字数 237 浏览 0 评论 0原文

我不想对 2D 图像进行边缘检测,而是想分别检测图像的每一行(即一条线)上的边缘。即从输入 1D 向量检测边缘,其值是范围从 0 到 255 的像素强度(下图): 在此处输入图像描述

我想检测示例输入中出现的主要边缘(下图) 在此处输入图像描述

Instead of edge detection of a 2D image, I would like to detect edges on every single row (i.g. a line) of an image separately. That is detection of edges from an input 1D vector whose values are pixel intensities ranging from 0 to 255 ( image below):
enter image description here

I would like to detect the major edges as appear in the sample input( image below)
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

憧憬巴黎街头的黎明 2025-01-11 22:40:18

获得所需结果的一种方法是按如下方式调整 2D Canny 边缘检测器(Mathematica 中的代码):

首先,使用高斯导数滤波器计算空间导数,设置相对于您想要的边缘比例的 sigma 值探测。取结果的绝对值。

d = Abs@GaussianFilter[data, {{10, 5}}, 1];

然后,自动确定阈值以将先前的导数值聚类为两组(此处使用大津方法)。

thrd = FindThreshold[d];

然后,检测导数值的步长(进入/离开“死区”的转换)。

steps = Flatten@Image`StepDetect[d, thrd]["NonzeroPositions"];

此时,您已经有了边缘的末端:

ListLinePlot[data, Epilog -> {Red, PointSize[Large], Map[Point[{#, data[[#]]}] &, steps]}]

在此处输入图像描述

可选 - 看来这就是您想要的--仅保留边缘的最低端。在这种情况下,将边缘末端的数据点聚类是可行的,但我不确定它的鲁棒性如何。

t = FindThreshold@data[[steps]];
steps2 = Select[steps, data[[#]] <= t &];

ListLinePlot[data, Epilog -> {Red, PointSize[Large], Map[Point[{#, data[[#]]}] &, steps2]}]

在此处输入图像描述

One way to get to your desired result is to adapt the 2D Canny edge detector as follows (code in Mathematica):

First, compute the spatial derivative using a Gaussian derivative filter, setting the sigma value relative to the scale of the edges you want to detect. Take the absolute value of the result.

d = Abs@GaussianFilter[data, {{10, 5}}, 1];

Then, determine a threshold automatically to cluster the previous derivative values in two groups (here using Otsu's method).

thrd = FindThreshold[d];

Then, detect the steps of the derivative values (transitions into/from the "dead band").

steps = Flatten@Image`StepDetect[d, thrd]["NonzeroPositions"];

At this point you have the ends of the edges:

ListLinePlot[data, Epilog -> {Red, PointSize[Large], Map[Point[{#, data[[#]]}] &, steps]}]

enter image description here

Optionally--it seems that's what you'd like--keep only the lowest ends of the edges. Clustering the data points at the ends of the edges works in this case, but I'm not sure how robust it is.

t = FindThreshold@data[[steps]];
steps2 = Select[steps, data[[#]] <= t &];

ListLinePlot[data, Epilog -> {Red, PointSize[Large], Map[Point[{#, data[[#]]}] &, steps2]}]

enter image description here

日裸衫吸 2025-01-11 22:40:18

考虑到这些边缘的良好对比度,有一个简单且可靠的解决方案:检测所有单调的像素值序列(严格增加或减少)。您将保持序列的总高度高于阈值(在您的情况下为 50),以拒绝噪声峰值。

作为副产品,您将获得起点和终点(虽然不完全是您期望的位置,但如果需要,可以对其进行改进)。

条形码?

Given the nice contrast of these edges, there is an easy solution that will work robustly: detect all monotonous sequences of pixel values (strictly increasing or decreasing). You will keep the sequences having a total height above a threshold (50 in your case) to reject the noisy peaks.

As a byproduct, you'll get the starting and ending points (not exactly where you expect them though, but this can be improved on if needed).

Barcodes ?

素年丶 2025-01-11 22:40:18

那么您正在寻找斜率的特定变化 - 即每个样本 Y 的特定变化?

难道不是简单地查看两个样本之间 Y 的差异,如果它的绝对值变化超过某个限制,则将其标记为边缘?

So you are looking for a particular change in slope - ie a certain change in Y per sample?

Isn't it simply look at the difference in Y between two samples and if it's absolute value changed by more than some limit mark that as an edge?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文