Fix image mask bug in centroid