MATLAB Answers

0

edge detection filters are not detecting my edges for the matrix I created, even though the gradient changes are super obvious

Asked by Aaron Connell on 22 Apr 2018
Latest activity Answered by Ahmet Cecen on 22 Apr 2018
I am trying to use the three edge filters below to show the edges of the image I created. For some reason the filters keep returning matrixes of zeros (black) even though there is super obvious gradient changes. Why are the filters not detecting the edges? Below is the code I have, and you can see from the images they are all black.
clear
figure
im=200*ones(10,10);
im(3:5,3:8)=50;
im(6:8,4:7)=50;
im2=mat2gray(im+round(9*randn(10,10)))
edge_p = edge(im2,'prewitt')
edge_s = edge(im2,'sobel')
edge_r = edge(im2,'roberts');
subplot(2,2,1);
imshow(im2);
title('Original Grayscale Image');
subplot(2,2,2);
imshow(edge_p);
title('Edge Using Prewit');
subplot(2,2,3);
imshow(edge_s);
title('Edge Using Sobel');
subplot(2,2,4);
imshow(edge_r);
title('Edge Using Roberts');

  0 Comments

Sign in to comment.

1 Answer

Answer by Ahmet Cecen on 22 Apr 2018
 Accepted Answer

I believe the very small size of your image is messing with the heuristics of the "edge" function to find thresholds. You can either define thresholds manually like:

edge_s = edge(im2,'sobel',0.1);

or resize your image before the operation:

im2 = resize(im2,5,'nearest');

  0 Comments

Sign in to comment.