MATLAB: Can i get the [x,y]co-ordinates of pixels in the labelled regions

connected componentsImage Processing Toolboxlabel;pixel co-ordinates

hi, thanks in advance for viewing my question and trying to answer it. i have a retinal image as my input which is black and white.now all i need is to get total number of connected components and xy-coordinates of those pixels which are labelled. i found the labels using bwlabel() and now i need coordinates for those labels.here opim is my input image.
label=bwlabel(opim);
d=max(max(label));
for j=1:d
[row,col]=find(label==j);
len=max(row)-min(row)+2;
breadth=max(col)-min(col)+2;
target=uint8(zeros([len breadth]));
sy=min(col)-1;
sx=min(row)-1;
for i=1:size(row,1)
x=row(i,1)-sx;
y=col(i,1)-sy;
target(x,y)=opim(row(i,1),col(i,1));
end
end
thankyou.

Best Answer

WHY do you need the coordinates of those labels? I never do. You code can do this:
[labeledImage, numberOfBlobs] = bwlabel(opim);
for j=1: numberOfBlobs
To get just one labeled blob at a time, you can use ismember:
thisBlob = ismember(labeledImage, blobNumber); % in the loop you'd use j instead of blobNumber