monochrome black-and-white bitmap
I'm working on Android for converting a colored bitmap captured from the camera into a black-and-white monochromatic image (no grays!).
I've got several methods for the gray scale conversion but I can't manage to get my image to a b&W format.
Are there any methods for converting a bitmap into this开发者_StackOverflow format?
One solid way is a mean threshold bitmap. The method is described in this paper, in the method section. It's often used for image alignment, and will compensate for different brightness levels, etc. You can use it straight from color, or after a greyscale conversion. After you get your image, you can simply set the white pixels to white, and black to black with setPixels()
from a buffer.
You can also tweak it so that it doesn't use the mean exactly. You could have a slider for 0-100% black, where the mean would be 50%. That way you could do on-the-fly adjustments for each individual picture. You just have to recalculate the threshold and apply the pixel buffer again.
You can try this approatch:
- getPixels() from Bitmap instance
- iterate through all pixcels and if its code is more than some value to set white color otherwise black color.
- setPixels() to Bitmap.
精彩评论