Make HDR image from Raw images
5 views (last 30 days)
Show older comments
Hello,
I'm using MatLab to blend some images and create and HDR radiance map. I'm using the new functions from MatLab 2019 to get the response function and create the HDR image.
Everythings works well with JPG (both grayscale and color), but I can't manage to make it work with Raw images. I have these file formats: CR2, DNG, Tiff. I'd like to make it work with at least one of them, so I can make an HDR radiance map with more than 8 bit depth.
Any help?
Thank you
EDIT:
First, I use the Tiff class to read the 16bit image:
t = Tiff(path,'r');
im = read(t);
Here I already have a weird problem because "im" is a 4D matrix. I don't know why but I have the 3 channels and then a matrix that's completely blank (every cell value is 2^16-1).
Anyway, I delete the last matrix so I have a 3D matrix. I use this matrix to compute the camera response function but I get weird results. This is the response function:
Since it's an uncompressed tiff, I think the response function should be linear. Also this response is just plain wrong anyway.
Here the code I'm using:
%% Collection of photos
setDir = fullfile('images','tt_*');
imds = imageDatastore(setDir);
figure(1);
montage(imds);
%% Response Function
crf = camresponse(imds,'ExposureTimes',[1/60,1/250,1/1000]);
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;
2 Comments
Ted Shultz
on 25 Sep 2019
Can you explain what you can't make work? You can't open the files? You get unexpected results?
Answers (1)
Vahila Kayithi
on 27 Dec 2019
Edited: Vahila Kayithi
on 27 Dec 2019
IamgeDataAStore object can be created directly from the .tif files by specifying the 'FileExtension' to '.tif'. Can you try running your code by creating the IamgeDataAStore object from .tif files instead of using Tiff class to read them?
Refer to this link to create IamgeDataAStore object from .tif files:
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!