HDR图像显示

来源:互联网 发布:win10很卡怎么优化 编辑:程序博客网 时间:2024/05/22 04:55

高动态范围图像

(High-Dynamic Range,简称HDR),相比普通的图像,可以提供更多的动态范围和图像细节,根据不同的曝光时间的LDR(Low-Dynamic Range)图像,利用每个曝光时间相对应最佳细节的LDR图像来合成最终HDR图像。

点击看大图

tone mapping

一张HDR图片,它记录了远远超出256个级别的实际场景的亮度值,超出的部分在屏幕上是显示不出来的。所以线性解码,总是导致图像一部分区域过于明亮,或者另一部分过于暗淡。

点击看大图

解决的方法就是tone mapping。这里我们将图像分解为两个层,一个基层(base layer or large-scale features)和一个细节层(detail layer)。只对基层进行对比度压缩,保持细节层不变。这里为将图像分解成两层,且保持边缘特性,就需要采取一些快速健壮的保边去噪的滤波器。比如说双边滤波(BF)等。

算法流程

根据《Fast Bilateral Filtering for the Display of High-Dynamic-Range Images 》给出了对比度缩减的流程:

  1. input intensity= 1/61*(R*20+G*40+B)
  2. r=R/(input intensity), g=G/input intensity, B=B/input intensity
  3. log(base)=Bilateral(log(input intensity))
  4. log(detail)=log(input intensity)-log(base)
  5. log (output intensity)=log(base)*compressionfactor+log(detail) - log_absolute_scale
  6. R output = r*10^(log(output intensity)), etc.

注:第一步是将原图像转换成其灰度图像,你可以使用其他你喜欢的转换公式。compressionfactor是对基层的压缩系数,log_absolute_scale是一个偏置参数,以确保基层压缩后最大像素值为1,这两个参数都与图像相关。这里作者建议取值
compressionfactor = targetContrast/(max(log(base)) - min(log(base))),log_absolute_scale= max(log(base))*compressionfactor。

点击看大图

代码

通常算法最后还要进行gamma校正,示例如下,edge preserving fliter你可以换成其他:

%BFTONEMAP High Dynamic Range tonemapping using BF%%   The script reduces the dynamic range of an HDR image using the method%   originally proposed by Durand and Dorsey, "Fast Bilateral Filtering%   for the Display of High-Dynamic-Range Images",%   ACM Transactions on Graphics, 2002.%% Load HDR image from file and convert to greyscalehdr = double(hdrread('smallOffice.hdr'));I = 0.2989*hdr(:,:,1) + 0.587*hdr(:,:,2) + 0.114*hdr(:,:,3);logI = log(I+eps);%% Perform edge-preserving smoothing using bilateralFilterbase = log(bilateralFilter(I));%% Compress the base layer and restore detailcompression = 0.25;detail = logI - base;OUT = base*compression + detail;OUT = exp(OUT);%% Restore colorOUT = OUT./I;OUT = hdr .* padarray(OUT, [0 0 2], 'circular' , 'post');%% Finally, shift, scale, and gamma correct the resultgamma = 1.0/2.2;bias = -min(OUT(:));gain = 0.45;OUT = (gain*(OUT + bias)).^gamma;imshow([hdr OUT]);

效果

bilateralFilter是双边滤波器,若是你找不到合适的,可以到这里下载。

点击看大图

参考

[1]: http://people.csail.mit.edu/fredo/PUBLI/Siggraph2002/

[2]: http://www.cnblogs.com/Imageshop/p/3428809.html

[3]:
http://baike.baidu.com/link?url=FeAX3SzIdJdyzL4JwHQhB_Nyv4-mDeNF1lUQe7vBBCe5K6RV7y9HGgJDIBmSvdn79OR17vwSWQjARC9U2xi7LJL38X2V27qqkJ6ESSCcAYgPDLZln8oE0JCiHnydMmdG
[4]: http://people.csail.mit.edu/sparis/bf/

转载请保留以下信息

作者 日期 联系方式 风吹夏天 2015年5月1日 wincoder@qq.com
1 0
原创粉丝点击