# [ACCEPTED]-One dimensional edge detection-edge-detection

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

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

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

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

```
thrd = FindThreshold[d];
```

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

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

At this point 6 you have the ends of the edges:

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

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

```
t = FindThreshold@data[[steps]];
steps2 = Select[steps, data[[#]] <= t &];
ListLinePlot[data, Epilog -> {Red, PointSize[Large], Map[Point[{#, data[[#]]}] &, steps2]}]
```

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

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

Barcodes ?

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

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

More Related questions

We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.