% shadowscan.m % This script reads the images and acquires the min,max,contrast, and % shadow images. % Load matlab.mat for calibration information then run this startimg = 1386; endimg = 1534; inited = 0; Imin=0; Imax=0; Ishadow=0; Icontrast=0; for c = startimg:endimg str = sprintf('output_%05d.jpg',c); fdin = fopen(str); if fdin ~= -1 fclose(fdin); imgin = double(rgb2gray(imread(str))); imginfo = imfinfo(str); sizex = imginfo.Width; sizey = imginfo.Height; if inited == 0 inited = 1; Imin = double(zeros(sizey,sizex)); Imax = double(zeros(sizey,sizex)); Ishadow = double(zeros(sizey,sizex)); Icontrast = double(zeros(sizey,sizex)); for i = 1:sizey for j = 1:sizex Imin(i,j) = double(255); end end end for i = 1:sizey for j = 1:sizex if imgin(i,j) > Imax(i,j) Imax(i,j) = imgin(i,j); Icontrast(i,j) = Imax(i,j) - Imin(i,j); Ishadow(i,j) = (Imax(i,j)+Imin(i,j))/2; end if imgin(i,j) < Imin(i,j) Imin(i,j) = imgin(i,j); Icontrast(i,j) = Imax(i,j) - Imin(i,j); Ishadow(i,j) = (Imax(i,j)+Imin(i,j))/2; end end end end end