區域性邊緣保持濾波(LEP)高動態範圍影象HDR壓縮 matlab程式(二)
阿新 • • 發佈:2018-12-31
上一篇部落格給出了論文"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.
下面為高動態範圍壓縮程式:
- clear all;
- HDR = hdrread('..\HDR Images\AhwahneeGreatLounge_small.hdr');
-
% HDR = hdrread('..\HDR Images\AtriumMorning.hdr'
- % HDR = hdrread('..\HDR Images\belgium.hdr');
- % HDR = hdrread('..\HDR Images\cadik-desk02_mid.hdr');
- % HDR = hdrread('..\HDR Images\designCenter.hdr');
- % HDR = hdrread('..\HDR Images\desk.hdr');
- % HDR = hdrread('..\HDR Images\doll.hdr');
- % HDR = hdrread('..\HDR Images\groveD.hdr');
-
% HDR = hdrread('..\HDR Images\HancockKitchenInside_small.hdr'
- % HDR = hdrread('..\HDR Images\memorial.hdr');
- % HDR = hdrread('..\HDR Images\orion_correct_small.hdr');
- % HDR = hdrread('..\HDR Images\paul_bunyan_small.hdr');
- % HDR = hdrread('..\HDR Images\pillarsB_small.hdr');
- % HDR = hdrread('..\HDR Images\snowman.hdr');
-
% HDR = hdrread('..\HDR Images\tinterna_small.hdr'
- % HDR = hdrread('..\HDR Images\vinesunset.hdr');
- % HDR = hdrread('..\HDR Images\yosemite_small.hdr');
- L_in=(1/3)*(HDR(:,:,1)+HDR(:,:,2)+HDR(:,:,3));
- L=log(L_in*1e6+1);
- L=L/max(max(L));
- % L=mat2gray(L);
- alpha=0.1;
- beta=1;
- r=2;
- nLevel = 3;
- B = cell(1, nLevel);
- D = cell(1, nLevel);
- D_compression=cell(1, nLevel);
- B{nLevel}=L;
- for j = nLevel:-1:2
- B{j-1}=LocalWls_HDR(B{j}, alpha, beta, r);
- D{j}=B{j}-B{j-1};
- r=20;
- end
- B0=mean(mean(B{1}))*ones(size(L));
- D{1}=B{1}-B0;
- for j = nLevel:-1:1
- D_compression{j}=(2/pi)*atan(20*D{j});
- D_compression{j}=mat2gray(D_compression{j});
- end
- L_out=D_compression{1}*0.5+D_compression{2}+D_compression{3};
- % Rmax_clip = prctile(L_out(:),99);
- % Rmin_clip = prctile(L_out(:),1);
- % DR_clip = Rmax_clip/Rmin_clip;
- % exponent = log(100)/log(DR_clip);
- % L_out = max(0,L_out/Rmax_clip) .^ exponent;
- Rmax_clip = prctile(L_out(:),99.5);
- Rmin_clip = prctile(L_out(:),0.5);
- L_out(L_out>Rmax_clip)=Rmax_clip;
- L_out(L_out<Rmin_clip)=Rmin_clip;
- L_out=mat2gray(L_out);
- %L_out=L_out/max(max(L_out));
- out(:,:,1)=((HDR(:,:,1)./L_in).^0.6).*L_out;
- out(:,:,2)=((HDR(:,:,2)./L_in).^0.6).*L_out;
- out(:,:,3)=((HDR(:,:,3)./L_in).^0.6).*L_out;
- figure;imshow(out,[]);
- % imwrite(out,'result\AhwahneeGreatLounge_small.png');