I have the centroids of all the objects of an image. I have than cropped a 288 by 288 pixel area around the images (the size of the area is to try and isolate one centroid uniformly). Is it possible to tell if I have more than one centroid within my cropped image.
Here is the code I have to find the centroid and crop it. I am using Otsu's method (graythresh the im2bw) to threshold because it is predetermined method I am suppose to use, even though I know there is better ways. Code at the beginning to take out all objects with less than 120 pixels connection is there as well just fyi.
The overall goal is to individually isolate the object that each centroid is on and to isolate it and find the area of it, after thresholding. Perhaps there is a better way.
if true tic;load image=originalimage;binaryimage1=imregionalmax(loadimage);binaryimage2=bwareaopen(binaryimage1,120);labeledimage=bwlabel(binaryimage2);props=regionprops(binaryimage2,'Centroid);allCentroids=[props.Centroid];xcentroids=allCentroids(1:2:end);ycentroids=allCentroids(2:2:end);numberofobjects=size(props);for m=1:numberofobjects xmin=xcentroids(m); ymin=ycentroids(m); cropthat=imcrop(loadimage, [xmin-144, ymin-144, 288, 288]); pixellevel=graythresh(cropthat); levelbw=im2bw(cropthat,pixellevel); regionprops2=regionprops(levelbw,'area');end
Best Answer