Monochrome black and white bitmap

I am working on Android to convert a color bitmap captured from a camera to a black and white monochrome image (no grayscale!).

I have several methods for converting greyscale, but I am unable to get the b & W image.

Are there any methods for converting a bitmap to this format?

+1


source to share


2 answers


One solid way is the middle threshold bitmap. This method is described in this article in the method section. It is often used to flatten the image and compensate for different levels of brightness, etc. It can be used directly from color or after grayscale conversion. After you get the image, you can simply set the white pixels to white and black to black using setPixels()

the buffer.



You can also tweak it so that it doesn't use the mean exactly. You can have a slider for 0-100% black, where the average will be 50%. This way you can make adjustments on the fly for each individual image. You just need to recalculate the threshold and apply the pixel buffer again.

+2


source


You can try this:



  • getPixels () from Bitmap instance
  • iterating over all pixels and if its code is greater than some value to set the color to white, otherwise black.
  • setPixels () to a bitmap.
0


source







All Articles