How to programmatically change contrast of a bitmap in android?

前端 未结 8 2026
眼角桃花
眼角桃花 2020-12-02 17:35

I want to programmatically change the contrast of bitmap. Till now I have tried this.

private Bitmap adjustedContrast(Bitmap src, double value)
    {
                


        
8条回答
  •  情深已故
    2020-12-02 18:07

    I just had the same problem and ended up using the Color Matrix that Ruslan Yanchyshyn describes. I needed to automatically adjust brightness depending on the image, so I used BoofCV to create a histogram from a scaled version of the image - It took way to long to process the whole image. Then I analyzed the histogram - looked at what was the darkest and brightest colors and then created a color matrix which transforms the colors so the darkest colors are 0 and the brightest colors are 255. In this way the new image uses the whole spectrum from dark/black to light/white now.

    Ended up writing a small post on how I did it on our company blog here if anyone are interested. http://appdictive.dk/blog/projects/2016/07/26/levels_with_color_matrix/

提交回复
热议问题