This map processing code is not working correctly for this image
    3 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
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
0 commentaires
Réponses (1)
  Image Analyst
      
      
 le 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 commentaires
Voir également
Catégories
				En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange
			
	Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

