简体   繁体   中英

OpenCV get subimages by mask

Have you any ideas how can I with python and OpenCV get subimages on original image by that mask? I need separated subimages of every white area. Because it's not rects it's hard to get them separated. 在此处输入图片说明

I think you are looking for connectedComponentsWithStats(), which will give you connected components (ie, one label per white area). The result will be a labeled image with a separate label for each component.

From this, it is easy to extract the part of the image with a specific label.

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