-5

我试图从中心作为光盘中心像素的视网膜图像中提取 360*360 像素部分。请帮助我如何从图像中找到连接的组件,然后仅在 matlab 中提取较大的组件。

4

1 回答 1

1

您可以使用以下代码:

connComp = bwlabel(yourImage); %find the connected components
imageStats = regionprops(connComp,'all'); 
compNumber = size(imageStats);
for i=1:compNumber - 1 % to compare sizes of connected components
   box1 = imageStats(i).BoundingBox;
   compareVar1 = box1(3)*box1(4);
   box2 = imageStats(i+1).BoundingBox;
   compareVar2 = box2(3)*box2(4);
   if compareVar1 > compareVar2
      largestPosition=i;
   end
end
imshow(imageStats(largestPosition).Image) %this is the largest connected component
于 2015-02-09T02:26:44.057 回答