Permalink
Cannot retrieve contributors at this time
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?
QIS_HDR_TCI20/demo.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
108 lines (81 sloc)
2.82 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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. | |
%% | |
clc; | |
clear; | |
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 | |
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)); % RAW Ldr image 1 | |
IM1 = LDR_reconstruction(im1,sigmaRN,T,B,denoise); | |
im2 = squeeze(sum(simulate_noisy_images_lite(alpha(2)*b,sigmaRN,T,Nbits),1)); % RAW Ldr image 2 | |
IM2 = LDR_reconstruction(im2,sigmaRN,T,B,denoise); | |
im3 = squeeze(sum(simulate_noisy_images_lite(alpha(3)*b,sigmaRN,T,Nbits),1)); % RAW Ldr image 3 | |
IM3 = LDR_reconstruction(im3,sigmaRN,T,B,denoise); | |
%% | |
%HDR reconstruction | |
rec = HDR_rec(IM1,IM2,IM3,alpha,snr); | |
rec = reshape(rec,size(A)); | |
%% | |
%Display results | |
figure; | |
subplot(2,2,1);imshow(im1/T/(2^Nbits-1)); title('Long exposure'); | |
subplot(2,2,2);imshow(im2/T/(2^Nbits-1)); title('Medium exposure'); | |
subplot(2,2,3);imshow(im3/T/(2^Nbits-1)); title('Short Exposure'); | |
subplot(2,2,4);imshow(localtonemap(single(rec))); title('HDR Reconstruction'); | |