procedure tflip (imglist,abbName,extn,flipdir,clobber,outextn) string imglist {prompt="Image list (full or abbreviated names)"} bool abbName {no, prompt=" Are image names abbreviated?"} string extn {prompt=" Extension appended to abbreviated image names"} int flipdir {3, prompt="1=x-flip; 2=y-flip; 3=both x and y-flip"} bool clobber {no, prompt="Overwrite old image with flipped version?"} string outextn {"flp", prompt="Extension to flipped image names if no clobber"} struct *flist # list directed structure begin # Variable declarations: string currImage # current input image string flipstring # coord string that determines flip direction string outImage # output image name delete (files="temp_tflip*",go_ahea+,ver-) # Cases of flipping: if (flipdir==1) { flipstring="[-*,*]" # i.e. x-flip only } if (flipdir==2) { flipstring="[*,-*]" # i.e. y-flip only } if (flipdir==3) { flipstring="[-*,-*]" # i.e. x and y-flip } if (flipdir<1) { print (" ") print (" *** Invalid flip number (too low) ") bye # i.e. no flip } if (flipdir>3) { print (" ") print (" *** Invalid flip number (too high) ") bye # i.e. no flip } # Creation of imcopy flip file and output file: flist = imglist while ( fscan(flist, currImage) != EOF) { if (abbName==yes) { print (currImage//extn//flipstring, >> "temp_tflip.in") } if (abbName==no) { print (currImage//flipstring, >> "temp_tflip.in") } print (currImage//"tempcopy", >> "temp_tflip.names") if (clobber==no) { outImage = currImage//outextn } if (clobber==yes) { outImage = currImage//extn } print (outImage, >> "temp_tflip.out") } # Flipping: imcopy (input="@temp_tflip.in",output="@temp_tflip.names",verbose+) imdelete (images="@temp_tflip.out",verify-,default+,go_ahead+) imrename (oldnames="@temp_tflip.names",newnames="@temp_tflip.out", verbose+) # ** Note that old images are not deleted until AFTER the imcopy has # been made. This is extra work but is safer if imcopy fails for # some reason. # Cleaning-up: delete (files="temp_tflip*",go_ahea+,ver-) print (" ") print ("Done.") end