This map processing code is not working correctly for this image

1 visualización (últimos 30 días)
saravanakumar D
saravanakumar D el 31 de En. de 2014
Respondida: Image Analyst el 31 de En. de 2014
I am doing map processing. In this task i have to draw the line vertical upwards(Brown color) when it touches another blob. At that time we have to replace the second blob centroid x value with starting blob x value and draw the skyblue line between two blobs We have to reapeat this process to all blob in the image.
In this image i get the perfect skyblue line from yellow rectangle to red circle. But this code work wrong from green circle to blue triangle
my code is below:
for i=1:totalblob
x=shape(i).cen(1,:);
y=shape(i).cen(2,:);
xi=x; yi=y;
w=0;flag=0;
y=y-1;
%TOP CHECKING
for(trail=1:1000)
color_val=color(y,x,RGB);
RGB(y,x,1)=240;
RGB(y,x,2)=31;
RGB(y,x,3)=191;
if((color_val==shape(i).color)&w==0)
if(y>5)
y=y-1;
end %x=x-1;
else if (color_val==White)
w=1;
if(y>5)
y=y-1;
end %x=x-1;
else if(color_val==Black)
break;
else
for i=1:tblob
xa=shape(i).cen(1,:);
ya=shape(i).cen(2,:);
colorval=color(y,x,IMG);
if (colorval==shape(i).color)
if(x-40<xa<x+40)
if(y-86<ya<y)
xj=xi;
yj=ya;
shape(i).cen(1,:)=xi;
order(or).order=[xi,yi,xj,yj];
or=or+1;
RGB=line(xi,yi,xi,yj,RGB);
flag=1;
xi=0;
yi=0;
xj=0;
yj=0;
break;
end
end
end
end
end
end
end
end
if (flag==1)
break;
end
end
imtool(RGB);
end

Respuestas (1)

Image Analyst
Image Analyst el 31 de En. de 2014

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by