I'm processing a bunch of images with some framework, and all I'm given is a bunch of BufferedImage
objects. Unfortunately, these images are really dim, and I'd like to brighten them up and adjust the contrast a little.
Something like:
BufferedImage image = something.getImage();
image = new Brighten(image).brighten(0.3); // for 30%
image = new Contrast(image).contrast(0.3);
// ...
Any ideas?
Invoke the convertTo() method by passing the empty matrix, -1 (to get the same type), alpha value to increase or decrease contrast (0-1 or, 1-100) and, 0 as beta value.
If you are familiar with Java's util. List, the difference between Image and BufferedImage is the same as the difference between List and LinkedList. Image is a generic concept and BufferedImage is the concrete implementation of the generic concept; kind of like BMW is a make of a Car.
Brightness refers to the overall lightness or darkness of the image. Use the Brightness slider to adjust your image's luminosity level. Contrast is the difference in brightness between objects or regions.
Click the picture that you want to change the contrast for. Under Picture Tools, on the Format tab, in the Adjust group, click Contrast. Click the contrast percentage that you want.
That was easy, actually.
RescaleOp rescaleOp = new RescaleOp(1.2f, 15, null);
rescaleOp.filter(image, image); // Source and destination are the same.
A scaleFactor
of 1.2 and offset
of 15 seems to make the image about a stop brighter.
Yay!
Read more in the docs for RescaleOp
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With