Unexpected return

Hi,

label_img = measure.label(img)

regions = measure.regionprops(label_img)

print(“regions”, regions[0].bbox)

#print result
regions (1600, 2080, 0, 1602, 2082, 3)

Why regions[0].bbox return 6 values, when expected 4 ( bbox : tuple:Bounding box `(min_row, min_col, max_row, max_col))? What the additional two mean?

Hi @vitaly-pos,

Welcome to the forum.

What is the size / dimensionality of label_img?
If it’s 3d, I would expect the return to be a 6-tuple
(min_x, min_y, min_z, max_x, max_y, max_z)
Could that be the case?

John

Indeed, as hinted at by @bogovicj, your image appears to be a colour image, with 3 channels at the end. measure.label is probably not doing what you think it’s doing. If you have a colour image, first you have to segment it (divide it into regions, each with a different number). See the segmentation examples in our gallery for more information. Once you have these, you can use regionprops to get a property for each region.

1 Like

Thank you so much. The problem really was in the color image. I applied

img_gray = rgb2gray(img)

and received:

regions (1602, 2082, 2394, 3912)

What I need!