HDR blending not working with 16 bit images

조회 수: 9 (최근 30일)
gbos
gbos 2019년 10월 22일
댓글: gbos 2019년 11월 12일
I'm using the camresponse function and the makehdr function to blend few images and create a radiance map. I have no problem using 8 bits images, everything works fine. But if I use the same images but encoded with 16 bits, I get really bad results, as you can see in the following images. Using that crf with mkhdr results in a really bad quality hdr image.
The images are converted to 8 bit and 16 bit png from the original RAW file.
Any help? Is this function supposed to work with images with more than 8 bits? I guess so looking at camresponse.m but still I have these problems.
untitled.bmp
22.bmp
  댓글 수: 3
gbos
gbos 2019년 10월 31일
clc; clear all;
%% Parameters
defaultT = [0.625,1/5,1/3,1.3,3];
%% Collection of photos
setDir = fullfile('img','*.png');
imds = imageDatastore(setDir);
figure(1);
montage(imds);
%Check if there is the exposure info
meta = imfinfo(imds.Files{1});
try
temp = meta.DigitalCamera;
exif = true;
catch
exif = false;
end
%% Response Function
if(not(exif))
crf = camresponse(imds,'ExposureTimes',defaultT);
else
crf = camresponse(imds);
end
range = 0:length(crf)-1;
%Response function plots for every channel
figure(2); hold on;
if(size(crf,2) == 3)
%RGB Image
plot(crf(:,1),range,'--r','LineWidth',2);
plot(crf(:,2),range,'-.g','LineWidth',2);
plot(crf(:,3),range,':b','LineWidth',2);
legend('R-component','G-component','B-component','Location','southeast');
else
%Grayscale Image
plot(crf(:,1),range,'-k','LineWidth',2);
end
xlabel('Log-Exposure');
ylabel('Pixel Value');
title('Camera Response Function');
grid on;
axis('tight');
hold off;
gbos
gbos 2019년 10월 31일
편집: gbos 2019년 10월 31일
images can be downloaded here. They're different from the ones used to recover the crf I showed you on the first post, but you'll see the same problem shows up.
You can later try to convert the images in 8 bit PNGs and you'll see that the algorithm will work properly.

댓글을 달려면 로그인하십시오.

답변 (1개)

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi 2019년 11월 11일
Hey!
I believe that this is expected behavior of the commands makehdr and camresponse. 8 bit images generally produce smoother camresponse curves since the intensity range is narrower as compared to 16 bit images.
As a workaround to obtaining a more accurate looking curve, considering using a higher sampling interval to narrow down the “crf” result.
% Increasing sampling interval
crfNew = crf(1:200:65536,:);
range = 0:length(crfNew)-1;
% Response function plots for every channel
figure(2); hold on;
if(size(crf,2) == 3)
% RGB Image
plot(crfNew(:,1),range,'r','LineWidth',2);
plot(crfNew(:,2),range,'g','LineWidth',2);
plot(crfNew(:,3),range,'b','LineWidth',2);
legend('R-component','G-component','B-component','Location','southeast');
else
% Grayscale Image
plot(crf(:,1),range,'-k','LineWidth',2);
end
Hope this helps!
  댓글 수: 1
gbos
gbos 2019년 11월 12일
Sadly it doesnt work. Weird things happen when I use 16 bit images. This is another example, with an RGB image. I tried using an higher sampling as you suggested.
8 bit PNG
untitled2.jpg
16 bit PNG
untitled.jpg

댓글을 달려면 로그인하십시오.

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by