In that case Remi is correct, within a small error. The image is discrete and so there will be a small difference between using all of the pixels and only those in the outline.
It's some (but not all) times the same, here is an example of the centroid for an object and its boundary, you can see that the values of Y are shifted a little bit.
Excellent. Thank you very much. Good points for all. I saw the diferences.
The points do not match and do not necessarily have to be very close when the representation of the object is changed. The distance between the two points is totally dependent on the shape of the object.