In Chapter 5 of the book we list a short Matlab® program to integrate successive video frames from our diy intensified camera to image double-slit interference patterns obtained by shooting a single photon at a time.
The program listed in the book uses Vision for Matlab (VFM). However, this utility is not compatible with all versions of Windows and Matlab. An alternative is VCAPG2 by Kazuyuki Kobayashi available at http://www.ikko.k.hosei.ac.jp/~matlab/matkatuyo/vcapg2.htm (Also available from our SOFTWARE page).
The following is a version of the Matlab integration program shown in the book’s Listing 1 that has been modified to work with VCAPG2:
% ————
%
% Matlab program to integrate video image frames
% from single-photon interference setup.
%
% ©2011 David Prutchi, Ph.D. and Shanni R. Prutchi
%
% This program uses VCAPG2 to acquire
% image frames through a Windows video capture card.
%
%————–
noise(288,384)=0; % initialize array that will hold static dark image
a=vcapg2(‘grab’,1); % acquire 5 frames
dark=double(a); % convert from image format to double-precision numbers
% Integrate 5 frames
for n=1:1
noise=noise+dark(:,:,1,n)+dark(:,:,2,n)+dark(:,:,3,n);
end
noise=noise/1; % Calculate average dark static image
clf % Clear figure
imagesc(noise) % Display average dark static image
colorbar
title(‘Dark Static Image’)
drawnow % Draw figure now
clear a % Clear the image buffer
clear dark % Clear the double-precision image buffer
% Ask user to turn LASER on
beep
disp(‘PLEASE TURN LASER ON’)
pause(2)
beep
pause(2)
beep
pause(2)
beep
pause(2)
c(288,384)=0; % initialize array that will hold interference pattern
for n=1:200 % number of frames to be integrated
a=vcapg2(‘grab’,1); % grab a frame
b=double(a); % convert to double precision
n % display frame number
c=c+b(:,:,1)+b(:,:,2)+b(:,:,3)-noise(:,:); % integrate frame and subtract dark static image
figure(1) % select figure #1
clf % clear the figure
%imagesc(c,[0,max(max(c))]) % apply threshold at 0 and generate color image
imagesc(c,[median(median(c)),max(max(c))])
colorbar % show color scale
drawnow % draw figure now
if n == 1 % if this is the first frame, display it in Figure #2
figure(2)
subplot(2,3,1)
imagesc(c,[0,max(max(c))])
title(‘Frames Integrated = 1’)
drawnow
end
if n == 10 % if this is the 10th frame, display it in Figure #2
figure(2)
subplot(2,3,2)
imagesc(c,[0,max(max(c))])
title(‘Frames Integrated = 10’)
drawnow
end
if n == 25 % if this is the 25th frame, display it in Figure #2
figure(2)
subplot(2,3,3)
imagesc(c,[0,max(max(c))])
title(‘Frames Integrated = 25’)
drawnow
end
if n == 50 % if this is the 50th frame, display it in Figure #2
figure(2)
subplot(2,3,4)
imagesc(c,[0,max(max(c))])
title(‘Frames Integrated = 50’)
drawnow
end
if n == 100 % if this is the 100th frame, display it in Figure #2
figure(2)
subplot(2,3,5)
imagesc(c,[0,max(max(c))])
title(‘Frames Integrated = 100’)
drawnow
end
if n == 200 % if this is the 200th frame, display it in Figure #2
figure(2)
subplot(2,3,6)
imagesc(c,[0,max(max(c))])
title(‘Frames Integrated = 200’)
drawnow
end
end
figure(3) % display final result of integration in Figure #3
imagesc(c,[0,max(max(c))])
title(‘Frames Integrated = 200’)
colorbar