This map processing code is not working correctly for this image

1 回表示 (過去 30 日間)
saravanakumar D
saravanakumar D 2014 年 1 月 31 日
回答済み: Image Analyst 2014 年 1 月 31 日
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

回答 (1 件)

Image Analyst
Image Analyst 2014 年 1 月 31 日

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by