HDR blending not working with 16 bit images

2 vues (au cours des 30 derniers jours)
gbos
gbos le 22 Oct 2019
Commenté : gbos le 12 Nov 2019
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 commentaires
gbos
gbos le 31 Oct 2019
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 le 31 Oct 2019
Modifié(e) : gbos le 31 Oct 2019
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.

Connectez-vous pour commenter.

Réponses (1)

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi le 11 Nov 2019
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 commentaire
gbos
gbos le 12 Nov 2019
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

Connectez-vous pour commenter.

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by