How do I convert a 24-bit colour image to binary image using MFC?
how to con开发者_JAVA技巧vert a bitmap image in binary image?
The simplest and easiest way to convert a grey scale image to a binary image is to just apply a threshold, i.e.
out[y][x] = in[y][x] > threshold ? 1 : 0;
The threshold
value can be fixed, e.g. 128, variable, supplied by the user, or determined automatically by histogramming the image first.
There are more sophisticated methods which will generate subjectively "better" binary images, but without knowing more about your requirements it's hard to know whether you need something more advanced or whether simple thresholding will be good enough.
精彩评论