0

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

İsmet Alkan
  • 5,361
  • 3
  • 41
  • 64
user1263390
  • 187
  • 3
  • 4
  • 12
  • Why do you want to re-write it when a perfectly useable function already exists? Do you wish to customise `edge` in some way? You can use both the canny and sobel algorithms with `edge`. – Bill Cheatham Apr 04 '12 at 17:12

1 Answers1

2

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

Bill Cheatham
  • 11,396
  • 17
  • 69
  • 104
  • You still haven't explained why you want someone else to help you to do this when there is a very well implemented version, with source code available, in MATLAB already. Why do you need a new version of `edge`? – Bill Cheatham Apr 04 '12 at 17:51
  • Because in his university they forgot to buy the package that includes `edge` :-P – Nathan Fellman Apr 04 '12 at 18:01
  • @Nathan, I would believe that if it weren't for the specific requirements such as only using plus minus divide etc. I think this question is missing a tag. – Bill Cheatham Apr 04 '12 at 18:05
  • do you think so? Let's ask... @user1263390, is this a homework question? – Nathan Fellman Apr 04 '12 at 18:35