Adjust the brightness and contrast of bufferedimage in Java
•
Java
I'm using some frameworks to process a bunch of images. All I have is a bunch of buffered image objects Unfortunately, these images are really dark. I want to brighten them and adjust the contrast
It's like:
BufferedImage image = something.getImage(); image = new Brighten(image).brighten(0.3); // for 30% image = new Contrast(image).contrast(0.3); // ...
Any ideas?
Solution
It's actually very simple
RescaleOp rescaleOp = new RescaleOp(1.2f,15,null); rescaleOp.filter(image,image); // Source and destination are the same.
A scaling factor of 1.2 and an offset of 15 seem to make the image brighter about the stop
right on!
Read more in the docs for rescaleop
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码