Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
color edge detection in rgb color space

Subject: color edge detection in rgb color space

From: kavita grewal

Date: 12 Sep, 2012 08:27:07

Message: 1 of 2

hi..my program is not running..pls tell what is error in this and how to remove that error.
RGB=imread('birdy.jpg');
RGB=double(RGB);
SIZE=size(RGB);
for i=2:SIZE(1)-1
for j=2:SIZE(2)-1
G_rx(i,j)=abs(RGB(i-1,j+1,1)+2*RGB(i,j+1,1)+RGB(i+1,j+1,1)-RGB(i-1,j-1,1)-2*RGB(i,j-1,1)-RGB(i+1,j-1,1))/255;
if G_rx(i,j)>1
    G_rx(i,j)=1;
end;
if G_rx(i,j)<0
    G_rx(i,j)=0;
end;
G_gx(i,j)=abs(RGB(i-1,j+1,2)+2*RGB(i,j+1,2)+RGB(i+1,j+1,2)-RGB(i-1,j-1,2)-2*RGB(i,j-1,2)-RGB(i+1,j-1,2))/255;
if G_gx(i,j)>1
    G_gx(i,j)=1;
end;
if G_gx(i,j)<0
    G_gx(i,j)=0;
end;
G_bx(i,j)=abs(RGB(i-1,j+1,3)+2*RGB(i,j+1,3)+RGB(i+1,j+1,3)-RGB(i-1,j-1,3)-2*RGB(i,j-1,3)-RGB(i+1,j-1,3))/255;
if G_bx(i,j)>1
    G_bx(i,j)=1;
end;
if G_bx(i,j)<0
    G_bx(i,j)=0;
end;
G_ry(i,j)=abs(RGB(i+1,j-1,1)+2*RGB(i+1,j,1)+RGB(i+1,j+1,1)-RGB(i-1,j-1,1)-2*RGB(i-1,j,1)-RGB(i-1,j+1,1))/255;
if G_ry(i,j)>1
    G_ry(i,j)=1;
end;
if G_ry(i,j)<0
    G_ry(i,j)=0;
end;
G_gy(i,j)=abs(RGB(i+1,j-1,2)+2*RGB(i+1,j,2)+RGB(i+1,j+1,2)-RGB(i-1,j-1,2)-2*RGB(i-1,j,2)-RGB(i-1,j+1,2))/255;
if G_gy(i,j)>1
    G_gy(i,j)=1;
end;
if G_gy(i,j)<0
    G_gy(i,j)=0;
end;
G_by(i,j)=abs(RGB(i+1,j-1,3)+2*RGB(i+1,j,3)+RGB(i+1,j+1,3)-RGB(i-1,j-1,3)-2*RGB(i-1,j,3)-RGB(i-1,j+1,3))/255;
if G_by(i,j)>1
    G_by(i,j)=1;
end;
if G_by(i,j)<0
    G_by(i,j)=0;
end;
if G_rx(i,j)+G_gx(i,j)+G_bx(i,j)>G_ry(i,j)+G_gy(i,j)+G_by(i,j)
G_RGB(i,j,1)=G_rx(i,j);
G_RGB(i,j,2)=G_gx(i,j);
G_RGB(i,j,3)=G_bx(i,j);
else
G_RGB(i,j,1)=G_ry(i,j);
G_RGB(i,j,2)=G_gy(i,j);
G_RGB(i,j,3)=G_by(i,j);
end;
end;
end;
figure;imshow(G_RGB);title('RGB');
grayG_RGB=rgb2gray(G_RGB);
figure;imshow(grayG_RGB);title('RGB');
please help me...

Subject: color edge detection in rgb color space

From: Steven_Lord

Date: 12 Sep, 2012 14:09:43

Message: 2 of 2



"kavita grewal" <ruchimittal1988@gmail.com> wrote in message
news:k2ph0r$75o$1@newscl01ah.mathworks.com...
> hi..my program is not running..

Define "not running" -- does it throw an error (and if so, what error does
it throw?), does it return a different result than you expect (and if so,
what result does it return and what result do you expect it to return?),
etc.

> pls tell what is error in this and how to remove that error.

We don't have your birdy.jpg file. Please do NOT send it to me directly;
either give more details IN THE NEWSGROUP about exactly what's happening and
what you expect to happen or post the picture somewhere EVERYONE can see it
then post a link in the group and perhaps someone will be able to offer
suggestions for how to correct the code.

*snip*

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us