0

I am trying to adjust brightness and contrast using ImageUtil.contrast It turns out it is working for RGB image only. So it means there's probably something I'm not aware about Gray and Bi-Level images.

Pixel wise Pixel will be too heavy task, if there's any filter , that would be good.

//Contrast    
BufferedImage contrastImg = ImageUtil.toBuffered(ImageUtil.contrast(img, 0.3f));
//Brightness
BufferedImage brightenedImg = ImageUtil.toBuffered(ImageUtil.brightness(img, 1.0f));
// Sharpness
BufferedImage sharpenedImg = ImageUtil.sharpen(img, 0.3f);

For RGB it works as expected, it fails for B/W and GRAY though.

Any Ideas?

  • A black and white image doesn't really have much color information to adjust.. Contrast is already max (black and white). Adjusting brightness will either make the image all black or all white, or have no effect at all... Also sharpening is hard. So I'm not really sure what you expect? For grayscale it should work though... Do you have a sample image? – Harald K Nov 09 '19 at 19:49
  • Seems correct for B/W images. Also I tried with (for other types)' contrastImg = ImageUtil.toBuffered(ImageUtil.contrast(buffImg, 0.37f), BufferedImage.TYPE_INT_RGB);' And it worked. – Uttam Burman Nov 11 '19 at 12:09

0 Answers0