Playing with “Edge Detection”

A lot of articles explain what is edge detection, how to apply it, and the usage of it. Different edge detection techniques such as sobel, prewitt, and canny are easily found from any image processing software.

However, when we really want to perform edge detection for certain purpose, the problems arise. Look at the following example:

1. Original image
S = imread('pic8.jpg');

2. Edge detection using different methods
S2 = rgb2gray(S);
figure, edge(S2,'canny');

It seems like great but the usage of these output are useless until we really know what we want to do. For exmaple, we want to find the white rabbit, we need to perform some pre-processing before the edge detection so that we can fully utilize the function to suite to our needs.

3. Edge detection for the white rabbit
Since we know the RGB value for white color is [255,255,255], we can pre-process the image to extract the white color region from the image.

Sw = S(:,:,1)>200 & S(:,:,2)>200 & S(:,:,3)>200;

Well, it seems like make more sense. Let's have a look on how to perform edge detection on the black rabbit:

4. Edge detection for the black rabbit

Sb = S(:,:,1)<40 & S(:,:,2)<40 & S(:,:,3)<40;

The post processing can be used to remove unwanted noise.