English 中文(简体)
• 如何改变作为六氯乙烯价值储存的形象的对比和亮度
原标题:How to change the contrast and brightness of an image stored as pixel values

我的图像被储存成一系列的六氯乙烯价值。 我想能够运用亮度或与这种形象形成对照。 我是否能够用任何简单的方式或算法来实现这一点。

Here is my code...

   PlanarImage img=JAI.create("fileload","C:\aimages\blue_water.jpg");
   BufferedImage image = img.getAsBufferedImage();

   int w = image.getWidth();
   int h = image.getHeight();
   int k = 0;

   int[] sbins = new int[256];
   int[] pixel = new int[3];

   Double d = 0.0;
   Double d1;
   for (int x = 0; x < bi.getWidth(); x++) {
       for (int y = 0; y < bi.getHeight(); y++) {
           pixel = bi.getRaster().getPixel(x, y, new int[3]);
           k = (int) ((0.2125 * pixel[0]) + (0.7154 * pixel[1]) + (0.072 * pixel[2]));
           sbins[k]++;
       }
   }
最佳回答

我的建议是利用 Java的内在方法,调整光明和反差,而不是试图调整六氯乙烯的价值。 这样做似乎非常容易。

float brightenFactor = 1.2f

PlanarImage img=JAI.create("fileload","C:\aimages\blue_water.jpg");
BufferedImage image = img.getAsBufferedImage();

RescaleOp op = new RescaleOp(brightenFactor, 0, null);
image = op.filter(image, image);

浮动数占亮度的百分比。 在我的例子中,它将把亮度提高到现有价值的120%(即比原形象高20%)

See this link for a similar question... Adjust brightness and contrast of BufferedImage in Java

See this link for an example application... http://www.java2s.com/Code/Java/Advanced-Graphics/BrightnessIncreaseDemo.htm

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签