OpenCV converting one color to another
c++, colors, opencv
Solution
You can do the following.
Threshold your image using `inRange()`.
Mat image; // your original image
Mat mask;
void inRange(image, Scalar(255), Scalar(255), mask)
The output `mask` will be a binary mask where its pixel is set to 255 if the corresponding pixel in `image` equals to 255 (that is if the pixel value is between 255 and 255, boundaries are inclusive).
Copy `black_image` (your desired substitute color) into your original `image` through `mask` using `copyTo()`.
Mat black_image(image.size(), CV_8U, Scalar(0)); // all zeros image
black_image.copyTo(image, mask);
Problem
I have a greyscale image I would like to convert all the white pixels (pure white - 255) to black (0) only those colors, not all the greyscale How can I do this? Thank you! Ron