The first way is the weighted centroid. The weighted centroid takes into account the gray levels of the image. A centroid based on the binary image alone does not. So if your image is brighter on the left side, then the weighted centroid will be to the left of the centroid just based on the binary image. You can get both with regionprops by passing in both the gray scale image and the binary image into regionprops:
measurements = regionprops(labeledImage, grayImage, 'Centroid', 'WeightedCentroid');
Best Answer