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('p5-in1.jpg');
ShowColorImage(S,'0');
2. Edge detection using different methods
S2 = RGB2Gray(S);
S3 = edge(S2,'sobel');
ShowImage(S3,'0');
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;
Sw2 = edge(double(Sw),'prewitt');
ShowImage(Sw2,'0');
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>
Sb2 = edge(double(Sb),'prewitt');
ShowImage(Sb2,'0');
The post processing can be used to remove unwanted noise.