1 | initial version |
you can do 2 passes, one for white, and one for black.
the grey mask then is the inverse of the or'ed black and white mask. example:
Mat_<uchar> m(1,5); m << 30,110,170,220,240;
Mat b = m < 100;
Mat w = m > 200;
Mat g = ~ (b|w);
cout << b << endl;
cout << g << endl;
cout << w << endl;
.
[255, 0, 0, 0, 0]
[ 0, 255, 255, 0, 0]
[ 0, 0, 0, 255, 255]