function image_compare(fig1,fig2)
%
% Call image_compare(fig1,fig2);
%
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
if nargin<1,
	figs=str2num(input('Enter figure numbers ','s'));
	if isempty(figs), figs=[gcf-1,gcf]; end
    if length(figs(:))~=2, error('Must enter two figure numbers to compare.'); end
    fig1=figs(1); fig2=figs(2);
end
%
xax=[];
figure(fig1);
child1=get(fig1,'Children');
for jch=1:length(child1),
    if strcmp(get(child1(jch),'Type'),'axes'),
        child2=get(child1(jch),'Children');
        for jch2=1:length(child2);
            if strcmp(get(child2(jch2),'Type'),'image'),
                xax=get(child2(jch2),'Xdata'); yax=get(child2(jch2),'Ydata'); 
                data1=get(child2(jch2),'Cdata');
                break
            end
        end
    end
end
if isempty(xax), disp('Did not find image in current figure.'); return; end

xax=[];
figure(fig2);
child1=get(fig2,'Children');
for jch=1:length(child1),
    if strcmp(get(child1(jch),'Type'),'axes'),
        child2=get(child1(jch),'Children');
        for jch2=1:length(child2);
            if strcmp(get(child2(jch2),'Type'),'image'),
                xax=get(child2(jch2),'Xdata'); yax=get(child2(jch2),'Ydata'); 
                data2=get(child2(jch2),'Cdata');
                break
            end
        end
    end
end
if isempty(xax), disp('Did not find image in current figure.'); return; end

if ~all(size(data1)==size(data2)), disp('Images not the same size!!'); return; end

avg=(data1(:) + data2(:))/2;
dif=data1(:) - data2(:);
figure;
plot_cfill(avg,dif,'o','r',4);
xlabel('Image Value'); ylabel('Difference Between Images');
plot_set3(gca,1.5,'Arial',14,1);
zoom on;
