1 | initial version |
I guess the threshold algorithms proposed here could help you out:
http://docs.opencv.org/modules/imgproc/doc/miscellaneous_transformations.html
The threshold function applied twice could do exactly what you want. Just convert your 2D image structure to a single row vector first.