# Increasing filter size of edge detector

15 Ansichten (letzte 30 Tage)
Andrew am 7 Apr. 2014
Kommentiert: DGM am 6 Nov. 2022
Hello,
I am looking at using edge detectors to detect edges in my images but I as wondering if there was a way of increasing the size of the filters? For example increase Sobel or Prewitt from a 3 x 3 array to a 5 x 5 array or bigger. I am looking to see what the effect of a larger window will have on my edge detection.
Thanks, Andrew
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (2)

Nitin am 7 Apr. 2014
Bearbeitet: Nitin am 7 Apr. 2014
There is a nice thread on stackoverflow which might give you the values of the filter you are looking for.
##### 3 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
Nitin am 8 Apr. 2014
Sorry, I have updated my answer. Hopefully this will help
DGM am 6 Nov. 2022
For sake of making things local and elaborating, let's consider Daniel's Sobel-esque filters.
For a 5x5 filter, you can do
r = 2; % filter radius
[x y] = meshgrid(-r:r);
fk = x./(x.^2 + y.^2);
fk(r+1,r+1) = 0
fk = 5×5
-0.2500 -0.2000 0 0.2000 0.2500 -0.4000 -0.5000 0 0.5000 0.4000 -0.5000 -1.0000 0 1.0000 0.5000 -0.4000 -0.5000 0 0.5000 0.4000 -0.2500 -0.2000 0 0.2000 0.2500
You can simply change r to get a different size filter. If you want, you can transpose it.
If you want your output image to stay within a convenient range, you can just prenormalize the kernel depending on how you intend to apply it. If you intend to apply the filter once to get a directional derivative estimate, you can do
fk = fk/-sum(sum(fk(:,1:r))); % for single-pass
... and your image will conveniently stay within [-1 1].
If you intend to do two orthogonal filter passes to calculate the gradient magnitude, you can normalize like so:
fk = fk/(sqrt(5)*r); % for 2-pass
... and your image will stay within [0 1]
... or you can do whatever you want with it as is.

Melden Sie sich an, um zu kommentieren.

Image Analyst am 7 Apr. 2014
You can try difference of Gaussians or something. Use fspecial to build the Gaussians. DOG filters are common edge filters.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Object Analysis finden Sie in Help Center und File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by