Finding centroid of an image with a summed pixel area greater than 120 pixels squared
9 views (last 30 days)
Krispy Scripts on 11 Aug 2016
I am trying to find the position of an object in an image. I need to first find connected pixels with intensity values above threshold, which I used imregionalmax function. I know need to identify centroid's with areas greater than 120 pixels squared. I am having no problem using imregionalmax and then regionprops function to find centroid, but am having issues figuring out how to find centroids of objects with pixel areas greater than 120 pixels squared.
Image Analyst on 12 Aug 2016
Heath, no, don't use imregionalmax. Use thresholding followed by bwareaopen followed by bwlabel followed by regionprops:
binaryImage = grayImage > 120;
binaryImage = bwareaopen(binaryImage, 120); % Keep blobs 120 pixels and bigger.
labeledImage = bwlabel(binaryImage);
props = regionprops(labeledImage, 'Centroid');
allCentroids = [props.Centroid];
xCentroids = allCentroids(1:2:end);
yCentroids = allCentroids(2:2:end);
See my thresholding application (to visually/interactively threshold the image) and Image Segmentation Tutorial in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862