Main Page   Data Structures   File List   Data Fields   Globals  

Sadie_NewFunctions.c

Go to the documentation of this file.
00001 /*
00002 ##########################################
00003 # Sadie_NewFunctions.c -
00004 #   Set of routines for linking SADIE routines to create
00005 #   new images into tcl/tk.
00006 #
00007 # RCS: $Id: Sadie_NewFunctions.c,v 2.5 2000/08/08 22:54:32 giri Exp $ 
00008 # 
00009 # Digital Image Analysis Lab
00010 # Dept. of Electrical and Computer Engineering
00011 # University of Arizona
00012 ##########################################
00013 */
00014 
00015 #include <tcl.h>
00016 #include <tk.h>
00017 #include "sadie.h"
00018 
00019 /* RCS Indentification information */
00020 static char rcsid[] = "$Id: Sadie_NewFunctions.c,v 2.5 2000/08/08 22:54:32 giri Exp $";
00021 
00022 
00023 /*-Copyright Information------------------------------------------------------*/
00024 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00025 /*----------------------------------------------------------------------------*/
00026 /*-General Information--------------------------------------------------------*/
00027 /*                                                                            */
00028 /*   This procedure provides an interface to the SADIE function               */
00029 /*   SINEWAVE from Tcl/Tk.  It expects a tcl global array                     */
00030 /*   with these indices to exist:                                             */
00031 /*      array(lines)              --  int                                     */
00032 /*      array(pix)                --  int                                     */
00033 /*      array(period)             --  double                                  */
00034 /*      array(phase)              --  double                                  */
00035 /*      array(outname)            --  char*                                   */
00036 /*                                                                            */
00037 /*----------------------------------------------------------------------------*/
00038 /*-Interface Information------------------------------------------------------*/
00039 int Sadie_NewFunctions_SineWaveCmd(ClientData client_data, Tcl_Interp* interp, int argc, char *argv[])
00040 {
00041     Tcl_Obj* tclobj=NULL;
00042     Tcl_Obj* tclarrayname = NULL;
00043     Tcl_Obj* tclindexname = NULL;
00044     char msg[SLEN];
00045     char* array=NULL;
00046     char* tempstr=NULL;
00047     int strlen;
00048     int outimgaddr;
00049     IMAGE* outimg=NULL;
00050     char* outname=NULL;
00051     int lines, pix;
00052     double period, phase;
00053 
00054     if( argc != 2 ) {
00055         Tcl_AppendResult(interp,"wrong # args: should be \"",
00056         argv[0], " arrayname\"", (char *) NULL);
00057         return TCL_ERROR;
00058     }
00059     array=argv[1];
00060             
00061 
00062     /* Read the input integer array(lines) */
00063     tclarrayname = Tcl_NewStringObj(array,-1);
00064     tclindexname = Tcl_NewStringObj("lines",-1);
00065     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00066         if (Tcl_GetIntFromObj(interp,tclobj,&lines) == TCL_ERROR) return TCL_ERROR;
00067     } else {
00068         return TCL_ERROR;
00069     }
00070     Tcl_DecrRefCount(tclarrayname);
00071     Tcl_DecrRefCount(tclindexname);
00072                 
00073 
00074     /* Read the input integer array(pix) */
00075     tclarrayname = Tcl_NewStringObj(array,-1);
00076     tclindexname = Tcl_NewStringObj("pix",-1);
00077     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00078         if (Tcl_GetIntFromObj(interp,tclobj,&pix) == TCL_ERROR) return TCL_ERROR;
00079     } else {
00080         return TCL_ERROR;
00081     }
00082     Tcl_DecrRefCount(tclarrayname);
00083     Tcl_DecrRefCount(tclindexname);
00084                 
00085 
00086     /* Read the input double array(period) */
00087     tclarrayname = Tcl_NewStringObj(array,-1);
00088     tclindexname = Tcl_NewStringObj("period",-1);
00089     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00090         if (Tcl_GetDoubleFromObj(interp,tclobj,&period) == TCL_ERROR) return TCL_ERROR;
00091     } else {
00092         return TCL_ERROR;
00093     }
00094     Tcl_DecrRefCount(tclarrayname);
00095     Tcl_DecrRefCount(tclindexname);
00096                 
00097 
00098     /* Read the input double array(phase) */
00099     tclarrayname = Tcl_NewStringObj(array,-1);
00100     tclindexname = Tcl_NewStringObj("phase",-1);
00101     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00102         if (Tcl_GetDoubleFromObj(interp,tclobj,&phase) == TCL_ERROR) return TCL_ERROR;
00103     } else {
00104         return TCL_ERROR;
00105     }
00106     Tcl_DecrRefCount(tclarrayname);
00107     Tcl_DecrRefCount(tclindexname);
00108                 
00109 
00110     /* Read the output image 1 name */
00111     tclarrayname = Tcl_NewStringObj(array,-1);
00112     tclindexname = Tcl_NewStringObj("outname",-1);
00113     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00114         outname = Tcl_GetStringFromObj(tclobj,&strlen);
00115         if (strlen <= 0) return TCL_ERROR;
00116     } else {
00117         return TCL_ERROR;
00118     }
00119     Tcl_DecrRefCount(tclarrayname);
00120     Tcl_DecrRefCount(tclindexname);
00121                 
00122 
00123     SINEWAVE(lines,pix,period,phase,&outimg);
00124             
00125 
00126     if (CHECKIMG(outimg))  sprintf(outimg->text, "%s", outname);
00127     outimgaddr = (int) outimg;
00128                 
00129 
00130     sprintf(msg, "%x", outimgaddr);
00131     Tcl_SetResult(interp, msg, TCL_VOLATILE);
00132             
00133     return TCL_OK;
00134 }
00135 
00136 
00137 
00138 
00139 
00140 
00141 /*-Copyright Information------------------------------------------------------*/
00142 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00143 /*----------------------------------------------------------------------------*/
00144 /*-General Information--------------------------------------------------------*/
00145 /*                                                                            */
00146 /*   This procedure provides an interface to the SADIE function               */
00147 /*   CHIRP from Tcl/Tk.  It expects a tcl global array                        */
00148 /*   with these indices to exist:                                             */
00149 /*      array(lines)              --  int                                     */
00150 /*      array(pix)                --  int                                     */
00151 /*      array(period)             --  double                                  */
00152 /*      array(outname)            --  char*                                   */
00153 /*                                                                            */
00154 /*----------------------------------------------------------------------------*/
00155 /*-Interface Information------------------------------------------------------*/
00156 int Sadie_NewFunctions_ChirpCmd(ClientData client_data, Tcl_Interp* interp, int argc, char *argv[])
00157 {
00158     Tcl_Obj* tclobj=NULL;
00159     Tcl_Obj* tclarrayname = NULL;
00160     Tcl_Obj* tclindexname = NULL;
00161     char msg[SLEN];
00162     char* array=NULL;
00163     char* tempstr=NULL;
00164     int strlen;
00165     int outimgaddr;
00166     IMAGE* outimg=NULL;
00167     char* outname=NULL;
00168     int lines, pix;
00169     double period;
00170 
00171     if( argc != 2 ) {
00172         Tcl_AppendResult(interp,"wrong # args: should be \"",
00173         argv[0], " arrayname\"", (char *) NULL);
00174         return TCL_ERROR;
00175     }
00176     array=argv[1];
00177             
00178 
00179     /* Read the input integer array(lines) */
00180     tclarrayname = Tcl_NewStringObj(array,-1);
00181     tclindexname = Tcl_NewStringObj("lines",-1);
00182     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00183         if (Tcl_GetIntFromObj(interp,tclobj,&lines) == TCL_ERROR) return TCL_ERROR;
00184     } else {
00185         return TCL_ERROR;
00186     }
00187     Tcl_DecrRefCount(tclarrayname);
00188     Tcl_DecrRefCount(tclindexname);
00189                 
00190 
00191     /* Read the input integer array(pix) */
00192     tclarrayname = Tcl_NewStringObj(array,-1);
00193     tclindexname = Tcl_NewStringObj("pix",-1);
00194     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00195         if (Tcl_GetIntFromObj(interp,tclobj,&pix) == TCL_ERROR) return TCL_ERROR;
00196     } else {
00197         return TCL_ERROR;
00198     }
00199     Tcl_DecrRefCount(tclarrayname);
00200     Tcl_DecrRefCount(tclindexname);
00201                 
00202 
00203     /* Read the input double array(period) */
00204     tclarrayname = Tcl_NewStringObj(array,-1);
00205     tclindexname = Tcl_NewStringObj("period",-1);
00206     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00207         if (Tcl_GetDoubleFromObj(interp,tclobj,&period) == TCL_ERROR) return TCL_ERROR;
00208     } else {
00209         return TCL_ERROR;
00210     }
00211     Tcl_DecrRefCount(tclarrayname);
00212     Tcl_DecrRefCount(tclindexname);
00213                 
00214 
00215     /* Read the output image 1 name */
00216     tclarrayname = Tcl_NewStringObj(array,-1);
00217     tclindexname = Tcl_NewStringObj("outname",-1);
00218     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00219         outname = Tcl_GetStringFromObj(tclobj,&strlen);
00220         if (strlen <= 0) return TCL_ERROR;
00221     } else {
00222         return TCL_ERROR;
00223     }
00224     Tcl_DecrRefCount(tclarrayname);
00225     Tcl_DecrRefCount(tclindexname);
00226                 
00227 
00228     CHIRP(lines,pix,period,&outimg);
00229             
00230 
00231     if (CHECKIMG(outimg))  sprintf(outimg->text, "%s", outname);
00232     outimgaddr = (int) outimg;
00233                 
00234 
00235     sprintf(msg, "%x", outimgaddr);
00236     Tcl_SetResult(interp, msg, TCL_VOLATILE);
00237             
00238     return TCL_OK;
00239 }
00240 
00241 
00242 
00243 
00244 
00245 
00246 /*-Copyright Information------------------------------------------------------*/
00247 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00248 /*----------------------------------------------------------------------------*/
00249 /*-General Information--------------------------------------------------------*/
00250 /*                                                                            */
00251 /*   This procedure provides an interface to the SADIE function               */
00252 /*   SINESTAR from Tcl/Tk.  It expects a tcl global array                     */
00253 /*   with these indices to exist:                                             */
00254 /*      array(lines)              --  int                                     */
00255 /*      array(pix)                --  int                                     */
00256 /*      array(period)             --  double                                  */
00257 /*      array(outname)            --  char*                                   */
00258 /*                                                                            */
00259 /*----------------------------------------------------------------------------*/
00260 /*-Interface Information------------------------------------------------------*/
00261 int Sadie_NewFunctions_SineStarCmd(ClientData client_data, Tcl_Interp* interp, int argc, char *argv[])
00262 {
00263     Tcl_Obj* tclobj=NULL;
00264     Tcl_Obj* tclarrayname = NULL;
00265     Tcl_Obj* tclindexname = NULL;
00266     char msg[SLEN];
00267     char* array=NULL;
00268     char* tempstr=NULL;
00269     int strlen;
00270     int outimgaddr;
00271     IMAGE* outimg=NULL;
00272     char* outname=NULL;
00273     int lines, pix;
00274     double period;
00275 
00276     if( argc != 2 ) {
00277         Tcl_AppendResult(interp,"wrong # args: should be \"",
00278         argv[0], " arrayname\"", (char *) NULL);
00279         return TCL_ERROR;
00280     }
00281     array=argv[1];
00282             
00283 
00284     /* Read the input integer array(lines) */
00285     tclarrayname = Tcl_NewStringObj(array,-1);
00286     tclindexname = Tcl_NewStringObj("lines",-1);
00287     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00288         if (Tcl_GetIntFromObj(interp,tclobj,&lines) == TCL_ERROR) return TCL_ERROR;
00289     } else {
00290         return TCL_ERROR;
00291     }
00292     Tcl_DecrRefCount(tclarrayname);
00293     Tcl_DecrRefCount(tclindexname);
00294                 
00295 
00296     /* Read the input integer array(pix) */
00297     tclarrayname = Tcl_NewStringObj(array,-1);
00298     tclindexname = Tcl_NewStringObj("pix",-1);
00299     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00300         if (Tcl_GetIntFromObj(interp,tclobj,&pix) == TCL_ERROR) return TCL_ERROR;
00301     } else {
00302         return TCL_ERROR;
00303     }
00304     Tcl_DecrRefCount(tclarrayname);
00305     Tcl_DecrRefCount(tclindexname);
00306                 
00307 
00308     /* Read the input double array(period) */
00309     tclarrayname = Tcl_NewStringObj(array,-1);
00310     tclindexname = Tcl_NewStringObj("period",-1);
00311     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00312         if (Tcl_GetDoubleFromObj(interp,tclobj,&period) == 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 output image 1 name */
00321     tclarrayname = Tcl_NewStringObj(array,-1);
00322     tclindexname = Tcl_NewStringObj("outname",-1);
00323     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00324         outname = Tcl_GetStringFromObj(tclobj,&strlen);
00325         if (strlen <= 0) return TCL_ERROR;
00326     } else {
00327         return TCL_ERROR;
00328     }
00329     Tcl_DecrRefCount(tclarrayname);
00330     Tcl_DecrRefCount(tclindexname);
00331                 
00332 
00333     SINESTAR(lines,pix,period,&outimg);
00334             
00335 
00336     if (CHECKIMG(outimg))  sprintf(outimg->text, "%s", outname);
00337     outimgaddr = (int) outimg;
00338                 
00339 
00340     sprintf(msg, "%x", outimgaddr);
00341     Tcl_SetResult(interp, msg, TCL_VOLATILE);
00342             
00343     return TCL_OK;
00344 }
00345 
00346 
00347 
00348 
00349 
00350 
00351 /*-Copyright Information------------------------------------------------------*/
00352 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00353 /*----------------------------------------------------------------------------*/
00354 /*-General Information--------------------------------------------------------*/
00355 /*                                                                            */
00356 /*   This procedure provides an interface to the SADIE function               */
00357 /*   CHECKER from Tcl/Tk.  It expects a tcl global array                      */
00358 /*   with these indices to exist:                                             */
00359 /*      array(lines)              --  int                                     */
00360 /*      array(pix)                --  int                                     */
00361 /*      array(checklines)         --  int                                     */
00362 /*      array(checkpix)           --  int                                     */
00363 /*      array(outname)            --  char*                                   */
00364 /*                                                                            */
00365 /*----------------------------------------------------------------------------*/
00366 /*-Interface Information------------------------------------------------------*/
00367 int Sadie_NewFunctions_CheckerboardCmd(ClientData client_data, Tcl_Interp* interp, int argc, char *argv[])
00368 {
00369     Tcl_Obj* tclobj=NULL;
00370     Tcl_Obj* tclarrayname = NULL;
00371     Tcl_Obj* tclindexname = NULL;
00372     char msg[SLEN];
00373     char* array=NULL;
00374     char* tempstr=NULL;
00375     int strlen;
00376     int outimgaddr;
00377     IMAGE* outimg=NULL;
00378     char* outname=NULL;
00379     int lines, pix, checklines, checkpix;
00380 
00381     if( argc != 2 ) {
00382         Tcl_AppendResult(interp,"wrong # args: should be \"",
00383         argv[0], " arrayname\"", (char *) NULL);
00384         return TCL_ERROR;
00385     }
00386     array=argv[1];
00387             
00388 
00389     /* Read the input integer array(lines) */
00390     tclarrayname = Tcl_NewStringObj(array,-1);
00391     tclindexname = Tcl_NewStringObj("lines",-1);
00392     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00393         if (Tcl_GetIntFromObj(interp,tclobj,&lines) == TCL_ERROR) return TCL_ERROR;
00394     } else {
00395         return TCL_ERROR;
00396     }
00397     Tcl_DecrRefCount(tclarrayname);
00398     Tcl_DecrRefCount(tclindexname);
00399                 
00400 
00401     /* Read the input integer array(pix) */
00402     tclarrayname = Tcl_NewStringObj(array,-1);
00403     tclindexname = Tcl_NewStringObj("pix",-1);
00404     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00405         if (Tcl_GetIntFromObj(interp,tclobj,&pix) == TCL_ERROR) return TCL_ERROR;
00406     } else {
00407         return TCL_ERROR;
00408     }
00409     Tcl_DecrRefCount(tclarrayname);
00410     Tcl_DecrRefCount(tclindexname);
00411                 
00412 
00413     /* Read the input integer array(checklines) */
00414     tclarrayname = Tcl_NewStringObj(array,-1);
00415     tclindexname = Tcl_NewStringObj("checklines",-1);
00416     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00417         if (Tcl_GetIntFromObj(interp,tclobj,&checklines) == TCL_ERROR) return TCL_ERROR;
00418     } else {
00419         return TCL_ERROR;
00420     }
00421     Tcl_DecrRefCount(tclarrayname);
00422     Tcl_DecrRefCount(tclindexname);
00423                 
00424 
00425     /* Read the input integer array(checkpix) */
00426     tclarrayname = Tcl_NewStringObj(array,-1);
00427     tclindexname = Tcl_NewStringObj("checkpix",-1);
00428     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00429         if (Tcl_GetIntFromObj(interp,tclobj,&checkpix) == TCL_ERROR) return TCL_ERROR;
00430     } else {
00431         return TCL_ERROR;
00432     }
00433     Tcl_DecrRefCount(tclarrayname);
00434     Tcl_DecrRefCount(tclindexname);
00435                 
00436 
00437     /* Read the output image 1 name */
00438     tclarrayname = Tcl_NewStringObj(array,-1);
00439     tclindexname = Tcl_NewStringObj("outname",-1);
00440     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00441         outname = Tcl_GetStringFromObj(tclobj,&strlen);
00442         if (strlen <= 0) return TCL_ERROR;
00443     } else {
00444         return TCL_ERROR;
00445     }
00446     Tcl_DecrRefCount(tclarrayname);
00447     Tcl_DecrRefCount(tclindexname);
00448                 
00449 
00450     CHECKER(lines,pix,checklines,checkpix,&outimg);
00451             
00452 
00453     if (CHECKIMG(outimg))  sprintf(outimg->text, "%s", outname);
00454     outimgaddr = (int) outimg;
00455                 
00456 
00457     sprintf(msg, "%x", outimgaddr);
00458     Tcl_SetResult(interp, msg, TCL_VOLATILE);
00459             
00460     return TCL_OK;
00461 }
00462 
00463 
00464 
00465 
00466 
00467 
00468 /*-Copyright Information------------------------------------------------------*/
00469 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00470 /*----------------------------------------------------------------------------*/
00471 /*-General Information--------------------------------------------------------*/
00472 /*                                                                            */
00473 /*   This procedure provides an interface to the SADIE function               */
00474 /*   GRAYSCAL from Tcl/Tk.  It expects a tcl global array                      */
00475 /*   with these indices to exist:                                             */
00476 /*      array(lines)              --  int                                     */
00477 /*      array(pix)                --  int                                     */
00478 /*      array(number)             --  int                                     */
00479 /*      array(min)                --  double                                  */
00480 /*      array(max)                --  double                                  */
00481 /*      array(outname)            --  char*                                   */
00482 /*                                                                            */
00483 /*----------------------------------------------------------------------------*/
00484 /*-Interface Information------------------------------------------------------*/
00485 int Sadie_NewFunctions_GrayScaleCmd(ClientData client_data, Tcl_Interp* interp, int argc, char *argv[])
00486 {
00487     Tcl_Obj* tclobj=NULL;
00488     Tcl_Obj* tclarrayname = NULL;
00489     Tcl_Obj* tclindexname = NULL;
00490     char msg[SLEN];
00491     char* array=NULL;
00492     char* tempstr=NULL;
00493     int strlen;
00494     int outimgaddr;
00495     IMAGE* outimg=NULL;
00496     char* outname=NULL;
00497     int lines, pix, number;
00498     double min, max;
00499 
00500     if( argc != 2 ) {
00501         Tcl_AppendResult(interp,"wrong # args: should be \"",
00502         argv[0], " arrayname\"", (char *) NULL);
00503         return TCL_ERROR;
00504     }
00505     array=argv[1];
00506             
00507 
00508     /* Read the input integer array(lines) */
00509     tclarrayname = Tcl_NewStringObj(array,-1);
00510     tclindexname = Tcl_NewStringObj("lines",-1);
00511     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00512         if (Tcl_GetIntFromObj(interp,tclobj,&lines) == TCL_ERROR) return TCL_ERROR;
00513     } else {
00514         return TCL_ERROR;
00515     }
00516     Tcl_DecrRefCount(tclarrayname);
00517     Tcl_DecrRefCount(tclindexname);
00518                 
00519 
00520     /* Read the input integer array(pix) */
00521     tclarrayname = Tcl_NewStringObj(array,-1);
00522     tclindexname = Tcl_NewStringObj("pix",-1);
00523     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00524         if (Tcl_GetIntFromObj(interp,tclobj,&pix) == TCL_ERROR) return TCL_ERROR;
00525     } else {
00526         return TCL_ERROR;
00527     }
00528     Tcl_DecrRefCount(tclarrayname);
00529     Tcl_DecrRefCount(tclindexname);
00530                 
00531 
00532     /* Read the input integer array(number) */
00533     tclarrayname = Tcl_NewStringObj(array,-1);
00534     tclindexname = Tcl_NewStringObj("number",-1);
00535     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00536         if (Tcl_GetIntFromObj(interp,tclobj,&number) == TCL_ERROR) return TCL_ERROR;
00537     } else {
00538         return TCL_ERROR;
00539     }
00540     Tcl_DecrRefCount(tclarrayname);
00541     Tcl_DecrRefCount(tclindexname);
00542                 
00543 
00544     /* Read the input double array(min) */
00545     tclarrayname = Tcl_NewStringObj(array,-1);
00546     tclindexname = Tcl_NewStringObj("min",-1);
00547     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00548         if (Tcl_GetDoubleFromObj(interp,tclobj,&min) == TCL_ERROR) return TCL_ERROR;
00549     } else {
00550         return TCL_ERROR;
00551     }
00552     Tcl_DecrRefCount(tclarrayname);
00553     Tcl_DecrRefCount(tclindexname);
00554                 
00555 
00556     /* Read the input double array(max) */
00557     tclarrayname = Tcl_NewStringObj(array,-1);
00558     tclindexname = Tcl_NewStringObj("max",-1);
00559     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00560         if (Tcl_GetDoubleFromObj(interp,tclobj,&max) == TCL_ERROR) return TCL_ERROR;
00561     } else {
00562         return TCL_ERROR;
00563     }
00564     Tcl_DecrRefCount(tclarrayname);
00565     Tcl_DecrRefCount(tclindexname);
00566                 
00567 
00568     /* Read the output image 1 name */
00569     tclarrayname = Tcl_NewStringObj(array,-1);
00570     tclindexname = Tcl_NewStringObj("outname",-1);
00571     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00572         outname = Tcl_GetStringFromObj(tclobj,&strlen);
00573         if (strlen <= 0) return TCL_ERROR;
00574     } else {
00575         return TCL_ERROR;
00576     }
00577     Tcl_DecrRefCount(tclarrayname);
00578     Tcl_DecrRefCount(tclindexname);
00579                 
00580 
00581     GRAYSCAL(lines,pix,number,min,max,&outimg);
00582             
00583 
00584     if (CHECKIMG(outimg))  sprintf(outimg->text, "%s", outname);
00585     outimgaddr = (int) outimg;
00586                 
00587 
00588     sprintf(msg, "%x", outimgaddr);
00589     Tcl_SetResult(interp, msg, TCL_VOLATILE);
00590             
00591     return TCL_OK;
00592 }
00593 
00594 
00595 
00596 
00597 
00598 
00599 /*-Copyright Information------------------------------------------------------*/
00600 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00601 /*----------------------------------------------------------------------------*/
00602 /*-General Information--------------------------------------------------------*/
00603 /*                                                                            */
00604 /*   This procedure provides an interface to the SADIE function               */
00605 /*   FUNCTION from Tcl/Tk.  It expects a tcl global array                     */
00606 /*   with these indices to exist:                                             */
00607 /*      array(lines)              --  int                                     */
00608 /*      array(pix)                --  int                                     */
00609 /*      array(type)               --  int                                     */
00610 /*      array(radiuslines)        --  double                                  */
00611 /*      array(radiuspix)          --  double                                  */
00612 /*      array(outname)            --  char*                                   */
00613 /*                                                                            */
00614 /*----------------------------------------------------------------------------*/
00615 /*-Interface Information------------------------------------------------------*/
00616 int Sadie_NewFunctions_FunctionCmd(ClientData client_data, Tcl_Interp* interp, int argc, char *argv[])
00617 {
00618     Tcl_Obj* tclobj=NULL;
00619     Tcl_Obj* tclarrayname = NULL;
00620     Tcl_Obj* tclindexname = NULL;
00621     char msg[SLEN];
00622     char* array=NULL;
00623     char* tempstr=NULL;
00624     int strlen;
00625     int outimgaddr;
00626     IMAGE* outimg=NULL;
00627     char* outname=NULL;
00628     int lines, pix, type;
00629     double radiuslines, radiuspix, alpha;
00630 
00631     if( argc != 2 ) {
00632         Tcl_AppendResult(interp,"wrong # args: should be \"",
00633         argv[0], " arrayname\"", (char *) NULL);
00634         return TCL_ERROR;
00635     }
00636     array=argv[1];
00637             
00638 
00639     /* Read the input integer array(lines) */
00640     tclarrayname = Tcl_NewStringObj(array,-1);
00641     tclindexname = Tcl_NewStringObj("lines",-1);
00642     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00643         if (Tcl_GetIntFromObj(interp,tclobj,&lines) == TCL_ERROR) return TCL_ERROR;
00644     } else {
00645         return TCL_ERROR;
00646     }
00647     Tcl_DecrRefCount(tclarrayname);
00648     Tcl_DecrRefCount(tclindexname);
00649                 
00650 
00651     /* Read the input integer array(pix) */
00652     tclarrayname = Tcl_NewStringObj(array,-1);
00653     tclindexname = Tcl_NewStringObj("pix",-1);
00654     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00655         if (Tcl_GetIntFromObj(interp,tclobj,&pix) == TCL_ERROR) return TCL_ERROR;
00656     } else {
00657         return TCL_ERROR;
00658     }
00659     Tcl_DecrRefCount(tclarrayname);
00660     Tcl_DecrRefCount(tclindexname);
00661                 
00662 
00663     /* Read the input integer array(type) */
00664     tclarrayname = Tcl_NewStringObj(array,-1);
00665     tclindexname = Tcl_NewStringObj("type",-1);
00666     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00667         if (Tcl_GetIntFromObj(interp,tclobj,&type) == TCL_ERROR) return TCL_ERROR;
00668     } else {
00669         return TCL_ERROR;
00670     }
00671     Tcl_DecrRefCount(tclarrayname);
00672     Tcl_DecrRefCount(tclindexname);
00673                 
00674 
00675     /* Read the input double array(radiuslines) */
00676     tclarrayname = Tcl_NewStringObj(array,-1);
00677     tclindexname = Tcl_NewStringObj("radiuslines",-1);
00678     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00679         if (Tcl_GetDoubleFromObj(interp,tclobj,&radiuslines) == TCL_ERROR) return TCL_ERROR;
00680     } else {
00681         return TCL_ERROR;
00682     }
00683     Tcl_DecrRefCount(tclarrayname);
00684     Tcl_DecrRefCount(tclindexname);
00685                 
00686 
00687     /* Read the input double array(radiuspix) */
00688     tclarrayname = Tcl_NewStringObj(array,-1);
00689     tclindexname = Tcl_NewStringObj("radiuspix",-1);
00690     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00691         if (Tcl_GetDoubleFromObj(interp,tclobj,&radiuspix) == TCL_ERROR) return TCL_ERROR;
00692     } else {
00693         return TCL_ERROR;
00694     }
00695     Tcl_DecrRefCount(tclarrayname);
00696     Tcl_DecrRefCount(tclindexname);
00697                 
00698 
00699     /* Read the input double array(alpha) */
00700     tclarrayname = Tcl_NewStringObj(array,-1);
00701     tclindexname = Tcl_NewStringObj("alpha",-1);
00702     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00703         if (Tcl_GetDoubleFromObj(interp,tclobj,&alpha) == TCL_ERROR) return TCL_ERROR;
00704     } else {
00705         return TCL_ERROR;
00706     }
00707     Tcl_DecrRefCount(tclarrayname);
00708     Tcl_DecrRefCount(tclindexname);
00709                 
00710 
00711     /* Read the output image 1 name */
00712     tclarrayname = Tcl_NewStringObj(array,-1);
00713     tclindexname = Tcl_NewStringObj("outname",-1);
00714     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00715         outname = Tcl_GetStringFromObj(tclobj,&strlen);
00716         if (strlen <= 0) return TCL_ERROR;
00717     } else {
00718         return TCL_ERROR;
00719     }
00720     Tcl_DecrRefCount(tclarrayname);
00721     Tcl_DecrRefCount(tclindexname);
00722                 
00723 
00724     FUNCTION(lines,pix,radiuslines,radiuspix,alpha,type,&outimg);
00725             
00726 
00727     if (CHECKIMG(outimg))  sprintf(outimg->text, "%s", outname);
00728     outimgaddr = (int) outimg;
00729                 
00730 
00731     sprintf(msg, "%x", outimgaddr);
00732     Tcl_SetResult(interp, msg, TCL_VOLATILE);
00733             
00734     return TCL_OK;
00735 }
00736 
00737 
00738 
00739 
00740 
00741 
00742 /*-Copyright Information------------------------------------------------------*/
00743 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00744 /*----------------------------------------------------------------------------*/
00745 /*-General Information--------------------------------------------------------*/
00746 /*                                                                            */
00747 /*   This procedure provides an interface to the SADIE function               */
00748 /*   RANDOM from Tcl/Tk.  It expects a tcl global array                       */
00749 /*   with these indices to exist:                                             */
00750 /*      array(lines)              --  int                                     */
00751 /*      array(pix)                --  int                                     */
00752 /*      array(type)               --  int                                     */
00753 /*      array(deviation)          --  double                                  */
00754 /*      array(outname)            --  char*                                   */
00755 /*                                                                            */
00756 /*----------------------------------------------------------------------------*/
00757 /*-Interface Information------------------------------------------------------*/
00758 int Sadie_NewFunctions_RandomCmd(ClientData client_data, Tcl_Interp* interp, int argc, char *argv[])
00759 {
00760     Tcl_Obj* tclobj=NULL;
00761     Tcl_Obj* tclarrayname = NULL;
00762     Tcl_Obj* tclindexname = NULL;
00763     char msg[SLEN];
00764     char* array=NULL;
00765     char* tempstr=NULL;
00766     int strlen;
00767     int outimgaddr;
00768     IMAGE* outimg=NULL;
00769     char* outname=NULL;
00770     int lines, pix, type;
00771     double deviation;
00772 
00773     if( argc != 2 ) {
00774         Tcl_AppendResult(interp,"wrong # args: should be \"",
00775         argv[0], " arrayname\"", (char *) NULL);
00776         return TCL_ERROR;
00777     }
00778     array=argv[1];
00779             
00780 
00781     /* Read the input integer array(lines) */
00782     tclarrayname = Tcl_NewStringObj(array,-1);
00783     tclindexname = Tcl_NewStringObj("lines",-1);
00784     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00785         if (Tcl_GetIntFromObj(interp,tclobj,&lines) == TCL_ERROR) return TCL_ERROR;
00786     } else {
00787         return TCL_ERROR;
00788     }
00789     Tcl_DecrRefCount(tclarrayname);
00790     Tcl_DecrRefCount(tclindexname);
00791                 
00792 
00793     /* Read the input integer array(pix) */
00794     tclarrayname = Tcl_NewStringObj(array,-1);
00795     tclindexname = Tcl_NewStringObj("pix",-1);
00796     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00797         if (Tcl_GetIntFromObj(interp,tclobj,&pix) == TCL_ERROR) return TCL_ERROR;
00798     } else {
00799         return TCL_ERROR;
00800     }
00801     Tcl_DecrRefCount(tclarrayname);
00802     Tcl_DecrRefCount(tclindexname);
00803                 
00804 
00805     /* Read the input integer array(type) */
00806     tclarrayname = Tcl_NewStringObj(array,-1);
00807     tclindexname = Tcl_NewStringObj("type",-1);
00808     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00809         if (Tcl_GetIntFromObj(interp,tclobj,&type) == TCL_ERROR) return TCL_ERROR;
00810     } else {
00811         return TCL_ERROR;
00812     }
00813     Tcl_DecrRefCount(tclarrayname);
00814     Tcl_DecrRefCount(tclindexname);
00815                 
00816 
00817     /* Read the input double array(deviation) */
00818     tclarrayname = Tcl_NewStringObj(array,-1);
00819     tclindexname = Tcl_NewStringObj("deviation",-1);
00820     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00821         if (Tcl_GetDoubleFromObj(interp,tclobj,&deviation) == TCL_ERROR) return TCL_ERROR;
00822     } else {
00823         return TCL_ERROR;
00824     }
00825     Tcl_DecrRefCount(tclarrayname);
00826     Tcl_DecrRefCount(tclindexname);
00827                 
00828 
00829     /* Read the output image 1 name */
00830     tclarrayname = Tcl_NewStringObj(array,-1);
00831     tclindexname = Tcl_NewStringObj("outname",-1);
00832     if (tclobj = Tcl_ObjGetVar2(interp,  tclarrayname , tclindexname , TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)) {
00833         outname = Tcl_GetStringFromObj(tclobj,&strlen);
00834         if (strlen <= 0) return TCL_ERROR;
00835     } else {
00836         return TCL_ERROR;
00837     }
00838     Tcl_DecrRefCount(tclarrayname);
00839     Tcl_DecrRefCount(tclindexname);
00840                 
00841 
00842     RANDOM(lines,pix,type,deviation,&outimg);
00843             
00844 
00845     if (CHECKIMG(outimg))  sprintf(outimg->text, "%s", outname);
00846     outimgaddr = (int) outimg;
00847                 
00848 
00849     sprintf(msg, "%x", outimgaddr);
00850     Tcl_SetResult(interp, msg, TCL_VOLATILE);
00851             
00852     return TCL_OK;
00853 }
00854 
00855 
00856 
00857 
00858 
00859 
00860 /*-Copyright Information------------------------------------------------------*/
00861 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00862 /*----------------------------------------------------------------------------*/
00863 /*-General Information--------------------------------------------------------*/
00864 /*                                                                            */
00865 /*   This procedure initializes the all of the procedures                     */
00866 /*   in this file by registering them with Tcl.                               */
00867 /*                                                                            */
00868 /*----------------------------------------------------------------------------*/
00869 /*-Interface Information------------------------------------------------------*/
00870 int Sadie_NewFunctions_Init(Tcl_Interp *interp)
00871 {
00872     Tcl_CreateCommand(interp, "Sadie_NewFunctions_SineWave", Sadie_NewFunctions_SineWaveCmd,(ClientData) NULL, NULL);
00873     Tcl_CreateCommand(interp, "Sadie_NewFunctions_Chirp", Sadie_NewFunctions_ChirpCmd,(ClientData) NULL, NULL);
00874     Tcl_CreateCommand(interp, "Sadie_NewFunctions_SineStar", Sadie_NewFunctions_SineStarCmd,(ClientData) NULL, NULL);
00875     Tcl_CreateCommand(interp, "Sadie_NewFunctions_Checkerboard", Sadie_NewFunctions_CheckerboardCmd,(ClientData) NULL, NULL);
00876     Tcl_CreateCommand(interp, "Sadie_NewFunctions_GrayScale", Sadie_NewFunctions_GrayScaleCmd,(ClientData) NULL, NULL);
00877     Tcl_CreateCommand(interp, "Sadie_NewFunctions_Function", Sadie_NewFunctions_FunctionCmd,(ClientData) NULL, NULL);
00878     Tcl_CreateCommand(interp, "Sadie_NewFunctions_Random", Sadie_NewFunctions_RandomCmd,(ClientData) NULL, NULL);
00879     return TCL_OK;
00880 }
00881 
00882 
00883 
00884 
00885 
00886 

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