%
% Continues calculation of PRNU from data
% ------------------------------
% This program takes the average image collected for PRNU and produces a 
% value of the PRNU by subtracting the DSNU image from the average data
% collected. The variance of the result is then caculated to obtain the PRNU.


clear all;clc;

load ave4;              % loads average image, file name varies 
prnu = average;

load aveDSNU_4;         % DSNU image for the particular exposure
prnu = prnu - average;  

alpha = reshape(prnu(476:525, 576:625, :), 50*50, 4);

variance = var(reshape(prnu(476:525, 576:625, :), 50*50, 4));
variance = variance./mean(alpha)*100
save variance4 variance;
