How to convert bitmap image to binary image in android?

10,684

Are you looking for an algorithm to perform the conversion?

The easiest way is to compare each pixel value with a fixed threshold: if the pixel value is less than the threshold, the corresponding output pixel is black (0), else it is white (1).

If you wish to determine the threshold automatically, you may want to implement Otsu's method. That method does a correct job overall when you can't make too many assumptions about the pixels distribution in your image.

http://en.wikipedia.org/wiki/Otsu%27s_Method

As a reference, that's how it looks like in Mathematica: Binarize[image, threshold], and Binarize[img] for Otsu's method.

enter image description here

Share:
10,684
barzos
Author by

barzos

Updated on June 15, 2022

Comments

  • barzos
    barzos almost 2 years

    I need to convert bitmap to binary image for my hw.Do u know anything about that?

  • Kevin Gaudin
    Kevin Gaudin about 13 years
    start with giving more details about what you need. Your question does not make much sense.
  • barzos
    barzos about 13 years
    I didnt get any idea of converting binary image