是否有一些非常簡單和基本的代碼來預覽 HDR 影像(比如獲得 2DBufferedImage輸出或其他東西)?
我正在使用
使用默認/內置色調映射器運行,或者ImageIO.read(hdrFile)按照評論中的建議簡單地讀取影像,影像將如下所示:

最后,使用自定義全域色調映射器對代碼進行一些操作;param.setToneMapper(new DefaultToneMapper(0.75f)),我得到這樣的結果:

uj5u.com熱心網友回復:
在與@HaraldK 和他的代碼添加進行了長時間討論之后,我發布了這個問題的最終正確代碼,實際上是@qraqatit代碼的混合更新了一點@HaraldK 添加糾正錯誤的色調映射,這里是:
public int rgbToInteger(int r, int g, int b) {
int rgb = r;
rgb = (rgb << 8) g;
rgb = (rgb << 8) b;
return rgb;
}
public BufferedImage hdrToBufferedImage(File hdrFile) throws IOException {
HDRImage hdr = HDREncoder.readHDR(hdrFile, true);
int width = hdr.getWidth();
int height = hdr.getHeight();
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
float colorToneCorrection = 0.75f;
for (int x = 0; x < width; x ) {
for (int y = 0; y < height; y ) {
float r = hdr.getPixelValue(x, y, 0);
int red = (int) ((r / (colorToneCorrection r)) * 255);
float g = hdr.getPixelValue(x, y, 1);
int green = (int) ((g / (colorToneCorrection g)) * 255);
float b = hdr.getPixelValue(x, y, 2);
int blue = (int) (int) ((b / (colorToneCorrection b)) * 255);
bi.setRGB(x, y, rgbToInteger(red, green, blue));
}
}
//MAKE THE RESULTING IMAGE A BIT BRIGHTER
float brightness = 1.35f;
float contrast = 0f;
RescaleOp rescaleOp = new RescaleOp(brightness, contrast, null);
rescaleOp.filter(bi, bi);
return bi;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/484443.html
