调整Java中BufferedImage的亮度和对比度 [英] Adjust brightness and contrast of BufferedImage in Java
本文介绍了调整Java中BufferedImage的亮度和对比度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在用一些框架处理一堆图像,而我给出的只是一堆 BufferedImage
对象。不幸的是,这些图像真的很暗淡,我想照亮它们并调整对比度。
类似于:
BufferedImage image = something.getImage();
image = new Brighten(image).brighten(0.3); //为30%
图片=新对比度(图片).contrast(0.3);
// ...
有什么想法?
<
RescaleOp rescaleOp = new!解决方案
RescaleOp(1.2f,15,null);
rescaleOp.filter(image,image); //源和目标是相同的。
A scaleFactor
为1.2和<$ c $ b> $偏移 15似乎使图像停止更明亮。
Yay!
请阅读文档 RescaleOp
。
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?
解决方案
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
.
这篇关于调整Java中BufferedImage的亮度和对比度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文