monochrome black-and-white bitmap

时间秒杀一切 提交于 2019-12-31 05:06:27

问题


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 format?


回答1:


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.




回答2:


You can try this approatch:

  1. getPixels() from Bitmap instance
  2. iterate through all pixcels and if its code is more than some value to set white color otherwise black color.
  3. setPixels() to Bitmap.


来源:https://stackoverflow.com/questions/6939657/monochrome-black-and-white-bitmap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!