I have an image, and perform K-means
-based segmentation against is using slic
method. The code and result are attached. My question is that How can I extract the information for each segmented patch, such as its location, area, label, or related pixel values, etc.
segments = slic(img, n_segments = 250, sigma = 5,compactness=0.1)
As advised, I used props = regionprops(segments)
to extract the segmented patches. It turns out that props only has 249 elements instead of 250 as I setup in slic
method. what causes the mismatch here?
You can use skimage.measure.regionprops
. Note: SLIC currently returns values in [0, ..., n_labels-1]
, but regionprops
ignores 0, so you should add 1 to the output of SLIC.