Assume two Mat CV_8UC1 images, mask, and label, how to do the following operation in OpenCV (C ):
mask(label==5) = 255; // this is allowed in Matlab
// or
mask[label==5] = 255; // this is allowed in Python
CodePudding user response:
You could use inrange() with lowerb and upperb both set to 5,
or you could use compare() with src2 set to 5 and cmpop set to cv::CMP_EQ.
Both will set the output mask to be 255 where the values match.
