1 | initial version |
see the lines from OpenCV Samples imageSegmentation.cpp as a sample what you already have done.
and here is a better alternative
Mat mask;
inRange(src, Scalar(255, 255, 255), Scalar(255, 255, 255), mask);
src.setTo(Scalar(0, 0, 0), mask);