Main Page   Data Structures   File List   Data Fields   Globals  

Sadie_Filter.c

Go to the documentation of this file.
00001 /*
00002 ##########################################
00003 # Sadie_Filter.c -
00004 #   Set of routines for linking SADIE filter routines to tcl/tk.
00005 #
00006 # RCS: $Id: Sadie_Filter.c,v 2.5 2000/08/08 22:54:32 giri Exp $ 
00007 # 
00008 # Digital Image Analysis Lab
00009 # Dept. of Electrical and Computer Engineering
00010 # University of Arizona
00011 ##########################################
00012 */
00013 
00014 #include <tcl.h>
00015 #include <tk.h>
00016 #include "sadie.h"
00017 
00018 /* RCS Indentification information */
00019 static char rcsid[] =
00020   "$Id: Sadie_Filter.c,v 2.5 2000/08/08 22:54:32 giri Exp $";
00021 
00022 /*-------------------------------------------------------------*/
00023 /* Global Sadie variables that must be set from within Tcl/Tk  */
00024 /*-------------------------------------------------------------*/
00025 extern short nlev;
00026 extern short csize;
00027 extern double weight;
00028 extern double *count;
00029 extern PIXEL gain;
00030 extern PIXEL bias;
00031 extern PIXEL gmin;
00032 extern PIXEL gmax;
00033 extern PIXEL thresh;
00034 extern PIXEL gbrk[2][4];
00035 extern PIXEL *table;
00036 /* -------------------------------------------------------------------------- */
00037 
00038 /*-Copyright Information------------------------------------------------------*/
00039 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00040 /*----------------------------------------------------------------------------*/
00041 /*-General Information--------------------------------------------------------*/
00042 /*                                                                            */
00043 /*   This procedure provides an interface to the SADIE function               */
00044 /*   PSPECT from Tcl/Tk.  It expects a tcl global array                       */
00045 /*   with these indices to exist:                                             */
00046 /*      array(inimg,addr)         --  SADIE image address                     */
00047 /*      array(outname)            --  char*                                   */
00048 /*                                                                            */
00049 /*----------------------------------------------------------------------------*/
00050 /*-Interface Information------------------------------------------------------*/
00051 int
00052 Sadie_Filter_PSpectCmd (ClientData client_data, Tcl_Interp * interp, int argc,
00053                         char *argv[])
00054 {
00055   Tcl_Obj *tclobj = NULL;
00056   Tcl_Obj *tclarrayname = NULL;
00057   Tcl_Obj *tclindexname = NULL;
00058   char msg[SLEN];
00059   char *array = NULL;
00060   char *tempstr = NULL;
00061   int strlen;
00062   int inimgaddr;
00063   IMAGE *inimg = NULL;
00064   int outimgaddr;
00065   IMAGE *outimg = NULL;
00066   char *outname = NULL;
00067   int option;
00068 
00069   if (argc != 2)
00070     {
00071       Tcl_AppendResult (interp, "wrong # args: should be \"",
00072                         argv[0], " arrayname\"", (char *) NULL);
00073       return TCL_ERROR;
00074     }
00075   array = argv[1];
00076 
00077   /* Read input image array(inimg,addr) */
00078   tclarrayname = Tcl_NewStringObj (array, -1);
00079   tclindexname = Tcl_NewStringObj ("inimg,addr", -1);
00080   if (tclobj =
00081       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00082                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00083     {
00084       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
00085       if (strlen <= 0)
00086         return TCL_ERROR;
00087       sscanf (tempstr, "%x", &inimgaddr);
00088       inimg = (IMAGE *) inimgaddr;
00089     }
00090   else
00091     {
00092       return TCL_ERROR;
00093     }
00094   Tcl_DecrRefCount (tclarrayname);
00095   Tcl_DecrRefCount (tclindexname);
00096 
00097   /* Read the input integer array(option) */
00098   tclarrayname = Tcl_NewStringObj (array, -1);
00099   tclindexname = Tcl_NewStringObj ("option", -1);
00100   if (tclobj =
00101       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00102                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00103     {
00104       if (Tcl_GetIntFromObj (interp, tclobj, &option) == TCL_ERROR)
00105         return TCL_ERROR;
00106     }
00107   else
00108     {
00109       return TCL_ERROR;
00110     }
00111   Tcl_DecrRefCount (tclarrayname);
00112   Tcl_DecrRefCount (tclindexname);
00113 
00114   /* Read the output image 1 name */
00115   tclarrayname = Tcl_NewStringObj (array, -1);
00116   tclindexname = Tcl_NewStringObj ("outname", -1);
00117   if (tclobj =
00118       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00119                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00120     {
00121       outname = Tcl_GetStringFromObj (tclobj, &strlen);
00122       if (strlen <= 0)
00123         return TCL_ERROR;
00124     }
00125   else
00126     {
00127       return TCL_ERROR;
00128     }
00129   Tcl_DecrRefCount (tclarrayname);
00130   Tcl_DecrRefCount (tclindexname);
00131 
00132   if (option == NOR_PSPECT)
00133     PSPECT (inimg, &outimg);
00134   else
00135     PSPECT1D (inimg, option, &outimg);
00136 
00137   if (CHECKIMG (outimg))
00138     sprintf (outimg->text, "%s", outname);
00139   outimgaddr = (int) outimg;
00140 
00141   sprintf (msg, "%x", outimgaddr);
00142   Tcl_SetResult (interp, msg, TCL_VOLATILE);
00143 
00144   return TCL_OK;
00145 }
00146 
00147 /*-Copyright Information------------------------------------------------------*/
00148 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00149 /*----------------------------------------------------------------------------*/
00150 /*-General Information--------------------------------------------------------*/
00151 /*                                                                            */
00152 /*   This procedure provides an interface to the SADIE function               */
00153 /*   FCONVL from Tcl/Tk.  It expects a tcl global array                       */
00154 /*   with these indices to exist:                                             */
00155 /*      array(inimg,addr1)        --  SADIE image address                     */
00156 /*      array(inimg,addr2)        --  SADIE image address                     */
00157 /*      array(option)             --  int                                     */
00158 /*      array(outname)            --  char*                                   */
00159 /*                                                                            */
00160 /*----------------------------------------------------------------------------*/
00161 /*-Interface Information------------------------------------------------------*/
00162 int
00163 Sadie_Filter_FFTConvCmd (ClientData client_data, Tcl_Interp * interp,
00164                          int argc, char *argv[])
00165 {
00166   Tcl_Obj *tclobj = NULL;
00167   Tcl_Obj *tclarrayname = NULL;
00168   Tcl_Obj *tclindexname = NULL;
00169   char msg[SLEN];
00170   char *array = NULL;
00171   char *tempstr = NULL;
00172   int strlen;
00173   int inimgaddr1, inimgaddr2;
00174   IMAGE *inimg1 = NULL, *inimg2 = NULL;
00175   int outimgaddr;
00176   IMAGE *outimg = NULL;
00177   char *outname = NULL;
00178   int option;
00179 
00180   if (argc != 2)
00181     {
00182       Tcl_AppendResult (interp, "wrong # args: should be \"",
00183                         argv[0], " arrayname\"", (char *) NULL);
00184       return TCL_ERROR;
00185     }
00186   array = argv[1];
00187 
00188   /* Read input image array(inimg,addr1) */
00189   tclarrayname = Tcl_NewStringObj (array, -1);
00190   tclindexname = Tcl_NewStringObj ("inimg,addr1", -1);
00191   if (tclobj =
00192       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00193                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00194     {
00195       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
00196       if (strlen <= 0)
00197         return TCL_ERROR;
00198       sscanf (tempstr, "%x", &inimgaddr1);
00199       inimg1 = (IMAGE *) inimgaddr1;
00200     }
00201   else
00202     {
00203       return TCL_ERROR;
00204     }
00205   Tcl_DecrRefCount (tclarrayname);
00206   Tcl_DecrRefCount (tclindexname);
00207 
00208   /* Read input image array(inimg,addr2) */
00209   tclarrayname = Tcl_NewStringObj (array, -1);
00210   tclindexname = Tcl_NewStringObj ("inimg,addr2", -1);
00211   if (tclobj =
00212       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00213                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00214     {
00215       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
00216       if (strlen <= 0)
00217         return TCL_ERROR;
00218       sscanf (tempstr, "%x", &inimgaddr2);
00219       inimg2 = (IMAGE *) inimgaddr2;
00220     }
00221   else
00222     {
00223       return TCL_ERROR;
00224     }
00225   Tcl_DecrRefCount (tclarrayname);
00226   Tcl_DecrRefCount (tclindexname);
00227 
00228   /* Read the input integer array(option) */
00229   tclarrayname = Tcl_NewStringObj (array, -1);
00230   tclindexname = Tcl_NewStringObj ("option", -1);
00231   if (tclobj =
00232       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00233                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00234     {
00235       if (Tcl_GetIntFromObj (interp, tclobj, &option) == TCL_ERROR)
00236         return TCL_ERROR;
00237     }
00238   else
00239     {
00240       return TCL_ERROR;
00241     }
00242   Tcl_DecrRefCount (tclarrayname);
00243   Tcl_DecrRefCount (tclindexname);
00244 
00245   /* Read the output image 1 name */
00246   tclarrayname = Tcl_NewStringObj (array, -1);
00247   tclindexname = Tcl_NewStringObj ("outname", -1);
00248   if (tclobj =
00249       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00250                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00251     {
00252       outname = Tcl_GetStringFromObj (tclobj, &strlen);
00253       if (strlen <= 0)
00254         return TCL_ERROR;
00255     }
00256   else
00257     {
00258       return TCL_ERROR;
00259     }
00260   Tcl_DecrRefCount (tclarrayname);
00261   Tcl_DecrRefCount (tclindexname);
00262 
00263   FCONVL (inimg1, inimg2, option, &outimg);
00264 
00265   if (CHECKIMG (outimg))
00266     sprintf (outimg->text, "%s", outname);
00267   outimgaddr = (int) outimg;
00268 
00269   sprintf (msg, "%x", outimgaddr);
00270   Tcl_SetResult (interp, msg, TCL_VOLATILE);
00271 
00272   return TCL_OK;
00273 }
00274 
00275 /*-Copyright Information------------------------------------------------------*/
00276 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00277 /*----------------------------------------------------------------------------*/
00278 /*-General Information--------------------------------------------------------*/
00279 /*                                                                            */
00280 /*   This procedure provides an interface to the SADIE function               */
00281 /*   FILTER from Tcl/Tk.  It expects a tcl global array                       */
00282 /*   with these indices to exist:                                             */
00283 /*      array(inimg,addr)         --  SADIE image address                     */
00284 /*      array(option)             --  int                                     */
00285 /*      array(xradius)            --  double                                  */
00286 /*      array(yradius)            --  double                                  */
00287 /*      array(parameter)          --  double                                  */
00288 /*      array(outname)            --  char*                                   */
00289 /*                                                                            */
00290 /*----------------------------------------------------------------------------*/
00291 /*-Interface Information------------------------------------------------------*/
00292 int
00293 Sadie_Filter_FFTFiltCmd (ClientData client_data, Tcl_Interp * interp,
00294                          int argc, char *argv[])
00295 {
00296   Tcl_Obj *tclobj = NULL;
00297   Tcl_Obj *tclarrayname = NULL;
00298   Tcl_Obj *tclindexname = NULL;
00299   char msg[SLEN];
00300   char *array = NULL;
00301   char *tempstr = NULL;
00302   int strlen;
00303   int inimgaddr;
00304   IMAGE *inimg = NULL;
00305   int outimgaddr;
00306   IMAGE *outimg = NULL;
00307   char *outname = NULL;
00308   int option;
00309   double xradius, yradius, parameter;
00310 
00311   double (*flt) (double, double, double, double);
00312 
00313   if (argc != 2)
00314     {
00315       Tcl_AppendResult (interp, "wrong # args: should be \"",
00316                         argv[0], " arrayname\"", (char *) NULL);
00317       return TCL_ERROR;
00318     }
00319   array = argv[1];
00320 
00321   /* Read input image array(inimg,addr) */
00322   tclarrayname = Tcl_NewStringObj (array, -1);
00323   tclindexname = Tcl_NewStringObj ("inimg,addr", -1);
00324   if (tclobj =
00325       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00326                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00327     {
00328       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
00329       if (strlen <= 0)
00330         return TCL_ERROR;
00331       sscanf (tempstr, "%x", &inimgaddr);
00332       inimg = (IMAGE *) inimgaddr;
00333     }
00334   else
00335     {
00336       return TCL_ERROR;
00337     }
00338   Tcl_DecrRefCount (tclarrayname);
00339   Tcl_DecrRefCount (tclindexname);
00340 
00341   /* Read the input integer array(option) */
00342   tclarrayname = Tcl_NewStringObj (array, -1);
00343   tclindexname = Tcl_NewStringObj ("option", -1);
00344   if (tclobj =
00345       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00346                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00347     {
00348       if (Tcl_GetIntFromObj (interp, tclobj, &option) == TCL_ERROR)
00349         return TCL_ERROR;
00350     }
00351   else
00352     {
00353       return TCL_ERROR;
00354     }
00355   Tcl_DecrRefCount (tclarrayname);
00356   Tcl_DecrRefCount (tclindexname);
00357 
00358   /* Read the input double array(xradius) */
00359   tclarrayname = Tcl_NewStringObj (array, -1);
00360   tclindexname = Tcl_NewStringObj ("xradius", -1);
00361   if (tclobj =
00362       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00363                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00364     {
00365       if (Tcl_GetDoubleFromObj (interp, tclobj, &xradius) == TCL_ERROR)
00366         return TCL_ERROR;
00367     }
00368   else
00369     {
00370       return TCL_ERROR;
00371     }
00372   Tcl_DecrRefCount (tclarrayname);
00373   Tcl_DecrRefCount (tclindexname);
00374 
00375   /* Read the input double array(yradius) */
00376   tclarrayname = Tcl_NewStringObj (array, -1);
00377   tclindexname = Tcl_NewStringObj ("yradius", -1);
00378   if (tclobj =
00379       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00380                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00381     {
00382       if (Tcl_GetDoubleFromObj (interp, tclobj, &yradius) == TCL_ERROR)
00383         return TCL_ERROR;
00384     }
00385   else
00386     {
00387       return TCL_ERROR;
00388     }
00389   Tcl_DecrRefCount (tclarrayname);
00390   Tcl_DecrRefCount (tclindexname);
00391 
00392   /* Read the input double array(parameter) */
00393   tclarrayname = Tcl_NewStringObj (array, -1);
00394   tclindexname = Tcl_NewStringObj ("parameter", -1);
00395   if (tclobj =
00396       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00397                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00398     {
00399       if (Tcl_GetDoubleFromObj (interp, tclobj, &parameter) == TCL_ERROR)
00400         return TCL_ERROR;
00401     }
00402   else
00403     {
00404       return TCL_ERROR;
00405     }
00406   Tcl_DecrRefCount (tclarrayname);
00407   Tcl_DecrRefCount (tclindexname);
00408 
00409   /* Read the output image 1 name */
00410   tclarrayname = Tcl_NewStringObj (array, -1);
00411   tclindexname = Tcl_NewStringObj ("outname", -1);
00412   if (tclobj =
00413       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00414                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00415     {
00416       outname = Tcl_GetStringFromObj (tclobj, &strlen);
00417       if (strlen <= 0)
00418         return TCL_ERROR;
00419     }
00420   else
00421     {
00422       return TCL_ERROR;
00423     }
00424   Tcl_DecrRefCount (tclarrayname);
00425   Tcl_DecrRefCount (tclindexname);
00426 
00427   switch (option)
00428     {
00429     case 1:
00430       flt = FLTCONE;
00431       break;
00432 
00433     case 2:
00434       flt = FLTEXP;
00435       break;
00436 
00437     case 3:
00438       flt = FLTGAUSS;
00439       break;
00440 
00441     case 4:
00442       flt = FLTBOX;
00443       break;
00444 
00445     default:
00446       flt = FLTCYL;
00447       break;
00448     }
00449 
00450   FILTER (inimg, flt, xradius, yradius, parameter, &outimg);
00451 
00452   if (CHECKIMG (outimg))
00453     sprintf (outimg->text, "%s", outname);
00454   outimgaddr = (int) outimg;
00455 
00456   sprintf (msg, "%x", outimgaddr);
00457   Tcl_SetResult (interp, msg, TCL_VOLATILE);
00458 
00459   return TCL_OK;
00460 }
00461 
00462 /*-Copyright Information------------------------------------------------------*/
00463 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00464 /*----------------------------------------------------------------------------*/
00465 /*-General Information--------------------------------------------------------*/
00466 /*                                                                            */
00467 /*   This procedure provides an interface to the SADIE function               */
00468 /*   FFT2D from Tcl/Tk.  It expects a tcl global array                        */
00469 /*   with these indices to exist:                                             */
00470 /*      array(inimg,addr)         --  SADIE image address                     */
00471 /*      array(option)             --  int                                     */
00472 /*      array(outname)            --  char*                                   */
00473 /*                                                                            */
00474 /*----------------------------------------------------------------------------*/
00475 /*-Interface Information------------------------------------------------------*/
00476 int
00477 Sadie_Filter_FFTCmd (ClientData client_data, Tcl_Interp * interp, int argc,
00478                      char *argv[])
00479 {
00480   Tcl_Obj *tclobj = NULL;
00481   Tcl_Obj *tclarrayname = NULL;
00482   Tcl_Obj *tclindexname = NULL;
00483   char msg[SLEN];
00484   char *array = NULL;
00485   char *tempstr = NULL;
00486   int strlen;
00487   int inimgaddr;
00488   IMAGE *inimg = NULL;
00489   int outimgaddr;
00490   IMAGE *outimg = NULL;
00491   char *outname = NULL;
00492   int option;
00493 
00494   if (argc != 2)
00495     {
00496       Tcl_AppendResult (interp, "wrong # args: should be \"",
00497                         argv[0], " arrayname\"", (char *) NULL);
00498       return TCL_ERROR;
00499     }
00500   array = argv[1];
00501 
00502   /* Read input image array(inimg,addr) */
00503   tclarrayname = Tcl_NewStringObj (array, -1);
00504   tclindexname = Tcl_NewStringObj ("inimg,addr", -1);
00505   if (tclobj =
00506       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00507                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00508     {
00509       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
00510       if (strlen <= 0)
00511         return TCL_ERROR;
00512       sscanf (tempstr, "%x", &inimgaddr);
00513       inimg = (IMAGE *) inimgaddr;
00514     }
00515   else
00516     {
00517       return TCL_ERROR;
00518     }
00519   Tcl_DecrRefCount (tclarrayname);
00520   Tcl_DecrRefCount (tclindexname);
00521 
00522   /* Read the input integer array(option) */
00523   tclarrayname = Tcl_NewStringObj (array, -1);
00524   tclindexname = Tcl_NewStringObj ("option", -1);
00525   if (tclobj =
00526       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00527                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00528     {
00529       if (Tcl_GetIntFromObj (interp, tclobj, &option) == TCL_ERROR)
00530         return TCL_ERROR;
00531     }
00532   else
00533     {
00534       return TCL_ERROR;
00535     }
00536   Tcl_DecrRefCount (tclarrayname);
00537   Tcl_DecrRefCount (tclindexname);
00538 
00539   /* Read the output image 1 name */
00540   tclarrayname = Tcl_NewStringObj (array, -1);
00541   tclindexname = Tcl_NewStringObj ("outname", -1);
00542   if (tclobj =
00543       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00544                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00545     {
00546       outname = Tcl_GetStringFromObj (tclobj, &strlen);
00547       if (strlen <= 0)
00548         return TCL_ERROR;
00549     }
00550   else
00551     {
00552       return TCL_ERROR;
00553     }
00554   Tcl_DecrRefCount (tclarrayname);
00555   Tcl_DecrRefCount (tclindexname);
00556 
00557   FFT2D (inimg, option, &outimg);
00558 
00559   if (CHECKIMG (outimg))
00560     sprintf (outimg->text, "%s", outname);
00561   outimgaddr = (int) outimg;
00562 
00563   sprintf (msg, "%x", outimgaddr);
00564   Tcl_SetResult (interp, msg, TCL_VOLATILE);
00565 
00566   return TCL_OK;
00567 }
00568 
00569 /*-Copyright Information------------------------------------------------------*/
00570 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00571 /*----------------------------------------------------------------------------*/
00572 /*-General Information--------------------------------------------------------*/
00573 /*                                                                            */
00574 /*   This procedure provides an interface to the SADIE function               */
00575 /*   FHT2D from Tcl/Tk.  It expects a tcl global array                        */
00576 /*   with these indices to exist:                                             */
00577 /*      array(inimg,addr)         --  SADIE image address                     */
00578 /*      array(option)             --  int                                     */
00579 /*      array(outname)            --  char*                                   */
00580 /*                                                                            */
00581 /*----------------------------------------------------------------------------*/
00582 /*-Interface Information------------------------------------------------------*/
00583 int
00584 Sadie_Filter_FHTCmd (ClientData client_data, Tcl_Interp * interp, int argc,
00585                      char *argv[])
00586 {
00587   Tcl_Obj *tclobj = NULL;
00588   Tcl_Obj *tclarrayname = NULL;
00589   Tcl_Obj *tclindexname = NULL;
00590   char msg[SLEN];
00591   char *array = NULL;
00592   char *tempstr = NULL;
00593   int strlen;
00594   int inimgaddr;
00595   IMAGE *inimg = NULL;
00596   int outimgaddr;
00597   IMAGE *outimg = NULL;
00598   char *outname = NULL;
00599   int option;
00600 
00601   if (argc != 2)
00602     {
00603       Tcl_AppendResult (interp, "wrong # args: should be \"",
00604                         argv[0], " arrayname\"", (char *) NULL);
00605       return TCL_ERROR;
00606     }
00607   array = argv[1];
00608 
00609   /* Read input image array(inimg,addr) */
00610   tclarrayname = Tcl_NewStringObj (array, -1);
00611   tclindexname = Tcl_NewStringObj ("inimg,addr", -1);
00612   if (tclobj =
00613       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00614                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00615     {
00616       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
00617       if (strlen <= 0)
00618         return TCL_ERROR;
00619       sscanf (tempstr, "%x", &inimgaddr);
00620       inimg = (IMAGE *) inimgaddr;
00621     }
00622   else
00623     {
00624       return TCL_ERROR;
00625     }
00626   Tcl_DecrRefCount (tclarrayname);
00627   Tcl_DecrRefCount (tclindexname);
00628 
00629   /* Read the input integer array(option) */
00630   tclarrayname = Tcl_NewStringObj (array, -1);
00631   tclindexname = Tcl_NewStringObj ("option", -1);
00632   if (tclobj =
00633       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00634                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00635     {
00636       if (Tcl_GetIntFromObj (interp, tclobj, &option) == TCL_ERROR)
00637         return TCL_ERROR;
00638     }
00639   else
00640     {
00641       return TCL_ERROR;
00642     }
00643   Tcl_DecrRefCount (tclarrayname);
00644   Tcl_DecrRefCount (tclindexname);
00645 
00646   /* Read the output image 1 name */
00647   tclarrayname = Tcl_NewStringObj (array, -1);
00648   tclindexname = Tcl_NewStringObj ("outname", -1);
00649   if (tclobj =
00650       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00651                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00652     {
00653       outname = Tcl_GetStringFromObj (tclobj, &strlen);
00654       if (strlen <= 0)
00655         return TCL_ERROR;
00656     }
00657   else
00658     {
00659       return TCL_ERROR;
00660     }
00661   Tcl_DecrRefCount (tclarrayname);
00662   Tcl_DecrRefCount (tclindexname);
00663 
00664   FHT2D (inimg, option, &outimg);
00665 
00666   if (CHECKIMG (outimg))
00667     sprintf (outimg->text, "%s", outname);
00668   outimgaddr = (int) outimg;
00669 
00670   sprintf (msg, "%x", outimgaddr);
00671   Tcl_SetResult (interp, msg, TCL_VOLATILE);
00672 
00673   return TCL_OK;
00674 }
00675 
00676 /*-Copyright Information------------------------------------------------------*/
00677 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00678 /*----------------------------------------------------------------------------*/
00679 /*-General Information--------------------------------------------------------*/
00680 /*                                                                            */
00681 /*   This procedure provides an interface to the SADIE function               */
00682 /*   SCONVL from Tcl/Tk.  It expects a tcl global array                       */
00683 /*   with these indices to exist:                                             */
00684 /*      array(inimg,addr)         --  SADIE image address                     */
00685 /*      array(lines)              --  int                                     */
00686 /*      array(pix)                --  int                                     */
00687 /*      array(factor)             --  double                                  */
00688 /*      array(mask,0-(lines-1),0-(pix-1)) --  PIXEL                           */
00689 /*      array(outname)            --  char*                                   */
00690 /*                                                                            */
00691 /*----------------------------------------------------------------------------*/
00692 /*-Interface Information------------------------------------------------------*/
00693 int
00694 Sadie_Filter_MaskConvCmd (ClientData client_data, Tcl_Interp * interp,
00695                           int argc, char *argv[])
00696 {
00697   short i, j, k, n;
00698   Tcl_Obj *tclobj = NULL;
00699   Tcl_Obj *tclarrayname = NULL;
00700   Tcl_Obj *tclindexname = NULL;
00701   char msg[SLEN];
00702   char *array = NULL;
00703   char *tempstr = NULL;
00704   int strlen;
00705   int inimgaddr;
00706   IMAGE *inimg = NULL;
00707   int outimgaddr;
00708   IMAGE *outimg = NULL;
00709   char *outname = NULL;
00710   int lines, pix;
00711   double factor, tempdouble;
00712   PIXEL *psf = NULL;
00713   char index[20];
00714 
00715   if (argc != 2)
00716     {
00717       Tcl_AppendResult (interp, "wrong # args: should be \"",
00718                         argv[0], " arrayname\"", (char *) NULL);
00719       return TCL_ERROR;
00720     }
00721   array = argv[1];
00722 
00723   /* Read input image array(inimg,addr) */
00724   tclarrayname = Tcl_NewStringObj (array, -1);
00725   tclindexname = Tcl_NewStringObj ("inimg,addr", -1);
00726   if (tclobj =
00727       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00728                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00729     {
00730       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
00731       if (strlen <= 0)
00732         return TCL_ERROR;
00733       sscanf (tempstr, "%x", &inimgaddr);
00734       inimg = (IMAGE *) inimgaddr;
00735     }
00736   else
00737     {
00738       return TCL_ERROR;
00739     }
00740   Tcl_DecrRefCount (tclarrayname);
00741   Tcl_DecrRefCount (tclindexname);
00742 
00743   /* Read the input integer array(lines) */
00744   tclarrayname = Tcl_NewStringObj (array, -1);
00745   tclindexname = Tcl_NewStringObj ("lines", -1);
00746   if (tclobj =
00747       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00748                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00749     {
00750       if (Tcl_GetIntFromObj (interp, tclobj, &lines) == TCL_ERROR)
00751         return TCL_ERROR;
00752     }
00753   else
00754     {
00755       return TCL_ERROR;
00756     }
00757   Tcl_DecrRefCount (tclarrayname);
00758   Tcl_DecrRefCount (tclindexname);
00759 
00760   /* Read the input integer array(pix) */
00761   tclarrayname = Tcl_NewStringObj (array, -1);
00762   tclindexname = Tcl_NewStringObj ("pix", -1);
00763   if (tclobj =
00764       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00765                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00766     {
00767       if (Tcl_GetIntFromObj (interp, tclobj, &pix) == TCL_ERROR)
00768         return TCL_ERROR;
00769     }
00770   else
00771     {
00772       return TCL_ERROR;
00773     }
00774   Tcl_DecrRefCount (tclarrayname);
00775   Tcl_DecrRefCount (tclindexname);
00776 
00777   /* Read the input double array(factor) */
00778   tclarrayname = Tcl_NewStringObj (array, -1);
00779   tclindexname = Tcl_NewStringObj ("factor", -1);
00780   if (tclobj =
00781       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00782                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00783     {
00784       if (Tcl_GetDoubleFromObj (interp, tclobj, &factor) == TCL_ERROR)
00785         return TCL_ERROR;
00786     }
00787   else
00788     {
00789       return TCL_ERROR;
00790     }
00791   Tcl_DecrRefCount (tclarrayname);
00792   Tcl_DecrRefCount (tclindexname);
00793 
00794   /* Read the output image 1 name */
00795   tclarrayname = Tcl_NewStringObj (array, -1);
00796   tclindexname = Tcl_NewStringObj ("outname", -1);
00797   if (tclobj =
00798       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00799                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00800     {
00801       outname = Tcl_GetStringFromObj (tclobj, &strlen);
00802       if (strlen <= 0)
00803         return TCL_ERROR;
00804     }
00805   else
00806     {
00807       return TCL_ERROR;
00808     }
00809   Tcl_DecrRefCount (tclarrayname);
00810   Tcl_DecrRefCount (tclindexname);
00811 
00812   if (!(psf = (PIXEL *) malloc (lines * pix * sizeof (PIXEL))))
00813     {
00814       Tcl_AppendResult (interp, "Cannot allocate memory!", (char *) NULL);
00815       return TCL_ERROR;
00816     }
00817 
00818   for (n = 0, j = 0; j < lines; j++)
00819     {
00820       for (k = 0; k < pix; k++)
00821         {
00822           /* Read the input double array(mask,j,k) */
00823           sprintf (index, "mask,%d,%d", j, k);
00824           tclarrayname = Tcl_NewStringObj (array, -1);
00825           tclindexname = Tcl_NewStringObj (index, -1);
00826           if (tclobj =
00827               Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00828                               TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00829             {
00830               if (Tcl_GetDoubleFromObj (interp, tclobj, &tempdouble) ==
00831                   TCL_ERROR)
00832                 return TCL_ERROR;
00833               psf[n++] = (PIXEL) (tempdouble / factor);
00834             }
00835           else
00836             {
00837               return TCL_ERROR;
00838             }
00839           Tcl_DecrRefCount (tclarrayname);
00840           Tcl_DecrRefCount (tclindexname);
00841         }
00842     }
00843 
00844   SCONVL (inimg, psf, lines, pix, &outimg);
00845 
00846   if (psf)
00847     free (psf);
00848 
00849   if (CHECKIMG (outimg))
00850     sprintf (outimg->text, "%s", outname);
00851   outimgaddr = (int) outimg;
00852 
00853   sprintf (msg, "%x", outimgaddr);
00854   Tcl_SetResult (interp, msg, TCL_VOLATILE);
00855 
00856   return TCL_OK;
00857 }
00858 
00859 /*-Copyright Information------------------------------------------------------*/
00860 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00861 /*----------------------------------------------------------------------------*/
00862 /*-General Information--------------------------------------------------------*/
00863 /*                                                                            */
00864 /*   This procedure provides an interface to the SADIE function               */
00865 /*   SCONVL from Tcl/Tk.  It expects a tcl global array                       */
00866 /*   with these indices to exist:                                             */
00867 /*      array(inimg,addr)         --  SADIE image address                     */
00868 /*      array(kimg,addr)          --  SADIE image address                     */
00869 /*      array(normalize)          --  int                                     */
00870 /*      array(outname)            --  char*                                   */
00871 /*                                                                            */
00872 /*----------------------------------------------------------------------------*/
00873 /*-Interface Information------------------------------------------------------*/
00874 int
00875 Sadie_Filter_ImageConvCmd (ClientData client_data, Tcl_Interp * interp,
00876                            int argc, char *argv[])
00877 {
00878   short i, j, k, n;
00879   Tcl_Obj *tclobj = NULL;
00880   Tcl_Obj *tclarrayname = NULL;
00881   Tcl_Obj *tclindexname = NULL;
00882   char msg[SLEN];
00883   char *array = NULL;
00884   char *tempstr = NULL;
00885   int strlen;
00886   int normalize, lines, pix;
00887   PIXEL factor;
00888   int inimgaddr, kimgaddr;
00889   IMAGE *inimg = NULL, *kimg = NULL;
00890   int outimgaddr;
00891   IMAGE *outimg = NULL;
00892   char *outname = NULL;
00893   PIXEL *psf = NULL;
00894 
00895   if (argc != 2)
00896     {
00897       Tcl_AppendResult (interp, "wrong # args: should be \"",
00898                         argv[0], " arrayname\"", (char *) NULL);
00899       return TCL_ERROR;
00900     }
00901   array = argv[1];
00902 
00903   /* Read input image array(inimg,addr) */
00904   tclarrayname = Tcl_NewStringObj (array, -1);
00905   tclindexname = Tcl_NewStringObj ("inimg,addr", -1);
00906   if (tclobj =
00907       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00908                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00909     {
00910       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
00911       if (strlen <= 0)
00912         return TCL_ERROR;
00913       sscanf (tempstr, "%x", &inimgaddr);
00914       inimg = (IMAGE *) inimgaddr;
00915     }
00916   else
00917     {
00918       return TCL_ERROR;
00919     }
00920   Tcl_DecrRefCount (tclarrayname);
00921   Tcl_DecrRefCount (tclindexname);
00922 
00923   /* Read input image array(kimg,addr) */
00924   tclarrayname = Tcl_NewStringObj (array, -1);
00925   tclindexname = Tcl_NewStringObj ("kimg,addr", -1);
00926   if (tclobj =
00927       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00928                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00929     {
00930       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
00931       if (strlen <= 0)
00932         return TCL_ERROR;
00933       sscanf (tempstr, "%x", &kimgaddr);
00934       kimg = (IMAGE *) kimgaddr;
00935     }
00936   else
00937     {
00938       return TCL_ERROR;
00939     }
00940   Tcl_DecrRefCount (tclarrayname);
00941   Tcl_DecrRefCount (tclindexname);
00942 
00943   /* Read the input integer array(normalize) */
00944   tclarrayname = Tcl_NewStringObj (array, -1);
00945   tclindexname = Tcl_NewStringObj ("normalize", -1);
00946   if (tclobj =
00947       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00948                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00949     {
00950       if (Tcl_GetIntFromObj (interp, tclobj, &normalize) == TCL_ERROR)
00951         return TCL_ERROR;
00952     }
00953   else
00954     {
00955       return TCL_ERROR;
00956     }
00957   Tcl_DecrRefCount (tclarrayname);
00958   Tcl_DecrRefCount (tclindexname);
00959 
00960   /* Read the output image 1 name */
00961   tclarrayname = Tcl_NewStringObj (array, -1);
00962   tclindexname = Tcl_NewStringObj ("outname", -1);
00963   if (tclobj =
00964       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
00965                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00966     {
00967       outname = Tcl_GetStringFromObj (tclobj, &strlen);
00968       if (strlen <= 0)
00969         return TCL_ERROR;
00970     }
00971   else
00972     {
00973       return TCL_ERROR;
00974     }
00975   Tcl_DecrRefCount (tclarrayname);
00976   Tcl_DecrRefCount (tclindexname);
00977 
00978   lines = kimg->nlin;
00979   pix = kimg->npix;
00980 
00981   if (!(psf = (PIXEL *) malloc (lines * pix * sizeof (PIXEL))))
00982     {
00983       Tcl_AppendResult (interp, "Cannot allocate memory!", (char *) NULL);
00984       return TCL_ERROR;
00985     }
00986 
00987   for (n = 0, j = 0; j < lines; j++)
00988     {
00989       for (k = 0; k < pix; k++)
00990         {
00991           psf[n++] = kimg->data[0][j][k];
00992         }
00993     }
00994 
00995   if (normalize)
00996     {
00997       factor = 0.0;
00998 
00999       for (n = 0, j = 0; j < lines; j++)
01000         {
01001           for (k = 0; k < pix; k++)
01002             {
01003               factor += psf[n++];
01004             }
01005         }
01006 
01007       for (n = 0, j = 0; j < lines; j++)
01008         {
01009           for (k = 0; k < pix; k++)
01010             {
01011               psf[n++] /= factor;
01012             }
01013         }
01014     }
01015 
01016   SCONVL (inimg, psf, lines, pix, &outimg);
01017 
01018   if (psf)
01019     free (psf);
01020 
01021   if (CHECKIMG (outimg))
01022     sprintf (outimg->text, "%s", outname);
01023   outimgaddr = (int) outimg;
01024 
01025   sprintf (msg, "%x", outimgaddr);
01026   Tcl_SetResult (interp, msg, TCL_VOLATILE);
01027 
01028   return TCL_OK;
01029 }
01030 
01031 /*-Copyright Information------------------------------------------------------*/
01032 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
01033 /*----------------------------------------------------------------------------*/
01034 /*-General Information--------------------------------------------------------*/
01035 /*                                                                            */
01036 /*   This procedure provides an interface to the SADIE function               */
01037 /*   EDGE from Tcl/Tk.  It expects a tcl global array                         */
01038 /*   with these indices to exist:                                             */
01039 /*      array(inimg,addr)         --  SADIE image address                     */
01040 /*      array(option)             --  int                                     */
01041 /*      array(magname)            --  char*                                   */
01042 /*      array(dirname)            --  char*                                   */
01043 /*                                                                            */
01044 /*----------------------------------------------------------------------------*/
01045 /*-Interface Information------------------------------------------------------*/
01046 int
01047 Sadie_Filter_LibGradCmd (ClientData client_data, Tcl_Interp * interp,
01048                          int argc, char *argv[])
01049 {
01050   Tcl_Obj *tclobj = NULL;
01051   Tcl_Obj *tclarrayname = NULL;
01052   Tcl_Obj *tclindexname = NULL;
01053   char msg[SLEN];
01054   char *array = NULL;
01055   char *tempstr = NULL;
01056   int strlen;
01057   int inimgaddr;
01058   IMAGE *inimg = NULL;
01059   int magimgaddr, dirimgaddr;
01060   IMAGE *magimg = NULL, *dirimg = NULL;
01061   char *magname = NULL, *dirname = NULL;
01062   int option;
01063 
01064   if (argc != 2)
01065     {
01066       Tcl_AppendResult (interp, "wrong # args: should be \"",
01067                         argv[0], " arrayname\"", (char *) NULL);
01068       return TCL_ERROR;
01069     }
01070   array = argv[1];
01071 
01072   /* Read input image array(inimg,addr) */
01073   tclarrayname = Tcl_NewStringObj (array, -1);
01074   tclindexname = Tcl_NewStringObj ("inimg,addr", -1);
01075   if (tclobj =
01076       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01077                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01078     {
01079       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01080       if (strlen <= 0)
01081         return TCL_ERROR;
01082       sscanf (tempstr, "%x", &inimgaddr);
01083       inimg = (IMAGE *) inimgaddr;
01084     }
01085   else
01086     {
01087       return TCL_ERROR;
01088     }
01089   Tcl_DecrRefCount (tclarrayname);
01090   Tcl_DecrRefCount (tclindexname);
01091 
01092   /* Read the input integer array(option) */
01093   tclarrayname = Tcl_NewStringObj (array, -1);
01094   tclindexname = Tcl_NewStringObj ("option", -1);
01095   if (tclobj =
01096       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01097                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01098     {
01099       if (Tcl_GetIntFromObj (interp, tclobj, &option) == TCL_ERROR)
01100         return TCL_ERROR;
01101     }
01102   else
01103     {
01104       return TCL_ERROR;
01105     }
01106   Tcl_DecrRefCount (tclarrayname);
01107   Tcl_DecrRefCount (tclindexname);
01108 
01109   /* Read the output image 1 name */
01110   tclarrayname = Tcl_NewStringObj (array, -1);
01111   tclindexname = Tcl_NewStringObj ("magname", -1);
01112   if (tclobj =
01113       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01114                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01115     {
01116       magname = Tcl_GetStringFromObj (tclobj, &strlen);
01117       if (strlen <= 0)
01118         return TCL_ERROR;
01119     }
01120   else
01121     {
01122       return TCL_ERROR;
01123     }
01124   Tcl_DecrRefCount (tclarrayname);
01125   Tcl_DecrRefCount (tclindexname);
01126 
01127   /* Read the output image 2 name */
01128   tclarrayname = Tcl_NewStringObj (array, -1);
01129   tclindexname = Tcl_NewStringObj ("dirname", -1);
01130   if (tclobj =
01131       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01132                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01133     {
01134       dirname = Tcl_GetStringFromObj (tclobj, &strlen);
01135       if (strlen <= 0)
01136         return TCL_ERROR;
01137     }
01138   else
01139     {
01140       return TCL_ERROR;
01141     }
01142   Tcl_DecrRefCount (tclarrayname);
01143   Tcl_DecrRefCount (tclindexname);
01144 
01145   EDGE (inimg, option, &magimg, &dirimg);
01146 
01147   if (CHECKIMG (magimg))
01148     sprintf (magimg->text, "%s", magname);
01149   magimgaddr = (int) magimg;
01150 
01151   if (CHECKIMG (dirimg))
01152     sprintf (dirimg->text, "%s", dirname);
01153   dirimgaddr = (int) dirimg;
01154 
01155   sprintf (msg, "%x %x", magimgaddr, dirimgaddr);
01156   Tcl_SetResult (interp, msg, TCL_VOLATILE);
01157 
01158   return TCL_OK;
01159 }
01160 
01161 /*-Copyright Information------------------------------------------------------*/
01162 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
01163 /*----------------------------------------------------------------------------*/
01164 /*-General Information--------------------------------------------------------*/
01165 /*                                                                            */
01166 /*   This procedure provides an interface to the SADIE function               */
01167 /*   GRADIENT from Tcl/Tk.  It expects a tcl global array                     */
01168 /*   with these indices to exist:                                             */
01169 /*      array(inimg,addr)         --  SADIE image address                     */
01170 /*      array(hmask,0-2)          --  PIXEL                                   */
01171 /*      array(vmask,0-2)          --  PIXEL                                   */
01172 /*      array(magname)            --  char*                                   */
01173 /*      array(dirname)            --  char*                                   */
01174 /*                                                                            */
01175 /*----------------------------------------------------------------------------*/
01176 /*-Interface Information------------------------------------------------------*/
01177 int
01178 Sadie_Filter_MaskGradCmd (ClientData client_data, Tcl_Interp * interp,
01179                           int argc, char *argv[])
01180 {
01181   short i, j, k, n;
01182   Tcl_Obj *tclobj = NULL;
01183   Tcl_Obj *tclarrayname = NULL;
01184   Tcl_Obj *tclindexname = NULL;
01185   char msg[SLEN];
01186   char *array = NULL;
01187   char *tempstr = NULL;
01188   int strlen;
01189   int inimgaddr;
01190   IMAGE *inimg = NULL;
01191   int magimgaddr, dirimgaddr;
01192   IMAGE *magimg = NULL, *dirimg = NULL;
01193   char *magname = NULL, *dirname = NULL;
01194   PIXEL hpsf[9], vpsf[9];
01195   char index[20];
01196   double tempdouble;
01197   int size = 3;
01198 
01199   if (argc != 2)
01200     {
01201       Tcl_AppendResult (interp, "wrong # args: should be \"",
01202                         argv[0], " arrayname\"", (char *) NULL);
01203       return TCL_ERROR;
01204     }
01205   array = argv[1];
01206 
01207   /* Read input image array(inimg,addr) */
01208   tclarrayname = Tcl_NewStringObj (array, -1);
01209   tclindexname = Tcl_NewStringObj ("inimg,addr", -1);
01210   if (tclobj =
01211       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01212                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01213     {
01214       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01215       if (strlen <= 0)
01216         return TCL_ERROR;
01217       sscanf (tempstr, "%x", &inimgaddr);
01218       inimg = (IMAGE *) inimgaddr;
01219     }
01220   else
01221     {
01222       return TCL_ERROR;
01223     }
01224   Tcl_DecrRefCount (tclarrayname);
01225   Tcl_DecrRefCount (tclindexname);
01226 
01227   /* Read the output image 1 name */
01228   tclarrayname = Tcl_NewStringObj (array, -1);
01229   tclindexname = Tcl_NewStringObj ("magname", -1);
01230   if (tclobj =
01231       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01232                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01233     {
01234       magname = Tcl_GetStringFromObj (tclobj, &strlen);
01235       if (strlen <= 0)
01236         return TCL_ERROR;
01237     }
01238   else
01239     {
01240       return TCL_ERROR;
01241     }
01242   Tcl_DecrRefCount (tclarrayname);
01243   Tcl_DecrRefCount (tclindexname);
01244 
01245   /* Read the output image 2 name */
01246   tclarrayname = Tcl_NewStringObj (array, -1);
01247   tclindexname = Tcl_NewStringObj ("dirname", -1);
01248   if (tclobj =
01249       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01250                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01251     {
01252       dirname = Tcl_GetStringFromObj (tclobj, &strlen);
01253       if (strlen <= 0)
01254         return TCL_ERROR;
01255     }
01256   else
01257     {
01258       return TCL_ERROR;
01259     }
01260   Tcl_DecrRefCount (tclarrayname);
01261   Tcl_DecrRefCount (tclindexname);
01262 
01263   for (n = 0, j = 0; j < 3; j++)
01264     {
01265       for (k = 0; k < 3; k++)
01266         {
01267           /* Read the input PIXEL array(hmask,j,k) */
01268           sprintf (index, "hmask,%d,%d", j, k);
01269           tclarrayname = Tcl_NewStringObj (array, -1);
01270           tclindexname = Tcl_NewStringObj (index, -1);
01271           if (tclobj =
01272               Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01273                               TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01274             {
01275               if (Tcl_GetDoubleFromObj (interp, tclobj, &tempdouble) ==
01276                   TCL_ERROR)
01277                 return TCL_ERROR;
01278               hpsf[n] = (PIXEL) tempdouble;
01279             }
01280           else
01281             {
01282               return TCL_ERROR;
01283             }
01284           Tcl_DecrRefCount (tclarrayname);
01285           Tcl_DecrRefCount (tclindexname);
01286 
01287           /* Read the input PIXEL array(vmask,j,k) */
01288           sprintf (index, "vmask,%d,%d", j, k);
01289           tclarrayname = Tcl_NewStringObj (array, -1);
01290           tclindexname = Tcl_NewStringObj (index, -1);
01291           if (tclobj =
01292               Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01293                               TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01294             {
01295               if (Tcl_GetDoubleFromObj (interp, tclobj, &tempdouble) ==
01296                   TCL_ERROR)
01297                 return TCL_ERROR;
01298               vpsf[n++] = (PIXEL) tempdouble;
01299             }
01300           else
01301             {
01302               return TCL_ERROR;
01303             }
01304           Tcl_DecrRefCount (tclarrayname);
01305           Tcl_DecrRefCount (tclindexname);
01306         }
01307     }
01308 
01309   GRADIENT (inimg, vpsf, hpsf, size, &magimg, &dirimg);
01310 
01311   if (CHECKIMG (magimg))
01312     sprintf (magimg->text, "%s", magname);
01313   magimgaddr = (int) magimg;
01314 
01315   if (CHECKIMG (dirimg))
01316     sprintf (dirimg->text, "%s", dirname);
01317   dirimgaddr = (int) dirimg;
01318 
01319   sprintf (msg, "%x %x", magimgaddr, dirimgaddr);
01320   Tcl_SetResult (interp, msg, TCL_VOLATILE);
01321 
01322   return TCL_OK;
01323 }
01324 
01325 /*-Copyright Information------------------------------------------------------*/
01326 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
01327 /*----------------------------------------------------------------------------*/
01328 /*-General Information--------------------------------------------------------*/
01329 /*                                                                            */
01330 /*   This procedure provides an interface to the SADIE function               */
01331 /*   GRADIENT from Tcl/Tk.  It expects a tcl global array                     */
01332 /*   with these indices to exist:                                             */
01333 /*      array(inimg,addr)         --  SADIE image address                     */
01334 /*      array(himg,addr)          --  SADIE image address                     */
01335 /*      array(vimg,addr)          --  SADIE image address                     */
01336 /*      array(magname)            --  char*                                   */
01337 /*      array(dirname)            --  char*                                   */
01338 /*                                                                            */
01339 /*----------------------------------------------------------------------------*/
01340 /*-Interface Information------------------------------------------------------*/
01341 int
01342 Sadie_Filter_ImageGradCmd (ClientData client_data, Tcl_Interp * interp,
01343                            int argc, char *argv[])
01344 {
01345   short i, j, k, n;
01346   Tcl_Obj *tclobj = NULL;
01347   Tcl_Obj *tclarrayname = NULL;
01348   Tcl_Obj *tclindexname = NULL;
01349   char msg[SLEN];
01350   char *array = NULL;
01351   char *tempstr = NULL;
01352   int strlen;
01353   int normalize, lines, pix;
01354   PIXEL *hpsf = NULL, *vpsf = NULL;
01355   int inimgaddr, himgaddr, vimgaddr;
01356   IMAGE *inimg = NULL, *himg = NULL, *vimg = NULL;
01357   int magimgaddr, dirimgaddr;
01358   IMAGE *magimg = NULL, *dirimg = NULL;
01359   char *magname = NULL, *dirname = NULL;
01360   int size;
01361 
01362   if (argc != 2)
01363     {
01364       Tcl_AppendResult (interp, "wrong # args: should be \"",
01365                         argv[0], " arrayname\"", (char *) NULL);
01366       return TCL_ERROR;
01367     }
01368   array = argv[1];
01369 
01370   /* Read input image array(inimg,addr) */
01371   tclarrayname = Tcl_NewStringObj (array, -1);
01372   tclindexname = Tcl_NewStringObj ("inimg,addr", -1);
01373   if (tclobj =
01374       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01375                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01376     {
01377       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01378       if (strlen <= 0)
01379         return TCL_ERROR;
01380       sscanf (tempstr, "%x", &inimgaddr);
01381       inimg = (IMAGE *) inimgaddr;
01382     }
01383   else
01384     {
01385       return TCL_ERROR;
01386     }
01387   Tcl_DecrRefCount (tclarrayname);
01388   Tcl_DecrRefCount (tclindexname);
01389 
01390   /* Read input image array(himg,addr) */
01391   tclarrayname = Tcl_NewStringObj (array, -1);
01392   tclindexname = Tcl_NewStringObj ("himg,addr", -1);
01393   if (tclobj =
01394       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01395                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01396     {
01397       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01398       if (strlen <= 0)
01399         return TCL_ERROR;
01400       sscanf (tempstr, "%x", &himgaddr);
01401       himg = (IMAGE *) himgaddr;
01402     }
01403   else
01404     {
01405       return TCL_ERROR;
01406     }
01407   Tcl_DecrRefCount (tclarrayname);
01408   Tcl_DecrRefCount (tclindexname);
01409 
01410   /* Read input image array(vimg,addr) */
01411   tclarrayname = Tcl_NewStringObj (array, -1);
01412   tclindexname = Tcl_NewStringObj ("vimg,addr", -1);
01413   if (tclobj =
01414       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01415                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01416     {
01417       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01418       if (strlen <= 0)
01419         return TCL_ERROR;
01420       sscanf (tempstr, "%x", &vimgaddr);
01421       vimg = (IMAGE *) vimgaddr;
01422     }
01423   else
01424     {
01425       return TCL_ERROR;
01426     }
01427   Tcl_DecrRefCount (tclarrayname);
01428   Tcl_DecrRefCount (tclindexname);
01429 
01430   /* Read the output image 1 name */
01431   tclarrayname = Tcl_NewStringObj (array, -1);
01432   tclindexname = Tcl_NewStringObj ("magname", -1);
01433   if (tclobj =
01434       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01435                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01436     {
01437       magname = Tcl_GetStringFromObj (tclobj, &strlen);
01438       if (strlen <= 0)
01439         return TCL_ERROR;
01440     }
01441   else
01442     {
01443       return TCL_ERROR;
01444     }
01445   Tcl_DecrRefCount (tclarrayname);
01446   Tcl_DecrRefCount (tclindexname);
01447 
01448   /* Read the output image 2 name */
01449   tclarrayname = Tcl_NewStringObj (array, -1);
01450   tclindexname = Tcl_NewStringObj ("dirname", -1);
01451   if (tclobj =
01452       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01453                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01454     {
01455       dirname = Tcl_GetStringFromObj (tclobj, &strlen);
01456       if (strlen <= 0)
01457         return TCL_ERROR;
01458     }
01459   else
01460     {
01461       return TCL_ERROR;
01462     }
01463   Tcl_DecrRefCount (tclarrayname);
01464   Tcl_DecrRefCount (tclindexname);
01465 
01466   size = himg->nlin;
01467   if (size != himg->npix)
01468     {
01469       Tcl_AppendResult (interp, "Image kernels must be square and equal in size.", (char *) NULL);      /*Sentinel. */
01470       return TCL_ERROR;
01471     }
01472   if (size != vimg->nlin)
01473     {
01474       Tcl_AppendResult (interp, "Image kernels must be square and equal in size.", (char *) NULL);      /*Sentinel. */
01475       return TCL_ERROR;
01476     }
01477   if (size != vimg->npix)
01478     {
01479       Tcl_AppendResult (interp, "Image kernels must be square and equal in size.", (char *) NULL);      /*Sentinel. */
01480       return TCL_ERROR;
01481     }
01482 
01483   lines = himg->nlin;
01484   pix = himg->npix;
01485 
01486   if (!(hpsf = (PIXEL *) malloc (lines * pix * sizeof (PIXEL))))
01487     {
01488       Tcl_AppendResult (interp, "Cannot allocate memory!", (char *) NULL);
01489       return TCL_ERROR;
01490     }
01491   if (!(vpsf = (PIXEL *) malloc (lines * pix * sizeof (PIXEL))))
01492     {
01493       Tcl_AppendResult (interp, "Cannot allocate memory!", (char *) NULL);
01494       return TCL_ERROR;
01495     }
01496   for (n = 0, j = 0; j < lines; j++)
01497     {
01498       for (k = 0; k < pix; k++)
01499         {
01500           hpsf[n] = himg->data[0][j][k];
01501           vpsf[n++] = vimg->data[0][j][k];
01502         }
01503     }
01504 
01505   GRADIENT (inimg, vpsf, hpsf, size, &magimg, &dirimg);
01506 
01507   if (CHECKIMG (magimg))
01508     sprintf (magimg->text, "%s", magname);
01509   magimgaddr = (int) magimg;
01510 
01511   if (CHECKIMG (dirimg))
01512     sprintf (dirimg->text, "%s", dirname);
01513   dirimgaddr = (int) dirimg;
01514 
01515   sprintf (msg, "%x %x", magimgaddr, dirimgaddr);
01516   Tcl_SetResult (interp, msg, TCL_VOLATILE);
01517 
01518   if (hpsf)
01519     free (hpsf);
01520   if (vpsf)
01521     free (vpsf);
01522 
01523   return TCL_OK;
01524 }
01525 
01526 /*-Copyright Information------------------------------------------------------*/
01527 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
01528 /*----------------------------------------------------------------------------*/
01529 /*-General Information--------------------------------------------------------*/
01530 /*                                                                            */
01531 /*   This procedure provides an interface to the SADIE function               */
01532 /*   WINDOW from Tcl/Tk.  It expects a tcl global array                       */
01533 /*   with these indices to exist:                                             */
01534 /*      array(inimg,addr)         --  SADIE image address                     */
01535 /*      array(lines)              --  int                                     */
01536 /*      array(pix)                --  int                                     */
01537 /*      array(outname)            --  char*                                   */
01538 /*                                                                            */
01539 /*----------------------------------------------------------------------------*/
01540 /*-Interface Information------------------------------------------------------*/
01541 int
01542 Sadie_Filter_VarMapCmd (ClientData client_data, Tcl_Interp * interp, int argc,
01543                         char *argv[])
01544 {
01545   Tcl_Obj *tclobj = NULL;
01546   Tcl_Obj *tclarrayname = NULL;
01547   Tcl_Obj *tclindexname = NULL;
01548   char msg[SLEN];
01549   char *array = NULL;
01550   char *tempstr = NULL;
01551   int strlen;
01552   int inimgaddr;
01553   IMAGE *inimg = NULL;
01554   int outimgaddr;
01555   IMAGE *outimg = NULL;
01556   char *outname = NULL;
01557   int lines, pix;
01558 
01559   if (argc != 2)
01560     {
01561       Tcl_AppendResult (interp, "wrong # args: should be \"",
01562                         argv[0], " arrayname\"", (char *) NULL);
01563       return TCL_ERROR;
01564     }
01565   array = argv[1];
01566 
01567   /* Read input image array(inimg,addr) */
01568   tclarrayname = Tcl_NewStringObj (array, -1);
01569   tclindexname = Tcl_NewStringObj ("inimg,addr", -1);
01570   if (tclobj =
01571       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01572                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01573     {
01574       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01575       if (strlen <= 0)
01576         return TCL_ERROR;
01577       sscanf (tempstr, "%x", &inimgaddr);
01578       inimg = (IMAGE *) inimgaddr;
01579     }
01580   else
01581     {
01582       return TCL_ERROR;
01583     }
01584   Tcl_DecrRefCount (tclarrayname);
01585   Tcl_DecrRefCount (tclindexname);
01586 
01587   /* Read the input integer array(lines) */
01588   tclarrayname = Tcl_NewStringObj (array, -1);
01589   tclindexname = Tcl_NewStringObj ("lines", -1);
01590   if (tclobj =
01591       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01592                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01593     {
01594       if (Tcl_GetIntFromObj (interp, tclobj, &lines) == TCL_ERROR)
01595         return TCL_ERROR;
01596     }
01597   else
01598     {
01599       return TCL_ERROR;
01600     }
01601   Tcl_DecrRefCount (tclarrayname);
01602   Tcl_DecrRefCount (tclindexname);
01603 
01604   /* Read the input integer array(pix) */
01605   tclarrayname = Tcl_NewStringObj (array, -1);
01606   tclindexname = Tcl_NewStringObj ("pix", -1);
01607   if (tclobj =
01608       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01609                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01610     {
01611       if (Tcl_GetIntFromObj (interp, tclobj, &pix) == TCL_ERROR)
01612         return TCL_ERROR;
01613     }
01614   else
01615     {
01616       return TCL_ERROR;
01617     }
01618   Tcl_DecrRefCount (tclarrayname);
01619   Tcl_DecrRefCount (tclindexname);
01620 
01621   /* Read the output image 1 name */
01622   tclarrayname = Tcl_NewStringObj (array, -1);
01623   tclindexname = Tcl_NewStringObj ("outname", -1);
01624   if (tclobj =
01625       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01626                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01627     {
01628       outname = Tcl_GetStringFromObj (tclobj, &strlen);
01629       if (strlen <= 0)
01630         return TCL_ERROR;
01631     }
01632   else
01633     {
01634       return TCL_ERROR;
01635     }
01636   Tcl_DecrRefCount (tclarrayname);
01637   Tcl_DecrRefCount (tclindexname);
01638 
01639   WINDOW (inimg, WTFVAR, lines, pix, &outimg);
01640 
01641   if (CHECKIMG (outimg))
01642     sprintf (outimg->text, "%s", outname);
01643   outimgaddr = (int) outimg;
01644 
01645   sprintf (msg, "%x", outimgaddr);
01646   Tcl_SetResult (interp, msg, TCL_VOLATILE);
01647 
01648   return TCL_OK;
01649 }
01650 
01651 /*-Copyright Information------------------------------------------------------*/
01652 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
01653 /*----------------------------------------------------------------------------*/
01654 /*-General Information--------------------------------------------------------*/
01655 /*                                                                            */
01656 /*   This procedure provides an interface to the SADIE function               */
01657 /*   WINDOW from Tcl/Tk.  It expects a tcl global array                       */
01658 /*   with these indices to exist:                                             */
01659 /*      array(inimg,addr)         --  SADIE image address                     */
01660 /*      array(lines)              --  int                                     */
01661 /*      array(pix)                --  int                                     */
01662 /*      array(outname)            --  char*                                   */
01663 /*                                                                            */
01664 /*----------------------------------------------------------------------------*/
01665 /*-Interface Information------------------------------------------------------*/
01666 int
01667 Sadie_Filter_DivMapCmd (ClientData client_data, Tcl_Interp * interp, int argc,
01668                         char *argv[])
01669 {
01670   Tcl_Obj *tclobj = NULL;
01671   Tcl_Obj *tclarrayname = NULL;
01672   Tcl_Obj *tclindexname = NULL;
01673   char msg[SLEN];
01674   char *array = NULL;
01675   char *tempstr = NULL;
01676   int strlen;
01677   int inimgaddr;
01678   IMAGE *inimg = NULL;
01679   int outimgaddr;
01680   IMAGE *outimg = NULL;
01681   char *outname = NULL;
01682   int lines, pix;
01683 
01684   if (argc != 2)
01685     {
01686       Tcl_AppendResult (interp, "wrong # args: should be \"",
01687                         argv[0], " arrayname\"", (char *) NULL);
01688       return TCL_ERROR;
01689     }
01690   array = argv[1];
01691 
01692   /* Read input image array(inimg,addr) */
01693   tclarrayname = Tcl_NewStringObj (array, -1);
01694   tclindexname = Tcl_NewStringObj ("inimg,addr", -1);
01695   if (tclobj =
01696       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01697                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01698     {
01699       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01700       if (strlen <= 0)
01701         return TCL_ERROR;
01702       sscanf (tempstr, "%x", &inimgaddr);
01703       inimg = (IMAGE *) inimgaddr;
01704     }
01705   else
01706     {
01707       return TCL_ERROR;
01708     }
01709   Tcl_DecrRefCount (tclarrayname);
01710   Tcl_DecrRefCount (tclindexname);
01711 
01712   /* Read the input integer array(lines) */
01713   tclarrayname = Tcl_NewStringObj (array, -1);
01714   tclindexname = Tcl_NewStringObj ("lines", -1);
01715   if (tclobj =
01716       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01717                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01718     {
01719       if (Tcl_GetIntFromObj (interp, tclobj, &lines) == TCL_ERROR)
01720         return TCL_ERROR;
01721     }
01722   else
01723     {
01724       return TCL_ERROR;
01725     }
01726   Tcl_DecrRefCount (tclarrayname);
01727   Tcl_DecrRefCount (tclindexname);
01728 
01729   /* Read the input integer array(pix) */
01730   tclarrayname = Tcl_NewStringObj (array, -1);
01731   tclindexname = Tcl_NewStringObj ("pix", -1);
01732   if (tclobj =
01733       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01734                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01735     {
01736       if (Tcl_GetIntFromObj (interp, tclobj, &pix) == TCL_ERROR)
01737         return TCL_ERROR;
01738     }
01739   else
01740     {
01741       return TCL_ERROR;
01742     }
01743   Tcl_DecrRefCount (tclarrayname);
01744   Tcl_DecrRefCount (tclindexname);
01745 
01746   /* Read the output image 1 name */
01747   tclarrayname = Tcl_NewStringObj (array, -1);
01748   tclindexname = Tcl_NewStringObj ("outname", -1);
01749   if (tclobj =
01750       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01751                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01752     {
01753       outname = Tcl_GetStringFromObj (tclobj, &strlen);
01754       if (strlen <= 0)
01755         return TCL_ERROR;
01756     }
01757   else
01758     {
01759       return TCL_ERROR;
01760     }
01761   Tcl_DecrRefCount (tclarrayname);
01762   Tcl_DecrRefCount (tclindexname);
01763 
01764   WINDOW (inimg, WTFDIVER, lines, pix, &outimg);
01765 
01766   if (CHECKIMG (outimg))
01767     sprintf (outimg->text, "%s", outname);
01768   outimgaddr = (int) outimg;
01769 
01770   sprintf (msg, "%x", outimgaddr);
01771   Tcl_SetResult (interp, msg, TCL_VOLATILE);
01772 
01773   return TCL_OK;
01774 }
01775 
01776 /*-Copyright Information------------------------------------------------------*/
01777 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
01778 /*----------------------------------------------------------------------------*/
01779 /*-General Information--------------------------------------------------------*/
01780 /*                                                                            */
01781 /*   This procedure provides an interface to the SADIE function               */
01782 /*   WINDOW from Tcl/Tk.  It expects a tcl global array                       */
01783 /*   with these indices to exist:                                             */
01784 /*      array(inimg,addr)         --  SADIE image address                     */
01785 /*      array(lines)              --  int                                     */
01786 /*      array(pix)                --  int                                     */
01787 /*      array(weight)             --  double                                  */
01788 /*      array(outname)            --  char*                                   */
01789 /*                                                                            */
01790 /*----------------------------------------------------------------------------*/
01791 /*-Interface Information------------------------------------------------------*/
01792 int
01793 Sadie_Filter_MajFiltCmd (ClientData client_data, Tcl_Interp * interp,
01794                          int argc, char *argv[])
01795 {
01796   Tcl_Obj *tclobj = NULL;
01797   Tcl_Obj *tclarrayname = NULL;
01798   Tcl_Obj *tclindexname = NULL;
01799   char msg[SLEN];
01800   char *array = NULL;
01801   char *tempstr = NULL;
01802   int strlen;
01803   int inimgaddr;
01804   IMAGE *inimg = NULL;
01805   int outimgaddr;
01806   IMAGE *outimg = NULL;
01807   char *outname = NULL;
01808   int lines, pix;
01809 
01810   if (argc != 2)
01811     {
01812       Tcl_AppendResult (interp, "wrong # args: should be \"",
01813                         argv[0], " arrayname\"", (char *) NULL);
01814       return TCL_ERROR;
01815     }
01816   array = argv[1];
01817 
01818   /* Read input image array(inimg,addr) */
01819   tclarrayname = Tcl_NewStringObj (array, -1);
01820   tclindexname = Tcl_NewStringObj ("inimg,addr", -1);
01821   if (tclobj =
01822       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01823                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01824     {
01825       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01826       if (strlen <= 0)
01827         return TCL_ERROR;
01828       sscanf (tempstr, "%x", &inimgaddr);
01829       inimg = (IMAGE *) inimgaddr;
01830     }
01831   else
01832     {
01833       return TCL_ERROR;
01834     }
01835   Tcl_DecrRefCount (tclarrayname);
01836   Tcl_DecrRefCount (tclindexname);
01837 
01838   /* Read the input integer array(lines) */
01839   tclarrayname = Tcl_NewStringObj (array, -1);
01840   tclindexname = Tcl_NewStringObj ("lines", -1);
01841   if (tclobj =
01842       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01843                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01844     {
01845       if (Tcl_GetIntFromObj (interp, tclobj, &lines) == TCL_ERROR)
01846         return TCL_ERROR;
01847     }
01848   else
01849     {
01850       return TCL_ERROR;
01851     }
01852   Tcl_DecrRefCount (tclarrayname);
01853   Tcl_DecrRefCount (tclindexname);
01854 
01855   /* Read the input integer array(pix) */
01856   tclarrayname = Tcl_NewStringObj (array, -1);
01857   tclindexname = Tcl_NewStringObj ("pix", -1);
01858   if (tclobj =
01859       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01860                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01861     {
01862       if (Tcl_GetIntFromObj (interp, tclobj, &pix) == TCL_ERROR)
01863         return TCL_ERROR;
01864     }
01865   else
01866     {
01867       return TCL_ERROR;
01868     }
01869   Tcl_DecrRefCount (tclarrayname);
01870   Tcl_DecrRefCount (tclindexname);
01871 
01872   /* Read the input double array(weight) */
01873   tclarrayname = Tcl_NewStringObj (array, -1);
01874   tclindexname = Tcl_NewStringObj ("weight", -1);
01875   if (tclobj =
01876       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01877                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01878     {
01879       if (Tcl_GetDoubleFromObj (interp, tclobj, &weight) == TCL_ERROR)
01880         return TCL_ERROR;
01881     }
01882   else
01883     {
01884       return TCL_ERROR;
01885     }
01886   Tcl_DecrRefCount (tclarrayname);
01887   Tcl_DecrRefCount (tclindexname);
01888 
01889   /* Read the output image 1 name */
01890   tclarrayname = Tcl_NewStringObj (array, -1);
01891   tclindexname = Tcl_NewStringObj ("outname", -1);
01892   if (tclobj =
01893       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01894                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01895     {
01896       outname = Tcl_GetStringFromObj (tclobj, &strlen);
01897       if (strlen <= 0)
01898         return TCL_ERROR;
01899     }
01900   else
01901     {
01902       return TCL_ERROR;
01903     }
01904   Tcl_DecrRefCount (tclarrayname);
01905   Tcl_DecrRefCount (tclindexname);
01906 
01907   RANGE (inimg);
01908   nlev = (short) inimg->gmax - (short) inimg->gmin + 1;
01909   gmin = inimg->gmin;
01910   gmax = inimg->gmax;
01911 
01912   count = NULL;
01913   if (!(count = (double *) malloc ((int) nlev * sizeof (double))))
01914     {
01915       Tcl_AppendResult (interp, "Cannot allocate memory!", (char *) NULL);
01916       return TCL_ERROR;
01917     }
01918 
01919   WINDOW (inimg, WTFMAJ, lines, pix, &outimg);
01920 
01921   if (count)
01922     free (count);
01923 
01924   if (CHECKIMG (outimg))
01925     sprintf (outimg->text, "%s", outname);
01926   outimgaddr = (int) outimg;
01927 
01928   sprintf (msg, "%x", outimgaddr);
01929   Tcl_SetResult (interp, msg, TCL_VOLATILE);
01930 
01931   return TCL_OK;
01932 }
01933 
01934 /*-Copyright Information------------------------------------------------------*/
01935 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
01936 /*----------------------------------------------------------------------------*/
01937 /*-General Information--------------------------------------------------------*/
01938 /*                                                                            */
01939 /*   This procedure provides an interface to the SADIE function               */
01940 /*   MEDIAN from Tcl/Tk.  It expects a tcl global array                       */
01941 /*   with these indices to exist:                                             */
01942 /*      array(inimg,addr)         --  SADIE image address                     */
01943 /*      array(lines)              --  int                                     */
01944 /*      array(pix)                --  int                                     */
01945 /*      array(outname)            --  char*                                   */
01946 /*                                                                            */
01947 /*----------------------------------------------------------------------------*/
01948 /*-Interface Information------------------------------------------------------*/
01949 int
01950 Sadie_Filter_MedFiltCmd (ClientData client_data, Tcl_Interp * interp,
01951                          int argc, char *argv[])
01952 {
01953   Tcl_Obj *tclobj = NULL;
01954   Tcl_Obj *tclarrayname = NULL;
01955   Tcl_Obj *tclindexname = NULL;
01956   char msg[SLEN];
01957   char *array = NULL;
01958   char *tempstr = NULL;
01959   int strlen;
01960   int inimgaddr;
01961   IMAGE *inimg = NULL;
01962   int outimgaddr;
01963   IMAGE *outimg = NULL;
01964   char *outname = NULL;
01965   int lines, pix;
01966 
01967   if (argc != 2)
01968     {
01969       Tcl_AppendResult (interp, "wrong # args: should be \"",
01970                         argv[0], " arrayname\"", (char *) NULL);
01971       return TCL_ERROR;
01972     }
01973   array = argv[1];
01974 
01975   /* Read input image array(inimg,addr) */
01976   tclarrayname = Tcl_NewStringObj (array, -1);
01977   tclindexname = Tcl_NewStringObj ("inimg,addr", -1);
01978   if (tclobj =
01979       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
01980                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01981     {
01982       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01983       if (strlen <= 0)
01984         return TCL_ERROR;
01985       sscanf (tempstr, "%x", &inimgaddr);
01986       inimg = (IMAGE *) inimgaddr;
01987     }
01988   else
01989     {
01990       return TCL_ERROR;
01991     }
01992   Tcl_DecrRefCount (tclarrayname);
01993   Tcl_DecrRefCount (tclindexname);
01994 
01995   /* Read the input integer array(lines) */
01996   tclarrayname = Tcl_NewStringObj (array, -1);
01997   tclindexname = Tcl_NewStringObj ("lines", -1);
01998   if (tclobj =
01999       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02000                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02001     {
02002       if (Tcl_GetIntFromObj (interp, tclobj, &lines) == TCL_ERROR)
02003         return TCL_ERROR;
02004     }
02005   else
02006     {
02007       return TCL_ERROR;
02008     }
02009   Tcl_DecrRefCount (tclarrayname);
02010   Tcl_DecrRefCount (tclindexname);
02011 
02012   /* Read the input integer array(pix) */
02013   tclarrayname = Tcl_NewStringObj (array, -1);
02014   tclindexname = Tcl_NewStringObj ("pix", -1);
02015   if (tclobj =
02016       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02017                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02018     {
02019       if (Tcl_GetIntFromObj (interp, tclobj, &pix) == TCL_ERROR)
02020         return TCL_ERROR;
02021     }
02022   else
02023     {
02024       return TCL_ERROR;
02025     }
02026   Tcl_DecrRefCount (tclarrayname);
02027   Tcl_DecrRefCount (tclindexname);
02028 
02029   /* Read the output image 1 name */
02030   tclarrayname = Tcl_NewStringObj (array, -1);
02031   tclindexname = Tcl_NewStringObj ("outname", -1);
02032   if (tclobj =
02033       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02034                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02035     {
02036       outname = Tcl_GetStringFromObj (tclobj, &strlen);
02037       if (strlen <= 0)
02038         return TCL_ERROR;
02039     }
02040   else
02041     {
02042       return TCL_ERROR;
02043     }
02044   Tcl_DecrRefCount (tclarrayname);
02045   Tcl_DecrRefCount (tclindexname);
02046 
02047   MEDIAN (inimg, lines, pix, &outimg);
02048 
02049   if (CHECKIMG (outimg))
02050     sprintf (outimg->text, "%s", outname);
02051   outimgaddr = (int) outimg;
02052 
02053   sprintf (msg, "%x", outimgaddr);
02054   Tcl_SetResult (interp, msg, TCL_VOLATILE);
02055 
02056   return TCL_OK;
02057 }
02058 
02059 /*-Copyright Information------------------------------------------------------*/
02060 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
02061 /*----------------------------------------------------------------------------*/
02062 /*-General Information--------------------------------------------------------*/
02063 /*                                                                            */
02064 /*   This procedure provides an interface to the SADIE function               */
02065 /*   WINDOW from Tcl/Tk.  It expects a tcl global array                       */
02066 /*   with these indices to exist:                                             */
02067 /*      array(inimg,addr)         --  SADIE image address                     */
02068 /*      array(lines)              --  int                                     */
02069 /*      array(pix)                --  int                                     */
02070 /*      array(outname)            --  char*                                   */
02071 /*                                                                            */
02072 /*----------------------------------------------------------------------------*/
02073 /*-Interface Information------------------------------------------------------*/
02074 int
02075 Sadie_Filter_MinFiltCmd (ClientData client_data, Tcl_Interp * interp,
02076                          int argc, char *argv[])
02077 {
02078   Tcl_Obj *tclobj = NULL;
02079   Tcl_Obj *tclarrayname = NULL;
02080   Tcl_Obj *tclindexname = NULL;
02081   char msg[SLEN];
02082   char *array = NULL;
02083   char *tempstr = NULL;
02084   int strlen;
02085   int inimgaddr;
02086   IMAGE *inimg = NULL;
02087   int outimgaddr;
02088   IMAGE *outimg = NULL;
02089   char *outname = NULL;
02090   int lines, pix;
02091 
02092   if (argc != 2)
02093     {
02094       Tcl_AppendResult (interp, "wrong # args: should be \"",
02095                         argv[0], " arrayname\"", (char *) NULL);
02096       return TCL_ERROR;
02097     }
02098   array = argv[1];
02099 
02100   /* Read input image array(inimg,addr) */
02101   tclarrayname = Tcl_NewStringObj (array, -1);
02102   tclindexname = Tcl_NewStringObj ("inimg,addr", -1);
02103   if (tclobj =
02104       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02105                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02106     {
02107       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
02108       if (strlen <= 0)
02109         return TCL_ERROR;
02110       sscanf (tempstr, "%x", &inimgaddr);
02111       inimg = (IMAGE *) inimgaddr;
02112     }
02113   else
02114     {
02115       return TCL_ERROR;
02116     }
02117   Tcl_DecrRefCount (tclarrayname);
02118   Tcl_DecrRefCount (tclindexname);
02119 
02120   /* Read the input integer array(lines) */
02121   tclarrayname = Tcl_NewStringObj (array, -1);
02122   tclindexname = Tcl_NewStringObj ("lines", -1);
02123   if (tclobj =
02124       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02125                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02126     {
02127       if (Tcl_GetIntFromObj (interp, tclobj, &lines) == TCL_ERROR)
02128         return TCL_ERROR;
02129     }
02130   else
02131     {
02132       return TCL_ERROR;
02133     }
02134   Tcl_DecrRefCount (tclarrayname);
02135   Tcl_DecrRefCount (tclindexname);
02136 
02137   /* Read the input integer array(pix) */
02138   tclarrayname = Tcl_NewStringObj (array, -1);
02139   tclindexname = Tcl_NewStringObj ("pix", -1);
02140   if (tclobj =
02141       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02142                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02143     {
02144       if (Tcl_GetIntFromObj (interp, tclobj, &pix) == TCL_ERROR)
02145         return TCL_ERROR;
02146     }
02147   else
02148     {
02149       return TCL_ERROR;
02150     }
02151   Tcl_DecrRefCount (tclarrayname);
02152   Tcl_DecrRefCount (tclindexname);
02153 
02154   /* Read the output image 1 name */
02155   tclarrayname = Tcl_NewStringObj (array, -1);
02156   tclindexname = Tcl_NewStringObj ("outname", -1);
02157   if (tclobj =
02158       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02159                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02160     {
02161       outname = Tcl_GetStringFromObj (tclobj, &strlen);
02162       if (strlen <= 0)
02163         return TCL_ERROR;
02164     }
02165   else
02166     {
02167       return TCL_ERROR;
02168     }
02169   Tcl_DecrRefCount (tclarrayname);
02170   Tcl_DecrRefCount (tclindexname);
02171 
02172   WINDOW (inimg, WTFMIN, lines, pix, &outimg);
02173 
02174   if (CHECKIMG (outimg))
02175     sprintf (outimg->text, "%s", outname);
02176   outimgaddr = (int) outimg;
02177 
02178   sprintf (msg, "%x", outimgaddr);
02179   Tcl_SetResult (interp, msg, TCL_VOLATILE);
02180 
02181   return TCL_OK;
02182 }
02183 
02184 /*-Copyright Information------------------------------------------------------*/
02185 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
02186 /*----------------------------------------------------------------------------*/
02187 /*-General Information--------------------------------------------------------*/
02188 /*                                                                            */
02189 /*   This procedure provides an interface to the SADIE function               */
02190 /*   WINDOW from Tcl/Tk.  It expects a tcl global array                       */
02191 /*   with these indices to exist:                                             */
02192 /*      array(inimg,addr)         --  SADIE image address                     */
02193 /*      array(lines)              --  int                                     */
02194 /*      array(pix)                --  int                                     */
02195 /*      array(outname)            --  char*                                   */
02196 /*                                                                            */
02197 /*----------------------------------------------------------------------------*/
02198 /*-Interface Information------------------------------------------------------*/
02199 int
02200 Sadie_Filter_MaxFiltCmd (ClientData client_data, Tcl_Interp * interp,
02201                          int argc, char *argv[])
02202 {
02203   Tcl_Obj *tclobj = NULL;
02204   Tcl_Obj *tclarrayname = NULL;
02205   Tcl_Obj *tclindexname = NULL;
02206   char msg[SLEN];
02207   char *array = NULL;
02208   char *tempstr = NULL;
02209   int strlen;
02210   int inimgaddr;
02211   IMAGE *inimg = NULL;
02212   int outimgaddr;
02213   IMAGE *outimg = NULL;
02214   char *outname = NULL;
02215   int lines, pix;
02216 
02217   if (argc != 2)
02218     {
02219       Tcl_AppendResult (interp, "wrong # args: should be \"",
02220                         argv[0], " arrayname\"", (char *) NULL);
02221       return TCL_ERROR;
02222     }
02223   array = argv[1];
02224 
02225   /* Read input image array(inimg,addr) */
02226   tclarrayname = Tcl_NewStringObj (array, -1);
02227   tclindexname = Tcl_NewStringObj ("inimg,addr", -1);
02228   if (tclobj =
02229       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02230                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02231     {
02232       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
02233       if (strlen <= 0)
02234         return TCL_ERROR;
02235       sscanf (tempstr, "%x", &inimgaddr);
02236       inimg = (IMAGE *) inimgaddr;
02237     }
02238   else
02239     {
02240       return TCL_ERROR;
02241     }
02242   Tcl_DecrRefCount (tclarrayname);
02243   Tcl_DecrRefCount (tclindexname);
02244 
02245   /* Read the input integer array(lines) */
02246   tclarrayname = Tcl_NewStringObj (array, -1);
02247   tclindexname = Tcl_NewStringObj ("lines", -1);
02248   if (tclobj =
02249       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02250                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02251     {
02252       if (Tcl_GetIntFromObj (interp, tclobj, &lines) == TCL_ERROR)
02253         return TCL_ERROR;
02254     }
02255   else
02256     {
02257       return TCL_ERROR;
02258     }
02259   Tcl_DecrRefCount (tclarrayname);
02260   Tcl_DecrRefCount (tclindexname);
02261 
02262   /* Read the input integer array(pix) */
02263   tclarrayname = Tcl_NewStringObj (array, -1);
02264   tclindexname = Tcl_NewStringObj ("pix", -1);
02265   if (tclobj =
02266       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02267                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02268     {
02269       if (Tcl_GetIntFromObj (interp, tclobj, &pix) == TCL_ERROR)
02270         return TCL_ERROR;
02271     }
02272   else
02273     {
02274       return TCL_ERROR;
02275     }
02276   Tcl_DecrRefCount (tclarrayname);
02277   Tcl_DecrRefCount (tclindexname);
02278 
02279   /* Read the output image 1 name */
02280   tclarrayname = Tcl_NewStringObj (array, -1);
02281   tclindexname = Tcl_NewStringObj ("outname", -1);
02282   if (tclobj =
02283       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02284                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02285     {
02286       outname = Tcl_GetStringFromObj (tclobj, &strlen);
02287       if (strlen <= 0)
02288         return TCL_ERROR;
02289     }
02290   else
02291     {
02292       return TCL_ERROR;
02293     }
02294   Tcl_DecrRefCount (tclarrayname);
02295   Tcl_DecrRefCount (tclindexname);
02296 
02297   WINDOW (inimg, WTFMAX, lines, pix, &outimg);
02298 
02299   if (CHECKIMG (outimg))
02300     sprintf (outimg->text, "%s", outname);
02301   outimgaddr = (int) outimg;
02302 
02303   sprintf (msg, "%x", outimgaddr);
02304   Tcl_SetResult (interp, msg, TCL_VOLATILE);
02305 
02306   return TCL_OK;
02307 }
02308 
02309 /*-Copyright Information------------------------------------------------------*/
02310 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
02311 /*----------------------------------------------------------------------------*/
02312 /*-General Information--------------------------------------------------------*/
02313 /*                                                                            */
02314 /*   This procedure provides an interface to the SADIE function               */
02315 /*   WINDOW from Tcl/Tk.  It expects a tcl global array                       */
02316 /*   with these indices to exist:                                             */
02317 /*      array(inimg,addr)         --  SADIE image address                     */
02318 /*      array(lines)              --  int                                     */
02319 /*      array(pix)                --  int                                     */
02320 /*      array(size)               --  int                                     */
02321 /*      array(thresh)             --  PIXEL                                   */
02322 /*      array(outname)            --  char*                                   */
02323 /*                                                                            */
02324 /*----------------------------------------------------------------------------*/
02325 /*-Interface Information------------------------------------------------------*/
02326 int
02327 Sadie_Filter_CAvgFiltCmd (ClientData client_data, Tcl_Interp * interp,
02328                           int argc, char *argv[])
02329 {
02330   Tcl_Obj *tclobj = NULL;
02331   Tcl_Obj *tclarrayname = NULL;
02332   Tcl_Obj *tclindexname = NULL;
02333   char msg[SLEN];
02334   char *array = NULL;
02335   char *tempstr = NULL;
02336   int strlen;
02337   int inimgaddr;
02338   IMAGE *inimg = NULL;
02339   int outimgaddr;
02340   IMAGE *outimg = NULL;
02341   char *outname = NULL;
02342   int lines, pix, size;
02343   double tempdouble;
02344 
02345   if (argc != 2)
02346     {
02347       Tcl_AppendResult (interp, "wrong # args: should be \"",
02348                         argv[0], " arrayname\"", (char *) NULL);
02349       return TCL_ERROR;
02350     }
02351   array = argv[1];
02352 
02353   /* Read input image array(inimg,addr) */
02354   tclarrayname = Tcl_NewStringObj (array, -1);
02355   tclindexname = Tcl_NewStringObj ("inimg,addr", -1);
02356   if (tclobj =
02357       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02358                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02359     {
02360       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
02361       if (strlen <= 0)
02362         return TCL_ERROR;
02363       sscanf (tempstr, "%x", &inimgaddr);
02364       inimg = (IMAGE *) inimgaddr;
02365     }
02366   else
02367     {
02368       return TCL_ERROR;
02369     }
02370   Tcl_DecrRefCount (tclarrayname);
02371   Tcl_DecrRefCount (tclindexname);
02372 
02373   /* Read the input integer array(lines) */
02374   tclarrayname = Tcl_NewStringObj (array, -1);
02375   tclindexname = Tcl_NewStringObj ("lines", -1);
02376   if (tclobj =
02377       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02378                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02379     {
02380       if (Tcl_GetIntFromObj (interp, tclobj, &lines) == TCL_ERROR)
02381         return TCL_ERROR;
02382     }
02383   else
02384     {
02385       return TCL_ERROR;
02386     }
02387   Tcl_DecrRefCount (tclarrayname);
02388   Tcl_DecrRefCount (tclindexname);
02389 
02390   /* Read the input integer array(pix) */
02391   tclarrayname = Tcl_NewStringObj (array, -1);
02392   tclindexname = Tcl_NewStringObj ("pix", -1);
02393   if (tclobj =
02394       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02395                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02396     {
02397       if (Tcl_GetIntFromObj (interp, tclobj, &pix) == TCL_ERROR)
02398         return TCL_ERROR;
02399     }
02400   else
02401     {
02402       return TCL_ERROR;
02403     }
02404   Tcl_DecrRefCount (tclarrayname);
02405   Tcl_DecrRefCount (tclindexname);
02406 
02407   /* Read the input integer array(size) */
02408   tclarrayname = Tcl_NewStringObj (array, -1);
02409   tclindexname = Tcl_NewStringObj ("size", -1);
02410   if (tclobj =
02411       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02412                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02413     {
02414       if (Tcl_GetIntFromObj (interp, tclobj, &size) == TCL_ERROR)
02415         return TCL_ERROR;
02416       csize = (short) size;
02417     }
02418   else
02419     {
02420       return TCL_ERROR;
02421     }
02422   Tcl_DecrRefCount (tclarrayname);
02423   Tcl_DecrRefCount (tclindexname);
02424 
02425   /* Read the input PIXEL array(thresh) */
02426   tclarrayname = Tcl_NewStringObj (array, -1);
02427   tclindexname = Tcl_NewStringObj ("thresh", -1);
02428   if (tclobj =
02429       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02430                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02431     {
02432       if (Tcl_GetDoubleFromObj (interp, tclobj, &tempdouble) == TCL_ERROR)
02433         return TCL_ERROR;
02434       thresh = (PIXEL) tempdouble;
02435     }
02436   else
02437     {
02438       return TCL_ERROR;
02439     }
02440   Tcl_DecrRefCount (tclarrayname);
02441   Tcl_DecrRefCount (tclindexname);
02442 
02443   /* Read the output image 1 name */
02444   tclarrayname = Tcl_NewStringObj (array, -1);
02445   tclindexname = Tcl_NewStringObj ("outname", -1);
02446   if (tclobj =
02447       Tcl_ObjGetVar2 (interp, tclarrayname, tclindexname,
02448                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
02449     {
02450       outname = Tcl_GetStringFromObj (tclobj, &strlen);
02451       if (strlen <= 0)
02452         return TCL_ERROR;
02453     }
02454   else
02455     {
02456       return TCL_ERROR;
02457     }
02458   Tcl_DecrRefCount (tclarrayname);
02459   Tcl_DecrRefCount (tclindexname);
02460 
02461   WINDOW (inimg, WTFCAVG, lines, pix, &outimg);
02462 
02463   if (CHECKIMG (outimg))
02464     sprintf (outimg->text, "%s", outname);
02465   outimgaddr = (int) outimg;
02466 
02467   sprintf (msg, "%x", outimgaddr);
02468   Tcl_SetResult (interp, msg, TCL_VOLATILE);
02469 
02470   return TCL_OK;
02471 }
02472 
02473 /*-Copyright Information------------------------------------------------------*/
02474 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
02475 /*----------------------------------------------------------------------------*/
02476 /*-General Information--------------------------------------------------------*/
02477 /*                                                                            */
02478 /*   This procedure initializes the all of the procedures                     */
02479 /*   in this file by registering them with Tcl.                               */
02480 /*                                                                            */
02481 /*----------------------------------------------------------------------------*/
02482 /*-Interface Information------------------------------------------------------*/
02483 int
02484 Sadie_Filter_Init (Tcl_Interp * interp)
02485 {
02486   Tcl_CreateCommand (interp, "Sadie_Filter_PSpect", Sadie_Filter_PSpectCmd,
02487                      (ClientData) NULL, NULL);
02488   Tcl_CreateCommand (interp, "Sadie_Filter_FFTConv", Sadie_Filter_FFTConvCmd,
02489                      (ClientData) NULL, NULL);
02490   Tcl_CreateCommand (interp, "Sadie_Filter_FFTFilt", Sadie_Filter_FFTFiltCmd,
02491                      (ClientData) NULL, NULL);
02492   Tcl_CreateCommand (interp, "Sadie_Filter_FFT", Sadie_Filter_FFTCmd,
02493                      (ClientData) NULL, NULL);
02494   Tcl_CreateCommand (interp, "Sadie_Filter_FHT", Sadie_Filter_FHTCmd,
02495                      (ClientData) NULL, NULL);
02496   Tcl_CreateCommand (interp, "Sadie_Filter_MaskConv",
02497                      Sadie_Filter_MaskConvCmd, (ClientData) NULL, NULL);
02498   Tcl_CreateCommand (interp, "Sadie_Filter_ImageConv",
02499                      Sadie_Filter_ImageConvCmd, (ClientData) NULL, NULL);
02500   Tcl_CreateCommand (interp, "Sadie_Filter_LibGrad", Sadie_Filter_LibGradCmd,
02501                      (ClientData) NULL, NULL);
02502   Tcl_CreateCommand (interp, "Sadie_Filter_ImageGrad",
02503                      Sadie_Filter_ImageGradCmd, (ClientData) NULL, NULL);
02504   Tcl_CreateCommand (interp, "Sadie_Filter_MaskGrad",
02505                      Sadie_Filter_MaskGradCmd, (ClientData) NULL, NULL);
02506   Tcl_CreateCommand (interp, "Sadie_Filter_VarMap", Sadie_Filter_VarMapCmd,
02507                      (ClientData) NULL, NULL);
02508   Tcl_CreateCommand (interp, "Sadie_Filter_DivMap", Sadie_Filter_DivMapCmd,
02509                      (ClientData) NULL, NULL);
02510   Tcl_CreateCommand (interp, "Sadie_Filter_MajFilt", Sadie_Filter_MajFiltCmd,
02511                      (ClientData) NULL, NULL);
02512   Tcl_CreateCommand (interp, "Sadie_Filter_MedFilt", Sadie_Filter_MedFiltCmd,
02513                      (ClientData) NULL, NULL);
02514   Tcl_CreateCommand (interp, "Sadie_Filter_MinFilt", Sadie_Filter_MinFiltCmd,
02515                      (ClientData) NULL, NULL);
02516   Tcl_CreateCommand (interp, "Sadie_Filter_MaxFilt", Sadie_Filter_MaxFiltCmd,
02517                      (ClientData) NULL, NULL);
02518   Tcl_CreateCommand (interp, "Sadie_Filter_CAvgFilt",
02519                      Sadie_Filter_CAvgFiltCmd, (ClientData) NULL, NULL);
02520   return TCL_OK;
02521 }

Generated on Sun May 18 15:36:15 2003 for tclSadie by doxygen1.3