macro vanCittert;
{  On the first iteration of this macro there should not be any windows }
{  called ÒNext ImageÓ or ÒPrevious ImageÓ }
{  You should start with an image called ÒStart ImageÓ }
var
	boolean : hasNext,hasPrevious,ok;
	longint : dx,dy;
begin
	DisposeUnClose;
	ok:=Exist('Start Image');
	if(!ok)
		ShowError(' ','You must start with an image called ÒStart ImageÓ.');
	endif;
	hasNext:=Exist('Next Image');
	hasPrevious:=Exist('Previous Image');
	ok:=TRUE;
	if(!hasNext)
		ok:=DuplicateData('Start Image',FALSE,'Next Image');
	endif;
	if(!ok) 
		exit;
	endif;	
	if(hasNext)
		ok:=DuplicateData('Next Image',FALSE,'Previous Image');
	endif;
	if(!ok) 
		exit;
	endif;	
	SimpleFilter('Next Image','PSF');
	SimpleMath('Start Image',-,'None','Next Image','Next Image');
	if(hasPrevious)	
		SimpleMath('Next Image',+,'None','Previous Image','Next Image');
	endif;
	KillROI('Next Image');
	SelectData('Next Image');
	SelectData('Start Image');
end;
