Hi all,
I am very new to the image analyst world. I have an image that has had the centroids calculated ( http://www.mathworks.com/matlabcentral/answers/299323-finding-centroid-of-an-image-with-a-summed-pixel-area-greater-than-120-pixels-squared ) thanks Image Analyst!
So now with these centroid locations (in struct array), I would like to take a 288 pixel by 288 pixel region around the centroid origins. My goal is to find the pixel value of this region, which I believe I can do with Otsu's method (graythresh function).
My attempts to calculate the coordinates for imcrop function for all my centroids have been unsuccessful, so I thought I would reach out to the MATLAB professionals.
Any help is of course appreciated.
Here is my attempt:
binaryImage=imregionalmax(loadedimage)binaryImage=bwareaopen(binaryImage, 120);labeledImage=logical(binaryImage);props=regionprops(labeledImage,'Centroid');allCentroids=allCentroids[props.Centroid];xCentroids=allCentroids(1:2:end);yCentroids=allCentroids(2:2:end);allCentorids=allCentroids';[size1,size2]=size(allCentroids);for k=1:1:size1 xmin=xCentroids(1,k); ymin=yCentroids(1,k); width=288; height=288; crop=imcrop(binaryImage, [xmin ymin width height]); pixellevel=graythresh(crop) endend
Best Answer