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

Generated on Wed Apr 9 08:56:12 2003 for TREES by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002