procedure tvellips(image,xcen,ycen,drad,ellipt,posang) char image ="" {prompt="Image name"} real xcen =1. {prompt="Center position x (pixels)"} real ycen =1. {prompt="Center position y (pixels)"} char drad ="1." {prompt="Comma-separated list of semi-major axis radii"} real ellipt =0. {prompt="Ellipticity (1-b/a)"} real posang =0. {prompt="Position angle (wrt. x-axis)"} int color =204 {prompt="Color for ellipse (204=r,205=g,206=b,207=y)"} real zlow =0. {prompt="Lower cut level (display)"} real zhigh =0. {prompt="Upper cut level"} bool redispl =yes {prompt="(Re)display image first?"} bool calconly=no {prompt="Do not display, only calculate ellipses?"} char calcfil ="" {prompt="Name of output file"} char calcfmt ="full" {prompt="Format of output file (basic|full|tvmark)", enum="basic|full|tvmark"} bool calcpid =yes {prompt="Prepend image name in output file?"} # @(#) task tvellips Author: R.A. Jansen -- Apr 22 1997 # @(#) # @(#) task to calculate and overlay ellipses on a loaded image. The # @(#) shape of the ellipses is determined by 'ellipt' and 'posang', the # @(#) sizes by the length-list 'drad'. This task is adapted from one by # @(#) M. Franx. If 'nodispl=no', the 'tv' package must be loaded and # @(#) saoimage or ds9 must have be running; otherwise, only a tvmark # @(#) command file will be generated and saved into 'outfil'. # @(#) # @(#) Jun 30 2000 -- Added support for multi-extension / N-dim. images. begin char img, tmp, ofil, ofmt, cstr, cstrold int clr, imglen, nsam, isam, nell, NN real cx, cy, da, eps, pa, zlo, zhi real pi, cospa, sinpa, phi, cosphi, sinphi, x, y img = image cx = xcen cy = ycen eps = ellipt pa = posang clr = color zlo = zlow zhi = zhigh ofil = calcfil ofmt = calcfmt pi = 3.141592654 # Check whether the required packages are loaded... if ( !calconly && !defpac("tv") ) { error(1,"Please load \"image.tv\" first!") } # Check existence of input image, in case 'calconly==no'... unlearn chkimg chkimg (img, "access", imtype="", verbose=no) if ( !calconly && !chkimg.ok ) { error (1,"Image "//chkimg.imroot//chkimg.imtype//" not found!") } img = chkimg.imroot//chkimg.imtype//chkimg.imrpstr # Test whether 'calcfil' is defined in case 'calconly==yes'... if ( calconly ) { if ( ofil == "" ) { error (1,"You need to specify 'calcfil' when 'calconly==yes'!") } chkimg (ofil, "noaccess", imtype="file", verbose=yes) if (!chkimg.ok) { return } } # Check string with semi-major axis radii... cparse (drad, delim=",") nell = cparse.nfields if ( nell == 0 ) { error (1,"Could not parse string with semi-major axis radii!") } if ( nell > 15 ) { error (1,"Current maximum of 15 semi-major axis radii is exceeded!") } # (Re)display input image if 'redispl==yes'... if ( !calconly && redispl ) { xdisplay (img, z1=zlo, z2=zhi) } # Loop over all semi-major axis radii and compute ellipses ... tmp = mktemp("tvllps") for ( NN = 1 ; NN <= nell ; NN = NN + 1 ) { cparse (drad, delim=',', nselect=NN) da = real(cparse.selfield) nsam = nint(2.0*pi*da) + 1 cospa = cos(pa*pi/180.) sinpa = sin(pa*pi/180.) cstrold = " " for ( isam = 0 ; isam <= nsam ; isam = isam + 1 ) { phi = 2.0*pi*isam/nsam cosphi = cos(phi) sinphi = sin(phi) x = cx + (cospa*cosphi*da) - (sinpa*sinphi*da*(1.0-eps)) y = cy + (sinpa*cosphi*da) + (cospa*sinphi*da*(1.0-eps)) print (x," ",y," 101 s", >> tmp) if (calconly && ofmt != "tvmark" ) { if ( ofmt == "basic") { cstr = " "//str(nint(x))//" "//str(nint(x))//" "//str(nint(y))//" "//str(nint(y)) } else { cstr = "["//str(nint(x))//":"//str(nint(x))//","//str(nint(y))//":"//str(nint(y))//"]" } if (calcpid) { cstr = img//".imh"//cstr } if ( cstr != cstrold ) { print (cstr, >> ofil) } cstrold = cstr } } # goto next ellips } if (!calconly) { tvmark (frame=1, coords="", logfile="", autolog=no, commands=tmp, outimage="", mark="point", radii="0", lengths="0", label=no, number=no, nxoffset=0, nyoffset=0, txsize=1, pointsize=1, font="raster", color=clr, interactive=no, > "dev$null", >& "STDERR" ) } else { if ( calconly && ofmt == "tvmark") { copy (tmp, ofil, verbose=no) } } delete (tmp, yes, verify=no) end