# task mask = home$scripts/mask.cl #written by rf to mask hawaii images. This is done by multiplying image by # mask with good values=1 => imagem. Then find mode of image. Multiply mask with bad # values=1 by mode (tempfile) and add to imagem. procedure mask (files,mask) string files {prompt="images/image list (@) to mask"} string mask {prompt="name of mask with good value = 0"} #string invmask {prompt="name of mask with good value = 0"} string stat {prompt="statsec for calculating mode"} struct *inl struct *inl2 begin real mmode int i string c1,current string ffiles, mmask, iinvmask string modelist,statsec,tempname,modefile ffiles=files mmask=mask iinvmask="invmask" statsec=stat ########################################################################## if (access("modes")) {delete("modes",v-)} if (access("names")) {delete("names",v-)} # the following is taken from HW Rix align.cl if (access("tmplst")) {delete("tmplst",v-)} if (access("tmplst2")) {delete("tmplst2",v-)} i=strlen(ffiles) c1=substr(ffiles,1,1) # did user enter a filename* or a list (@) of files? if (c1 == "@") { print(substr(ffiles,2,i) copy(substr(ffiles,2,i),"tmplst",v-) } else { print(ffiles) section(ffiles,option="fullname") | sort(> "tmplst") } # now "tmplst" contains list of files to mask inl = "tmplst" # end of HW - mouching ############################################################################ #print("inl1") #print("calculating modes of ","@"//inl) while ( fscan (inl, current) != EOF ) { print(current//statsec, >>"names") } imstat("@"//"names",fields="mode",format-,>>"modes") inl2="modes" inl="tmplst" #create an inverse mask with good value=1 imarith(mmask ,"-","1","invmask") imarith("invmask","*","-1","invmask") print("starting loop") while (fscan(inl,current) != EOF && fscan (inl2,mmode) != EOF) { print("masking ",current, " with mode = ",mmode) imarith(current,"*",iinvmask,"m"//current) imarith(mmask,"*",mmode,"tempmask") imarith("m"//current,"+","tempmask","m"//current) imdel("tempmask") } imdel(iinvmask) end