weixin_44020081
�翘阿翘
2021-01-14 11:18

求助!!matlap中循环获取边界,轮廓反向问题!!!

  • c语言

matlap里面  循环获取边界,在for循环里面画出来的轮廓是正确的.  但是在for循环外面再次绘制同样的轮廓就是完全反向

谢谢大佬们帮忙解决~~~~~~


im = imread('5-1.png');
BW = im2bw( im ); 
r1=4;r2=1;r3=0.8;
[B,L,N] = bwboundaries(BW);
       imshow(BW); hold on;
       for k=1:length(B),
         boundary = B{k};
         if(k > N)
%            plot(boundary(:,2), boundary(:,1), 'g','LineWidth',2);  %显示内部边界
           outer_loopx = boundary(:,2)';
           outer_loopy = boundary(:,1)';
     
         
           plot(outer_loopx,outer_loopy,'g','LineWidth',1)
           
           %x,y坐标
         else
%            plot(boundary(:,2), boundary(:,1), 'r','LineWidth',2);  
           inner_loopx=boundary(:,2)';
           inner_loopy=boundary(:,1)';
           %显示外部边界
           plot(inner_loopx,inner_loopy,'r','LineWidth',1)
         end
       end
       figure
       axis equal
       plot(outer_loopx,outer_loopy,'g','LineWidth',1)

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

4条回答