简体   繁体   中英

How to get box around contour using skimage.segmentation.felzenszwalb?

I'm trying to get a box around a segmented object on the edge of the image, that is, there is no contour around the segmentation because the object is only partially inside the image region.

I use skimage.segmentation , find_boundaries , clear_border , and regioprops . However, regionprops does not provide those edge cases

segments_fz = felzenszwalb(cv2.cvtColor(image, cv2.COLOR_BGR2RGB), scale=300, sigma=0.5, min_size=50)
cleared = clear_border(segments_fz)
label_image = label(cleared)
regionprops(label_image)

A box around segmented object near the limit of the image region.

You shouldn't use clear_border . Then the objects on the border will be treated like any other. The bbox property should give you a bounding box for your object of interest, while find_boundaries and mark_boundaries will let you get or visualise the boundaries between segments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM