# Will this code give me the coordinates for the intensity-weighted centroid of image?

```
Mat image;
Moments moments(image);
int x = moments.M10 / moments.M00;
int y = moments.M01 / moments.M00;
```

yes. (well, maybe. unsure, if i understand you)

(what did you want ? there's the geometric center (cen of bbox), and the center-of-mass, which you got here)

I need to find the center of an irregular shape with the highest intensity offset from the geometric center. The intensity level should be considered when calculating the center.

moments() should be appplied to binary images, so the intensity is the same for all .

please explain: "highest intensity offset from the geometric center."

I have included an example image.

cv::moments has a boolean input argument isBinaryImage. So I guess it is prepared to receive non-binary images. I don't really know what is the result, I guess you should try it, plot the resulting x,y point and verify if the result makes sense.