matlab 双边滤波器 hdr显示源码,快速双边滤波显示HDR图像

31448629a0afbe97da7a45da04a3a205.png

function BilateralTMO(img, target_contrast, gammaCorrection, scaleV)

% input: hdr img

% input: target_contrast = 5; %default

% scaleV: 1 for hdr, 255 for uint8, 65535 for uint16

% gammaCorrection: open or close gamma Correction

maxgray = scaleV;

% 1 compute luminance channel

I_img = double(img(:,:,1).*20 + img(:,:,2).*40 + img(:,:,3).*1)./61;

% yuv = rgb2ycbcr(outmat./maxgray);

% yuv = rgb2ycbcr(img);

% I_img = yuv(:,:,1);

eps = 1e-6;

[r,c,col] = size(img);

log_I_img= log10(I_img+ eps);

% sigma_s = max([r, c]) * 0.02;

sigma_s = max([r, c]) * 0.02;

sigma_r = 0.4; %default 0.4

imgFil = blateralFilter_Grid(log_I_img, maxgray, sigma_s, sigma_r);

log_base = imgFil;

log_detail = log_I_img - log_base;

figure; imshow(log_base); title('base');

figure; imshow(log_detail); title('detail');

max_log_base = max(log_base(:));

min_log_base = min(log_base(:));

delta = max_log_base - min_log_base;

c_factor = log10(target_contrast) / (delta);

log_absolute = c_factor * max_log_base;

log_Iout = log_base * c_factor + log_detail - log_absolute;

Iout = 10.^(log_Iout) - eps;

Iout(Iout < 0.0) = 0.0;

%change luminance

imgOut = zeros(r,c,col);

N = Iout./I_img;

for i=1:col

imgOut(:,:,i) = img(:,:,i) .* N;

end

figure;imshow(imgOut);

title('TMO img');

imgOut1 = imgOut(:,:,1);

% gamma-correction

if gammaCorrection == 1

scale_factor = 1.0 / (10^(c_factor * max(imgFil(:))));

linearRGB = imgOut.* scale_factor;

gammaRGB = linearRGB.^(1/2.2);

figure;imshow((gammaRGB));

title('TMO img with gamma correction');

end

end

9c5e20a5ee4117631cf4a6f1975a337f.png

原始图像

f7fdb405ce1e2d564ffda1be31e2befe.png

处理后图像

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值