【发布时间】:2015-02-08 17:40:22
【问题描述】:
我正在尝试从以光盘的中心像素为中心的视网膜图像中提取 360*360 像素的部分。请帮助我如何从图像中找到连接的组件,然后仅在 matlab 中提取较大的组件。
【问题讨论】:
-
你期待什么样的答案?
标签: matlab connected-components
我正在尝试从以光盘的中心像素为中心的视网膜图像中提取 360*360 像素的部分。请帮助我如何从图像中找到连接的组件,然后仅在 matlab 中提取较大的组件。
【问题讨论】:
标签: matlab connected-components
您可以使用以下代码:
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
【讨论】: