function []= stim(frm1,frm2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%
%% Copyright (C) 2005-2007 Anurag Singh %%
%% %%
%% This program/code snippet/file (hence forth refered as "library") %%
%% is free software; you can redistribute it and/or %%
%% modify it under the terms of the GNU Lesser General Public %%
%% License as published by the Free Software Foundation; either %%
%% version 2.1 of the License, or (at your option) any later version. %%
%% %%
%% This library is distributed in the hope that it will be useful, %%
%% but WITHOUT ANY WARRANTY; without even the implied warranty of %%
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %%
%% Lesser General Public License for more details. %%
%% %%
%% You should have received a copy of the GNU Lesser General Public %%
%% License along with this library; if not, write to the Free Software %%
%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA %%
%% %%
%% FILENAME: %%
%% stim.m %%
%% %%
%% AUTHOR: %%
%% %%
%% Anurag Singh, %%
%% MS, 2007 %%
%% Aerospace Engineering & Mechanics %%
%% University of Minnesota - Twin Cities. %%
%% Minneapolis, MN 55455 (USA) %%
%% %%
%% (currently working at: Exa Corporation, Burlington, MA 01803) %%
%% %%
%% CONTACT/EMAIL: %%
%% %%
%% anurag@aem.umn.edu %%
%% anurag9@gmail.com %%
%% %%
%% SOURCE CONTROL INFORMATION: %%
%% None (since I was planning on putting it under source control since it has %%
%% reached the critical file system size. Would be a good thing to put it under %%
%% source control while making changes. %%
%% %%
%% DESCRIPTION: %%
%% %%
%% Need to add %%
%% %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% USAGE:
%
% stim(frame1,frame2)
%
% Input Arguments:
% frame1 First frame index which marks the biginning of the range of frames
% frame2 Last frame index upto which images are considered for stitching
%
% Output: Stitched image along with corresponding x y dimension array
%
% EXAMPLE:
% stim(1,200)
%
% REMARKS
% This function stitches images such that it takes the first image and then takes a portion of the
% subsequent images and joins them back to back to create one continuous long image.
global u_norm u v x y piv_ustd skip_files piv_ubar vecimfreq fov uim vim xim yim delta_99 u_tau nu
global piv_ustdplus u_normplus v_plus piv_zplus
if(nargin ~= 2)
disp (' ERROR: Insufficient arguments.');
help stim;
else
if (skip_files > 0)
disp('Warning: Files were skipped while reading them initially.');
disp(' The stitched image may not be a correct physical representation.');
end
dpix = round(size(u_norm,2)*piv_ubar/vecimfreq/(fov/1000))
p1 = 1;
p2 = p1 + dpix - 1;
xim = x;
yim = y;
% uim = squeeze(u_norm(frm1,:,:));
% vim = squeeze(v(frm1,:,:));
uim = squeeze(u_normplus(frm1,:,:));
vim = squeeze(v_plus(frm1,:,:));
for frame = frm1+1:frm2
% uim = [squeeze(u_norm(frame,p1:p2,:)); uim];
% vim = [squeeze(v(frame,p1:p2,:)); vim];
uim = [squeeze(u_normplus(frame,p1:p2,:)); uim];
vim = [squeeze(v_plus(frame,p1:p2,:)); vim];
xim = [xim; xim(size(xim,1),1) + x(p1:p2,:) ];
yim = [yim; yim(p1:p2,:)];
end
% Display the images
figure;
colormap(hsvmap(30,3,[1 0 0],[0 0 1]));
pcolor(-xim/delta_99, yim/delta_99, uim)
% caxis([-2.5*piv_ustd 2.5*piv_ustd])
caxis([-2.5*piv_ustdplus 2.5*piv_ustdplus])
cb = colorbar('horz'); % display the colorbar
set(get(cb,'XLabel'),'String',['Normalized, streamwise fluctuating velocity, u^{+}']);
shading interp;
lighting phong;
daspect([1 1 1]);
hold on
%quiver(xim, yim, uim, vim, 1,'k')
hold off
% xlabel('Streamwise distance normalized by \delta_{99} ->');
% ylabel('Spanwise distance, normalized by \delta_{99} ->');
xlabel('x (in terms of \delta) ->');
ylabel('y (in terms of \delta) ->');
title(['Stitched Image (Frame range = ',num2str(frm1),'-',num2str(frm2),'; stitch strip width ',num2str(p2-p1+1),sprintf('\n'),'Total images used = ',num2str(frm2-frm1+1),' Flow is from left to right), z^{+} = ', num2str(round(piv_zplus))]);
drawnow;
end