我试图从中心作为光盘中心像素的视网膜图像中提取360 * 360像素部分。请帮助我如何从图像中找到连接的组件,然后仅在matlab中提取较大的组件。
答案 0 :(得分: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