function rgb = tmo_reinhard02Globle(imgf, saturation)
% imgf-in double type,range(0,1)
% rgb-out double type, range(0,1)
lab = rgb2lab(imgf);% L:(0, 100)£¬a:(-128, 127), b(-128, 127)
Y = lab(:,:,1);
% log-average luminance
e=2.7183;
logavg = mean(e.^(log(0.00001 + Y(:))));
% a = 0.18;
minY = min(Y(:))*1.1;
maxY = max(Y(:))*0.9;
a = 0.18*4^((log2(logavg)-log2(minY)-log2(maxY)) / (log2(maxY)- log2(minY)));% reinhard03
L = a/logavg * Y;
Lwihte = max(L(:));
Ld = L .* (1+ L/(Lwihte^2))./ (1+L);
lab(:,:,1) = Ld*100;
% adjust saturation
if saturation ~= 1.0
lab(:,:,2) = lab(:,:,2) * saturation;
lab(:,:,3) = lab(:,:,3) * saturation;
end
rgb = lab2rgb(lab);
end
原始图
ReinHard02Globle, saturation=2