/* MX NATIVE IRAF TASK: mxdemo * * PURPOSE: Demonstrate some of the features of the MX library (mx.a) * * AUTHOR: K. J. Mighell (mighell@noao.edu) * * LANGUAGE: ANSI C * * DOCUMENTATION: http://www.noao.edu/staff/mighell/mx * * DATE: 20000313 * * MOD: 2 * * Copyleft (L) 2000 Kenneth John Mighell */ #include IRAFTASK (mxdemo) { int i; extern int iraf_mxdemo (void); i = iraf_mxdemo (); } /* * ############################################################################ */ int iraf_mxdemo(void) { char mxfunc[] = "iraf_mxdemo"; int status; struct mxiraf_image_s *image=NULL; char imname[MX_IRAF_SZ_FNAME+1]; double peakmin, peakmax; int step; /* CVOS forgot to define c_clgetr! */ #define c_clgetr c_clgetf extern void peaker (double **image, int nx, int ny, double peakmin, double peakmax, int idx0,int idy0); status = mxp_init_f0(); if (status) {status=1; goto mx_error;} c_clgstr ("image", imname, sizeof(imname)); if (mxiraf_cvos_error_check_f0()) {status=2; goto mx_error;} peakmin = (double) c_clgetr ("mnpeak"); if (mxiraf_cvos_error_check_f0()) {status=3; goto mx_error;} peakmax = (double) c_clgetr ("mxpeak"); if (mxiraf_cvos_error_check_f0()) {status=4; goto mx_error;} status = mxiraf_image_s_open_f3 (&image, imname, IRAF_READ_ONLY); if (status) {status = 5; goto mx_error;} peaker (image->data->matrixd, image->data->nxi, image->data->nyi, peakmin, peakmax, image->data->llx0i, image->data->lly0i); printf ("#\n# mxdemo %s %g %g\n",imname,peakmin,peakmax); status = mxiraf_image_s_close_f1 (&image); if (status) {status = 6; goto mx_error;} ok: status = 0; goto bye; mx_error: mxp_errmsg_append_f3 (mxfunc, status, ""); mxp_errmsg_dump_f0(); goto bye; bye: return(status); } /* * ############################################################################ */ void peaker( double **image, int nx, int ny, double peakmin, double peakmax, int idx0, int idy0 ) { int x, y, xx, yy, bingo, idx1=idx0+1, idy1=idy0+1, n=1, false=0, true=1; double pixel, neighbor; for (y=1; y<=(ny-2); ++y) { for (x=1; x<=(nx-2); ++x) { pixel = image[y][x]; if ( (pixel>=peakmin) && (pixelpixel) { bingo = false; } else { if (neighbor==pixel) { if ((xx!=x)||(yy!=y)) { if (((xx<=x)&&(yy<=y))||((xx>x)&&(yy