[英]Adjust brightness and contrast of BufferedImage in Java
I'm processing a bunch of images with some framework, and all I'm given is a bunch of BufferedImage
objects. 我正在使用一些框架处理一堆图像,而我给出的只是一堆
BufferedImage
对象。 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? 有任何想法吗?
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. scaleFactor
为1.2且offset
为15似乎使得关于停止的图像更亮。
Yay! 好极了!
Read more in the docs for RescaleOp
. 阅读
RescaleOp
文档中的RescaleOp
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.