i m trying to extract 360*360 pixels part from an retinal image with center as optical disk's center pixel. please help me with how to find the connected components from an image and then extract the larger one only in matlab.
Asked
Active
Viewed 1,631 times
-5
-
1what kind of answer do you expect? – embert Feb 08 '15 at 18:12
1 Answers
1
you can use the following code:
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

ammar
- 121
- 8