|
From: Chris L on 11 Mar 2005 01:02 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 11 Mar 2005 06:02 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 11 Mar 2005 07:09 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 11 Mar 2005 09:07 "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 11 Mar 2005 10:54 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. >
|
Pages: 1 Prev: optical flow Next: MATLAB Scource Code for JPEG2000 Needed - HELP!!! |