Ask Your Question

Revision history [back]

Solution found myself ... It seems that you need to place a different value for each marker, if all markers have the same value, then it will try to create one big region, in which it fails. So it comes down to when creating the markers, which I did by

Mat markers  = Mat::zeros(threshold_BW.rows, threshold_BW.cols, CV_8UC1);
for(int i = 0; i < centers.size(); i++){
    circle(markers, centers[i], 5, 255, CV_FILLED);
}

Which should be

Mat markers  = Mat::zeros(threshold_BW.rows, threshold_BW.cols, CV_8UC1);
for(int i = 0; i < centers.size(); i++){
    circle(markers, centers[i], 5, i+1, CV_FILLED);
}

Then the result looks like

image description