局部边缘保持滤波(LEP)高动态范围图像HDR压缩 matlab程序(二)

本文为转载,原博客地址:http://blog.csdn.net/majinlei121/article/details/50420980


上一篇博客给出了论文"Gu B, Li W, Zhu M, et al. Local edge-preserving multiscale decomposition for high dynamic range image tone mapping[J]. Image Processing, IEEE Transactions on, 2013, 22(1): 70-79."的局部边缘保持滤波程序,本文给出的是高动态范围图像压缩的程序,即HDR转换为LDR,其中程序中用到的hdr格式的高动态范围图像下载地址为http://download.csdn.net/detail/majinlei121/9380904

下面为高动态范围压缩程序:

[cpp]  view plain  copy
  1. clear all;  
  2.   
  3. HDR = hdrread('..\HDR Images\AhwahneeGreatLounge_small.hdr');  
  4. % HDR = hdrread('..\HDR Images\AtriumMorning.hdr');  
  5. % HDR = hdrread('..\HDR Images\belgium.hdr');  
  6. % HDR = hdrread('..\HDR Images\cadik-desk02_mid.hdr');  
  7. % HDR = hdrread('..\HDR Images\designCenter.hdr');  
  8. % HDR = hdrread('..\HDR Images\desk.hdr');  
  9. % HDR = hdrread('..\HDR Images\doll.hdr');  
  10. % HDR = hdrread('..\HDR Images\groveD.hdr');  
  11. % HDR = hdrread('..\HDR Images\HancockKitchenInside_small.hdr');  
  12. % HDR = hdrread('..\HDR Images\memorial.hdr');  
  13. % HDR = hdrread('..\HDR Images\orion_correct_small.hdr');  
  14. % HDR = hdrread('..\HDR Images\paul_bunyan_small.hdr');  
  15. % HDR = hdrread('..\HDR Images\pillarsB_small.hdr');  
  16. % HDR = hdrread('..\HDR Images\snowman.hdr');  
  17. % HDR = hdrread('..\HDR Images\tinterna_small.hdr');  
  18. % HDR = hdrread('..\HDR Images\vinesunset.hdr');  
  19. % HDR = hdrread('..\HDR Images\yosemite_small.hdr');  
  20.   
  21. L_in=(1/3)*(HDR(:,:,1)+HDR(:,:,2)+HDR(:,:,3));  
  22. L=log(L_in*1e6+1);  
  23. L=L/max(max(L));  
  24. % L=mat2gray(L);  
  25.   
  26. alpha=0.1;  
  27. beta=1;  
  28. r=2;  
  29. nLevel = 3;  
  30. B = cell(1, nLevel);  
  31. D = cell(1, nLevel);  
  32. D_compression=cell(1, nLevel);  
  33. B{nLevel}=L;  
  34. for j = nLevel:-1:2  
  35.     B{j-1}=LocalWls_HDR(B{j}, alpha, beta, r);  
  36.     D{j}=B{j}-B{j-1};  
  37.     r=20;  
  38. end  
  39. B0=mean(mean(B{1}))*ones(size(L));  
  40. D{1}=B{1}-B0;  
  41. for j = nLevel:-1:1  
  42.     D_compression{j}=(2/pi)*atan(20*D{j});  
  43.     D_compression{j}=mat2gray(D_compression{j});  
  44. end  
  45. L_out=D_compression{1}*0.5+D_compression{2}+D_compression{3};  
  46.   
  47. % Rmax_clip = prctile(L_out(:),99);  
  48. % Rmin_clip = prctile(L_out(:),1);  
  49. % DR_clip = Rmax_clip/Rmin_clip;  
  50. % exponent = log(100)/log(DR_clip);  
  51. % L_out = max(0,L_out/Rmax_clip) .^ exponent;  
  52.   
  53. Rmax_clip = prctile(L_out(:),99.5);  
  54. Rmin_clip = prctile(L_out(:),0.5);  
  55. L_out(L_out>Rmax_clip)=Rmax_clip;  
  56. L_out(L_out<Rmin_clip)=Rmin_clip;  
  57. L_out=mat2gray(L_out);  
  58. %L_out=L_out/max(max(L_out));  
  59.   
  60. out(:,:,1)=((HDR(:,:,1)./L_in).^0.6).*L_out;  
  61. out(:,:,2)=((HDR(:,:,2)./L_in).^0.6).*L_out;  
  62. out(:,:,3)=((HDR(:,:,3)./L_in).^0.6).*L_out;  
  63.   
  64. figure;imshow(out,[]);  
  65. % imwrite(out,'result\AhwahneeGreatLounge_small.png');  
最后实现的LDR图像有一些还是有光晕的,不知是程序的问题,还是论文本身的问题。








评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值