This map processing code is not working correctly for this image
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155860/image.png)
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
0 Kommentare
Antworten (1)
Image Analyst
am 31 Jan. 2014
Have you seen Steve's new blog entry on Maze solving? http://blogs.mathworks.com/steve/2014/01/21/solving-mazes-with-the-watershed-transform/
0 Kommentare
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!