Ask Your Question

Revision history [back]

Split a cv::mat into submats based on each containing a contour

Hey Guys,

I'm trying to process an image, so that I can do some data analysis with it afterwards. As input I have an image with one or multiple bright spots. I use some filters to reduce noise and then use threshhold to get a binary image. Now I search for all Contours in this image and get the bounding Rectangles. So far no problem. It could look similar to this (but probably with more bright spots):

It could look similar to this (but probably with more bright spots)threshholded imagecontours with bounding rectangle

But now I have to split up the image, so that I can analyse the data with better accuracy. Therefore I want to split the whole cv::mat into several rectangular submatrizes, with each containing exactly one contour.

Do anyone have a idea how to do that? To be precise, I only need the start column/row and the end column/row of each submatrix.

For Example: With the given image it should split the image along the red line: result

Thank you in advance! :)