function img = projgraf(shift,grow_hrt,grow_lng,res)
%
%  img = projgraf(shift,grow_hrt,grow_lng,res)
%
%  Projgraf will display a synthetic 2-D slice model
%  of a human chest using some of the input arguments
%  needed by PROJECT.  SHIFT allows a horizontal translation
%  while GROW_HRT allows a dilation of the "heart", and
%  GROW_LNG allows a dialation of the "lungs" and "chest wall".
%  The model is contained within a square box with vertices at (0,0)
%  and (1,1).  SHIFT is limited to +/-0.04, GROW_HRT
%  is limited from 0 to 0.04, and GROW_LNG is limited from
%  0 to 0.08.  RES is the rectangular sampling
%  grid.  A suggestion for RES is 0.004.
%
%  SEE project.m, modgraph.m
%
%  Developed by Timothy D. Dorney
%               Rice University
%               February, 1999
%               tdorney@ieee.org
%
%  Coded using MATLAB 5.X.X with NO additional toolboxes.
%
%	REVISION HISTORY
%
%	VERSION 1.0.0		FEB. 15, 1999	TIM DORNEY
%	VERSION 1.0.1		APR. 1, 1999	TIM DORNEY
%		Modified the sampling grid to match the
%		one defined in the back-projection algorithm.
%
%  NOTE:  PROJGRAF.M WILL GIVE EXACT ANSWERS!!!!
%         MODGRAPH.M IS FAST, BUT FOR BEST RESULTS USE PROJGRAF.M
%

if (nargin ~= 4)
        disp('PROJGRAF requires 4 input arguments!')
	return;
end
 
if ((shift < -0.04) | (shift > 0.04))
	shift = 0;
	disp('SHIFT limited to +/- 0.04.  The limit was exceeded.  SHIFT set to 0!');
end
if ((grow_hrt < 0) | (grow_hrt > 0.04))
	grow_hrt = 0;
	disp('GROW_HRT limited from 0 to 0.04.  The limit was exceeded.  GROW_HRT set to 0!');
end
if ((grow_lng < 0) | (grow_lng > 0.08))
	grow_lng = 0;
	disp('GROW_LNG limited from 0 to 0.08.  The limit was exceeded.  GROW_LNG set to 0!');
end


mapt = zeros(length([res/2:res:1]),length([res/2:res:1]));
ix = 0;
for x = res/2:res:1
   ix = ix  + 1;
   iy = 0;	
   for y = res/2:res:1
      iy = iy + 1;
      mapt((length([res/2:res:1])-iy+1),ix)=project(x,y,x,y,shift,grow_hrt,grow_lng);
   end
end

colormap(gray(255));
clf
disp('THE IMAGE SIZE IS:')
size(mapt)
imagesc(mapt);
axis('image');

img = mapt;
