0

It is possible to perform a variety of edge detector filters in Matlab, using edge function. But this function applies a threshold on the output. Is it possible to disable such thresholding? If not, is there any other ways to calculate the original values of the filters (canny and sobel) without thresholding?

Hamed
  • 1,175
  • 3
  • 20
  • 46

1 Answers1

1

The answer to your very clear question is a yes. Because all edge functions apply a threshold on some intensity-gradients you should not look at the edge function itself but at the underlying gradients. For that you can apply the imfilter() function. So, e.g. for the Sobel X-direction you would do the following:

I=imread('Img.jpg');
I=rgb2gray(I);
sobX=[1 0 -1, 2 0 -2, 1 0 -1];
GradientX = imfilter(I,sobX);
imshow(GradientX);

The same you can do with SobelY, just using

sobY=[1 2 1, 0 0 0, -1 -2 -1];

Of course you can combine the magnitudes of SobelX and SobelY by taking the hypothenuse.

The latter gives a ghostly effect:

I=imread('Img.jpg');
I=rgb2gray(I);
sobX=[1 0 -1, 2 0 -2, 1 0 -1];
GradX = imfilter(I,sobX);
sobY=[1 2 1, 0 0 0, -1 -2 -1];
GradY = imfilter(I,sobY);
Magn=(double(GradX.^2 + GradY.^2)).^0.5;
Magn=Magn*255/max(Magn(:))

UDDATE: Canny starts with Sobel (as above) but then applies non maximum suppression and hysteresis. These latter steps involve local operations of selecting/deselecting single pixels as edges (n.m.s.) respecively recursively follow thresholded edges (hysteresis). Thus, these postprocessing steps are not consistent anymore with a global matrix of grayvalues.

Settembrini
  • 1,366
  • 3
  • 20
  • 32