1 | initial version |
If I am understanding correctly, you are trying to get color values corresponding to each dot, then you can follow the contour approach instead of bounding grid. Assumes the background always white,
the procedure is like,
Threshold source image to create contours corresponding to dots.
Find contours to extract each object(dot) from thresholded image.
Now you can iterate through each contour, can draw mask corresponding for each contour.
In a loop use Mat::mean to calculate average color value, here you could use above created mask as the second argument to mean().
Repeat above two steps for each contour.