Make HDR from 3D matrix
2 次查看(过去 30 天)
显示 更早的评论
Hi! I would like to make HDR image from grayscale images. I have my grayscale images data in 3D matrix (two dimentions are spatial and one dimention is exposure time)? I wanted to do this with makehdr function I did not succed.
Thank you!
1 个评论
Vinai Datta Thatiparthi
2020-2-3
Hey Luka,
Can you share the grayscale image matrices that you talk about in your question? This could help us solve the problem faster.
回答(2 个)
Luka Rogelj
2020-2-4
2 个评论
Vinai Datta Thatiparthi
2020-2-13
编辑:Vinai Datta Thatiparthi
2020-2-13
Hello Luka,
The data that you have provided isn't comprehensible. Your matrix has 3 dimensions, but it's unclear what the data represents. For example, from the question, I understand that the 3rd plane of the 3-dimensional matrix that you shared contains the Exposure Times information. This would mean a 300x480 plane containing the Exposure Time values, which may not be correct.
To be able to use makehdr, you must have a collection of 'n' images of the same scene, captured with different amounts of exposure. Additionally, a row-vector of size [1xn] containing Exposure Values/Relative Exposure can be provided, where the number of elements is the same as the number of images that you work with.
Hope this helps!
Vinai Datta Thatiparthi
2020-4-29
Hey Luka,
With the new data that you've provided, this piece of code could help you -
load('hdr_example.mat') % Load Data into MATLAB
cellIm = cell(1,size(images,3)); % Create an empty cell-array to store the images
for idx = 1:size(images,3)
cellIm{idx} = images(:,:,idx); % Every element of the cell array is now a [600 x 903] image
end
% Using the function makehdr
hdr = makehdr(cellIm, 'RelativeExposure', exposure ./ exposure(1));
rgb = tonemap(hdr); % Mapping for viewing HDR image
figure; imshow(rgb) % Show the output image
Hope this helps!
3 个评论
Vinai Datta Thatiparthi
2020-4-29
Hey Luka,
The function makehdr was recently improved & updated to accept a cell array of matrices as inputs directly. Previously, customers were required to use imread to load data from files stored on the PC locally, and then use makehdr. You can notice this behaviour in makehdr Documentation.
The block of code that I shared with you previously utilizes this new feature of the makehdr function. I believe that you're using an older version of MATLAB, and that is why you're running into this error.
Possible workarounds:
- Please update to the latest revision of MATLAB to be able to utilize this new feature
- Else, you may have to use the function imwrite to recursively save the image data onto your PC. After you've saved these files, you can follow the example available on makehdr Documentation to get your desired outputs.
load('hdr_example.mat') % Load Data into MATLAB
for idx = 1:size(images,3)
% Filename changes for every iteration
filename = strcat('image_', num2str(idx), '.jpg');
% Save images locally
imwrite(images(:,:,idx), filename)
end
% String of filenames
files = ["image_1.jpg", "image_2.jpg", "image_3.jpg", ...
"image_4.jpg", "image_5.jpg", "image_6.jpg"];
% Using the function makehdr
hdr = makehdr(files, 'RelativeExposure', exposure ./ exposure(1));
rgb = tonemap(hdr); % Mapping for viewing HDR image
figure; imshow(rgb) % Show the output image
Hope this helps!
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!