tone mapping matlab,Matlab Code For Local Tone mapping

该博客探讨了HDR图像处理中的局部色调映射和权重HDR技术。通过代码展示了如何进行局部色调映射,以及两种方法在处理图像细节上的差异。权重HDR在暗部和亮部显示更多细节,而响应函数HDR则存在颜色偏移。此外,还讨论了全景图像的处理和转换方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Original Image

Original1

Original2

Original3

Original4

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

Local Tone mapping Process

Intensity Image

Base Image

Detail Image

Final Tone mapping + gamma correction

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

Result Comparison

Naive HDR

Weighted HDR

Tone mapping + Gamma Correction

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

As you can see Weighted HDR shows more details on the dark and white part and the Tone mapping results shows even more detail on the white and dark part

Matlab Code For Local Tone mapping

function img = LocalToneMapping(hdr)

img = double(hdr);

% Calculate the Intensity Image

% Based on https://en.wikipedia.org/wiki/Relative_luminance

I = 0.2126 * img(:,:,1) + 0.7152 * img(:,:,2) + 0.0722 * img(:,:,3);

% Get log domain Intensity

L = log2(I);

% Get base image

B = bilateralFilter(L);

% Get Detail image

D = L - B;

% Contrast reduction only on the base

maxb = max(B(:));

minb = min(B(:));

% Scale base image

s = 3/(maxb-minb);

ajtB = (B-maxb).*s;

O = 2.^(ajtB+D);

% Reconstruct Color Chanel

img(:,:,1) = O.*(img(:,:,1)./I);

img(:,:,2) = O.*(img(:,:,2)./I);

img(:,:,3) = O.*(img(:,:,3)./I);

% linearly scale to 0~1

img = linearScalImage(img);

% Apply gamma correction

img = img.^0.6;

[h,s,v] = rgb2hsv(img);

h = h.^1.2;

s = s.^1.1;

v = v.^0.7;

[rr, gg, bb] = hsv2rgb(h,s,v);

img(:,:,1) = rr;

img(:,:,2) = gg;

img(:,:,3) = bb;

end

Original Images

Original1

Original2

Original3

Original4

Original5

Original6

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

Recovered Log radiance image

recovered1

recovered2

recovered3

recovered4

recovered5

recovered6

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

The recovered log irradiance image of different shutter speed image looks the same. Because we are using the same camera and the only difference is the shutter speed(irradiance is the same), I*/exposure will put them all in the same exposure thus they look the same.

Estimated function G

Red

Green

Blue

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

HDR result

Naive avg

Weighted avg

Response Function

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

As you can see, the weighted HDR result shows more detail on the dark and white part while the the response function HDR has a color shift(compare to the naive HDR and weighted HDR) because we estimate the response function of the camera and re-mapping pixle values

Panoramic transformations

Normal

Reflection

Phi-The

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

Response Function HDR

Panoramic Image

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

For the Panoramic transformations, we first compute the normal image of the sphere and them compute the reflection image and finally compute the Theta Phi image and map the Theta Phi from the sphere coordinate to a rectengular Theta Phi coordinates.

Blend result

Objects

Without objects

Mask

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

Empty

With Objects

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值