Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find each SLIC superpixel's centroid in python?

newbie here! I'm working with python plus opencv and skimage packages. I've segmented an image in superpixels using:

segments = slic(image, n_segments=numSegments, sigma=1, convert2lab=True)

Now I'd like to get the coordinates associated with each superpixel's centroid, how can I do that?

like image 752
Jimbo Avatar asked Jun 20 '26 17:06

Jimbo


1 Answers

Try looking at skimage.measure.regionprops:

from skimage.measure import regionprops

regions = regionprops(segments)
for props in regions:
    cx, cy = props.centroid  # centroid coordinates
like image 148
Shai Avatar answered Jun 23 '26 08:06

Shai