user1263390
user1263390

Reputation: 187

find edge in image

How can I detect the edges in an image without using method 'edge', with only using mathematical operations (matrix or Derived or div or any other)? Indeed, how can I rewrite the function edge by using the algorithm Canny or sobel or any other?

For example:

enter image description here

pink rectangle 256*256 black rectangle 127*127

Answer:Canny Tutorial

Upvotes: 0

Views: 5328

Answers (1)

Bill Cheatham
Bill Cheatham

Reputation: 11937

You state that you wish to use Canny, Sobel or another algorithm. These can both be used in edge. Try for example:

BW = edge(I,'canny');

where I is your image matrix. If you are interested in finding out how edge works, type

edit edge

into your command window. You will then get to see MATLAB's own implementation.

You may wish to reimplement edge from scratch, to gain a good understanding of how image processing algorithms work. If so, I would direct you towards the following sources:

For your specific example with the rectangles, it is quite possible to use edge to find the edges. The one trick you have to do is to convert the rgb image to a grayscale one, using rgb2gray. Try for example:

rgb_image = imread('iarLe.png');
gray_image = rgb2gray(rgb_image);
edge_image = edge(gray_image);
imshow(edge_image);

enter image description here

Upvotes: 2

Related Questions