Saving Clusters in OpenCV

asked 2018-02-19 19:12:50 -0500

I'm using OpenCV with Python 3.6. Suppose I have this this black-white binary image, which shows 10 white blobs on a black background. Is it possible to save each blob as a separate image file (for a total of 10 files)? For example, the top-left blob would save as this. Note that in the example, only the top-left blob is showing.

I know that clustering, masks and ROI are things in OpenCV, but I'm unsure how to use them to save each cluster automatically. Apologies if there's already a duplicate answer; I'm new to computer vision and might be searching up the wrong terms!

edit retag flag offensive close merge delete

Comments

use connectedComponentsWithStat you will get Rect included each cluster.

LBerger gravatar imageLBerger ( 2018-02-20 15:31:54 -0500 )edit