1 简介
针对普通相机拍摄图像中存在区域曝光问题,提出一种改进的基于离散余弦变换的多曝光图像融合算法.分别对同一场景的多幅不同曝光图像分块,并对每个小块进行离散余弦变换.对提取相应位置的低频系数平均加权,获取图像近似部分的融合分量;对高频系数基于区域标准差确定权重系数,根据权重系数的大小获取细节部分的融合分量.最后,通过反离散余弦变换获得较好质量的多曝光融合图像.仿真实验表明,该算法在提取低频系数为25%,高频系数为75%时,展现的图像细节信息更加丰富.
2 部分代码
function[imf] = mrdctf(im1,im2,J)% Multi resolution 1D DCT based image fusion% Developed by : VPS Naidu, MSDF Lab% input: im1 & im2 images to be fused% J no. of decomposition levels% output: imf fused imageimfr = mrdctif(im1,im2,J);imfc = mrdctif(im1',im2',J)';imf = 0.5*(imfr+imfc);function[imf] = mrdctif(im1,im2,J)%Multi resolution image fusion by DCT[m,n] = size(im1);x1 = c2dt1d(im1,m,n);x2 = c2dt1d(im2,m,n);for i=1:J X1{i} = mrdct(x1); X2{i} = mrdct(x2); x1 = X1{i}.L; x2 = X2{i}.L;end% fusion start hereXf.L = 0.5*(X1{J}.L+X2{J}.L);for i=J:-1:1 D = (abs(X1{i}.H) - abs(X2{i}.H)) >=0; Xf.H = D.*X1{i}.H + (~D).*X2{i}.H; Xf.L = imrdct(Xf);endimf = c1d2d(Xf.L,m,n);function[R] = c2dt1d(R,m,n)% conversion from 2D array to 1D vectorR(2:2:end,:)=R(2:2:end,end:-1:1);R = reshape(R',1,m*n);function[R] = c1d2d(R,m,n)% conversion from 1D vector to 2D arrayR = reshape(R,n,m)';R(2:2:end,:)=R(2:2:end,end:-1:1);function[X] = mrdct(x)% multi resolution analysisn=length(x);Y = dct(x,n);X.L = idct(Y(1:n/2));% low frequency X.H = Y(n/2+1:n);% low frequencyfunction[x] = imrdct(X)% inverse multi resolution analysisxl = dct(X.L);x = [xl X.H];x = idct(x);
3 仿真结果
4 参考文献
[1]刘卫华, 马洋花, 刘颖. 基于DCT变换的多曝光图像融合方法[J]. 西安邮电大学学报, 2016, 21(6):4.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。