I'm using version OpenCV 3.2.
I open the default camera:
VideoCapture cap;
cap.open(0);
and grab the current frame:
Mat frame;
cap.read(frame);
Now I want to reduce the number of colours shown in the image. Thus, I do an integer division and multiply the image by the same scalar value, let it be 10 for example. This can easily done with the C++ operators' overload.
Mat processedFrame = (frame / 10) * 10
However, frame
values are in float format. The division is then not performed as an integer division, and the reduction of colours is not achieved.
I guess it can be fixed by making a cast of frame
to integer values before doing the integer division. How could I do this cast taking into account that a camera can grab images in 1 (gray scale) or 3 (BGR) colour channels?