Java中调整BufferedImage的亮度和对比度 [英] Adjust brightness and contrast of BufferedImage in Java
本文介绍了Java中调整BufferedImage的亮度和对比度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在用一些框架处理一堆图像,我得到的只是一堆 BufferedImage
对象.不幸的是,这些图像真的很暗,我想将它们调亮并稍微调整一下对比度.
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.
类似于:
BufferedImage image = something.getImage();
image = new Brighten(image).brighten(0.3); // for 30%
image = new Contrast(image).contrast(0.3);
// ...
有什么想法吗?
推荐答案
其实很简单.
RescaleOp rescaleOp = new RescaleOp(1.2f, 15, null);
rescaleOp.filter(image, image); // Source and destination are the same.
1.2 的 scaleFactor
和 15 的 offset
似乎使关于停止的图像更亮.
A scaleFactor
of 1.2 and offset
of 15 seems to make the image about a stop brighter.
耶!
在 RescaleOp
.
这篇关于Java中调整BufferedImage的亮度和对比度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文