From: Chris L on
Hi i am trying to run some edge detection algorithms such as sobel
and canny on an color image but I get an error that only gray scale
images are to be used.

When I use RGB2GRAY the program does work but I get a red image
instead of some edge detection.

RGB = imread(['C:\temp\4.jpg']); % Read the image
I = rgb2gray(RGB);
J = edge(I,'sobel')
axes(handles.axes2);
image(I)
set(handles.axes2, 'Visible', 'off');

Any idea what im doing wrong?

Thanx, Chris
From: Chris on
Any help out there?
Thanks again!

Chris

Chris L wrote:
>
>
> Hi i am trying to run some edge detection algorithms such as sobel
> and canny on an color image but I get an error that only gray scale
> images are to be used.
>
> When I use RGB2GRAY the program does work but I get a red image
> instead of some edge detection.
>
> RGB = imread(['C:\temp\4.jpg']); % Read the image
> I = rgb2gray(RGB);
> J = edge(I,'sobel')
> axes(handles.axes2);
> image(I)
> set(handles.axes2, 'Visible', 'off');
>
> Any idea what im doing wrong?
>
> Thanx, Chris
From: Dave Robinson on
Chris wrote:
>
>
> Any help out there?
> Thanks again!
>
> Chris
>
> Chris L wrote:
>>
>>
>> Hi i am trying to run some edge detection algorithms such as
> sobel
>> and canny on an color image but I get an error that only gray
> scale
>> images are to be used.
>>
>> When I use RGB2GRAY the program does work but I get a red image
>> instead of some edge detection.
>>
>> RGB = imread(['C:\temp\4.jpg']); % Read the image
>> I = rgb2gray(RGB);
>> J = edge(I,'sobel')
>> axes(handles.axes2);
>> image(I)
>> set(handles.axes2, 'Visible', 'off');
>>
>> Any idea what im doing wrong?
>>
>> Thanx, Chris

In changing the RGB image into grey, you are in danger loosing
possibly important detail. A junction between two distinct colours,
which have the same grey level representation will disappear. There
are edge detectors which are specifically designed to work on
coloured images - however I don't have the detail here with me. But
what might work for you is to split your RGB image into its three
component planes, edge detect using Sobel or Canny, then either
recombine them using a logical OR function, else reform back into an
RGB image, so you can tell the colours of the edges.

It should be said that this technique is not as good as the colour
edge detectors, you might like to look them up on the web.

Regards

Dave Robinson
From: Steve Eddins on
"Chris L" <ChrisESL99(a)Hotmail.com> writes:

> Hi i am trying to run some edge detection algorithms such as sobel
> and canny on an color image but I get an error that only gray scale
> images are to be used.
>
> When I use RGB2GRAY the program does work but I get a red image
> instead of some edge detection.
>
> RGB = imread(['C:\temp\4.jpg']); % Read the image
> I = rgb2gray(RGB);
> J = edge(I,'sobel')
> axes(handles.axes2);
> image(I)
> set(handles.axes2, 'Visible', 'off');

You are getting a "red" image because MATLAB's Handle Graphics image function
is simply displaying I as if it were an indexed image against the default
colormap of the figure. Use the Image Processing Toolbox display function
imshow.

--
Steve Eddins

Development Manager, Image Processing Group
The MathWorks, Inc.
From: S Kota on
Instead of converting RGB to Gray its better to convert RGB to HSI
using rgb2hsv and apply edge detection on intensity values and then
get RGB image. This might give You better results than RGB to Gray.

Kota
Steve Eddins wrote:
>
>
> "Chris L" <ChrisESL99(a)Hotmail.com> writes:
>
>> Hi i am trying to run some edge detection algorithms such as
> sobel
>> and canny on an color image but I get an error that only gray
> scale
>> images are to be used.
>>
>> When I use RGB2GRAY the program does work but I get a red image
>> instead of some edge detection.
>>
>> RGB = imread(['C:\temp\4.jpg']); % Read the image
>> I = rgb2gray(RGB);
>> J = edge(I,'sobel')
>> axes(handles.axes2);
>> image(I)
>> set(handles.axes2, 'Visible', 'off');
>
> You are getting a "red" image because MATLAB's Handle Graphics
> image function
> is simply displaying I as if it were an indexed image against the
> default
> colormap of the figure. Use the Image Processing Toolbox display
> function
> imshow.
>
> --
> Steve Eddins
>
> Development Manager, Image Processing Group
> The MathWorks, Inc.
>