include "fitrad.h" # Map cveval function name for reals define rcveval cveval # FTR_OUTPUT -- Output data to the image procedure ftr_output$t (imin, imout, cv, option, xc, yc, rmax) pointer imin # IMIO descriptor for input image pointer imout # IMIO descriptor for output image pointer cv # CURFIT pointer int option # output option int xc, yc # center coordinates int rmax # maximum radius int line, col, nlines, ncols PIXEL r, func, fit int imgeti() pointer imgl2$t(), impl2$t() PIXEL $tcveval() begin # Get image dimension ncols = imgeti (imin, "i_naxis1") nlines = imgeti (imin, "i_naxis2") # Set output image pixel type the calulation data # type, instead of the input image data type call imputi (imout, "i_pixtype", TY_PIXEL) # Set lines before the subraster call ftr_lineset$t (imin, imout, option, 1, yc - rmax - 1) # Set lines in the subraster do line = yc - rmax, yc + rmax { # Fill columns nefore the subraster call ftr_colset$t (imin, imout, option, line, 1, xc - rmax - 1) # Compute columns within the subraster do col = xc - rmax, xc + rmax { # Compute the radius, the pixel intensity for that point # in the input image, and the fitted value for that point. r = sqrt (PIXEL ((xc - col) ** 2 + (yc - line) ** 2)) func = Mem$t[imgl2$t (imin, line) + col - 1] if (r <= rmax) fit = $tcveval (cv, r) # Branch on output option switch (option) { case OPT_FIT: if (r <= rmax) Mem$t[impl2$t (imout, line) + col - 1] = fit else Mem$t[impl2$t (imout, line) + col - 1] = func case OPT_DIFFERENCE: if (r <= rmax) Mem$t[impl2$t (imout, line) + col - 1] = func - fit else Mem$t[impl2$t (imout, line) + col - 1] = PIXEL (0) case OPT_RATIO: if (r <= rmax) { if (fit != 0.0001) Mem$t[impl2$t (imout, line) + col - 1] = func / fit else Mem$t[impl2$t (imout, line) + col - 1] = 0 } else Mem$t[impl2$t (imout, line) + col - 1] = PIXEL (1) default: call error (0, "Unknown output option (ftr_lineset)") } } # Fill columns after the subraster call ftr_colset$t (imin, imout, option, line, xc + rmax + 1, ncols) } # Set lines after the subraster call ftr_lineset$t (imin, imout, option, yc + rmax + 1, nlines) end # FTR_LINESET -- Set output image lines from input image lines, depending # on the output option. procedure ftr_lineset$t (imin, imout, option, lstart, lend) pointer imin # IMIO descriptor for input image pointer imout # IMIO descriptor for output image int lstart, lend # starting and ending lines int option # output option int line, npix int imgeti() pointer imgl2$t(), impl2$t() begin # Get line length npix = imgeti (imin, "i_naxis1") # Set lines in range do line = lstart, lend { switch (option) { case OPT_FIT: call amov$t (Mem$t[imgl2$t (imin, line)], Mem$t[impl2$t (imout, line)], npix) case OPT_DIFFERENCE: call aclr$t (Mem$t[impl2$t (imout, line)], npix) case OPT_RATIO: call amovk$t (PIXEL (1), Mem$t[impl2$t (imout, line)], npix) default: call error (0, "Unknown output option (ftr_lineset)") } } end # FTR_COLSET -- Set output image columns from input image lines, for a # given line, depending on the output option. procedure ftr_colset$t (imin, imout, option, line, cstart, cend) pointer imin # IMIO descriptor for input image pointer imout # IMIO descriptor for output image int option # output option int line # line number int cstart, cend # starting and ending columns int npix pointer imgl2$t(), impl2$t() begin # Compute number of pixels to set npix = cend - cstart + 1 if (npix == 0) return # Set colums in range switch (option) { case OPT_FIT: call amov$t (Mem$t[imgl2$t (imin, line) + cstart - 1], Mem$t[impl2$t (imout, line) + cstart - 1], npix) case OPT_DIFFERENCE: call aclr$t (Mem$t[impl2$t (imout, line) + cstart - 1], npix) case OPT_RATIO: call amovk$t (PIXEL (1), Mem$t[impl2$t (imout, line) + cstart - 1], npix) default: call error (0, "Unknown output option (ftr_colset)") } end