global img intmat intmat1 choice flag

init

pps=avsread2('/nfs/ir6/w/fyz/2dd/huber/hc/prompt1e6.50.fld');
img2=avsread('huber/phtm.fld')';
myout1=zeros(128,128,50);
load data3/c1

for ii=1:50,
	ii
	!rm -f pp.fld
	avswrite('pp.fld',pps(:,:,ii));
	fuserf=1; flag1=0; flag2=0; flag3=1; flag4=0; choice=10;
	[jk,jk,lset1]=exspeedfancy(c1(1:l1(ii,9),:,ii,9),ones(128),ones(128));
	[jk,jk,lset2]=exspeedfancy(c2(1:l2(ii,9),:,ii,9),ones(128),ones(128));
	[jk,jk,lset3]=exspeedfancy(c3(1:l3(ii,9),:,ii,9),ones(128),ones(128));
	[jk,jk,lset4]=exspeedfancy(c4(1:l4(ii,9),:,ii,9),ones(128),ones(128));
	dmap=min(min(lset1,lset2),min(lset3,lset4));
	xmap=zeros(N,N); ymap=zeros(N,N); penal=zeros(N,N,4);
	xmap(2:N,:)=min(dmap(1:N-1,:),dmap(2:N,:));
	ymap(:,2:N)=min(dmap(:,1:N-1),dmap(:,2:N));
	penal(:,:,1)=ymap'; penal(:,:,2)=xmap';
	penal(:,:,1:2)=h(penal(:,:,1:2));
	!rm -f pen.fld
	avswrite('pen.fld',penal);
	!rm -f out.fld
	!reconstruct 11 20
        choice=11; img=avsread('out.fld')'*1e5; go2;
        !rm -f out.fld
        !reconstruct 11 20
        choice=12; img=avsread('out.fld')'*1e5; fuserf=0; go2;
        !rm -f out.fld
        !reconstruct 11 20
        choice=13; img=avsread('out.fld')'*1e5; go2;
	if mod(ii,5)==0 | ii==1,
		save c1 c1 c2 c3 c4 l1 l2 l3 l4
	end
end
