Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
% Authors : Abhiram Gnanasambandam (agnanasa@purdue.edu),
%Stanley H. Chan (stanchan@purdue.edu)
%Intelligent Imaging Lab, Dept. of ECE, Purdue University
% Reference:
%[1]HDR Imaging with Quanta Image Sensors: Theoretical Limits and Optimal
%Reconstruction, Abhiram Gnanasambandam and Stanley H. Chan,
%IEEE Transactions on Computational Imaging, 2020
%[2]High Dynamic Range Imaging using Quanta Image Sensors, Abhiram
%Gnansambandam, Jiaju Ma, Stanley H. Chan, IISW 2019.
%%
clear all;
close all;
addpath('Simulation/Matlab')
%%
%Parameters
T = 10;
sigmaRN = 0.25;
Nbits = 3;
denoise = 1; %1 if you want to denoise, 0 if you dont
%%
load('B_snr.mat'); %Saved values for SigmaRN = 0.25, Nbits = 3 Should re-run
% this section after uncommenting the following lines, if
% you want different Nbits and sigmaRN
%This step has to run once for each different setting and the variables has
%to be stored. An efficicent hardware solution will be store these values
%in a look-up table
% p = [0.0228 0.9544 0.0228]; % Only for sigmaRN = 0.25. Has to change for different read noise
% count = 1;
% for i = 0.0001:0.0001:25
%
% m(count) = mean_mu(2^Nbits - 1,i,p);
% count = count + 1;
% end
%
% B = fit(m',[0.0001:0.0001:25]','linearinterp');
%
%
% count = 1;
% for i = 0.0001:0.0001:25
%
% m(count) = SNRH(2^Nbits - 1,i,1000,p);
% count = count + 1;
% end
%
% snr = fit([0.0001:0.0001:25]',m','linearinterp');
%%
%Simulate multiple LDR images
alpha = [1,1/10,1/100]; %Relative integration times
% for i = 1:
A = hdrread('cars1.hdr');
A = mean(A,3); %Convert to grayscale
A = imresize(A,0.25,'nearest');
A(A<0) = 0;
A(A>1e17) = 1e17;
b = A;
b(A==0) = 1e-16;
loga = log(b);
logamin = min(loga(:));
logamax = max(loga(:));
loga = (loga - logamin)./(logamax - logamin);
loga = loga * (log(8000) - log(0.01));
loga = loga + log(0.01);
b = exp(loga);
b(A==0) = min(b(:));
im1 = squeeze(sum(simulate_noisy_images_lite(alpha(1)*b,sigmaRN,T,Nbits),1));
IM1 = LDR_reconstruction(im1,sigmaRN,T,B,denoise);
im2 = squeeze(sum(simulate_noisy_images_lite(alpha(2)*b,sigmaRN,T,Nbits),1));
IM2 = LDR_reconstruction(im2,sigmaRN,T,B,denoise);
im3 = squeeze(sum(simulate_noisy_images_lite(alpha(3)*b,sigmaRN,T,Nbits),1));
IM3 = LDR_reconstruction(im3,sigmaRN,T,B,denoise);
%%
%HDR reconstruction
rec = HDR_rec(IM1,IM2,IM3,alpha,snr);
rec = reshape(rec,size(A));
figure;
subplot(2,2,1);imshow(IM1);
subplot(2,2,2);imshow(IM2);
subplot(2,2,3);imshow(IM3);
subplot(2,2,4);imshow(tonemap(single(rec)));