creating image mask of 288 by 288 pixel from centroid location, threshold the image mask and out put summed pixel area
5 views (last 30 days)
Krispy Scripts on 12 Aug 2016
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:
crop=imcrop(binaryImage, [xmin ymin width height]);
Image Analyst on 12 Aug 2016
Not sure what "the centroid's origin" means, but it appears that you want the upper left centroid, and to take a box going 288 pixels down from that and 288 pixels over from that, regardless if other centroids are included in that cropping box. So to do that, you'd do (without any loop at all):
xmin = floor(min(xCentroids));
ymin = floor(min(yCentroids));
width = 288;
height = 288;
croppedImage = imcrop(binaryImage, [xmin, ymin, width, height]);
that gives you the sub-image (the pixel values) of this 288x288 square of the binary image. I have no idea what you mean by "find the pixel value of this region" and why you think graythresh() may help you. There is nothing to threshold - it's already a binary image! And besides, you already have the pixel values because they're in the array croppedImage, so I don't know why you think you need any additional operations to get them.