Main Page   Data Structures   File List   Data Fields   Globals  

Sadie_Geometry.c

Go to the documentation of this file.
00001 /*
00002 ##########################################
00003 # Sadie_Geometry.c -
00004 #   Set of routines for linking SADIE geometry routines to tcl/tk.
00005 #
00006 # RCS: $Id: Sadie_Geometry.c,v 2.5 1999/02/01 21:44:15 gopalan 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 <stdio.h>
00017 #include <string.h>
00018 #include "sadie.h"
00019 
00020 /* RCS Indentification information */
00021 static char rcsid[] =
00022   "$Id: Sadie_Geometry.c,v 2.5 1999/02/01 21:44:15 gopalan Exp $";
00023 
00024 /*-------------------------------------------------------------*/
00025 /* Global Sadie variables that must be set from within Tcl/Tk  */
00026 /*-------------------------------------------------------------*/
00027 extern short nlev;
00028 extern short csize;
00029 extern double weight;
00030 extern double *count;
00031 extern PIXEL gain;
00032 extern PIXEL bias;
00033 extern PIXEL gmin;
00034 extern PIXEL gmax;
00035 extern PIXEL thresh;
00036 extern PIXEL gbrk[2][4];
00037 extern PIXEL *table;
00038 
00039 /* -------------------------------------------------------------------------- */
00040 
00041 /* Global Variable to hold Polynomial Terms */
00042 double xpolyterms[6] = { 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 };
00043 double ypolyterms[6] = { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 };
00044 int numpolyterms = 3;
00045 
00046 /*-Copyright Information------------------------------------------------------*/
00047 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00048 /*----------------------------------------------------------------------------*/
00049 /*-General Information--------------------------------------------------------*/
00050 /*                                                                            */
00051 /*   This procedure provides an interface to the SADIE function               */
00052 /*   RESAMPL from Tcl/Tk.  It expects a tcl global array                      */
00053 /*   with these indices to exist:                                             */
00054 /*      array(inimg,addr)         --  SADIE image address                     */
00055 /*      array(lines)              --  int                                     */
00056 /*      array(pix)                --  int                                     */
00057 /*      array(incrlines)          --  int                                     */
00058 /*      array(incrpix)            --  int                                     */
00059 /*      array(outname)            --  char*                                   */
00060 /*                                                                            */
00061 /*----------------------------------------------------------------------------*/
00062 /*-Interface Information------------------------------------------------------*/
00063 int
00064 Sadie_Geometry_AvgSubCmd (ClientData client_data, Tcl_Interp * interp,
00065                           int argc, char *argv[])
00066 {
00067   Tcl_Obj *tclobj = NULL;
00068   char msg[SLEN];
00069   char *array = NULL;
00070   char *tempstr = NULL;
00071   int strlen;
00072   int inimgaddr;
00073   IMAGE *inimg = NULL;
00074   int outimgaddr;
00075   IMAGE *outimg = NULL;
00076   char *outname = NULL;
00077   int lines, pix, incrlines, incrpix;
00078 
00079   if (argc != 2)
00080     {
00081       Tcl_AppendResult (interp, "wrong # args: should be \"",
00082                         argv[0], " arrayname\"", (char *) NULL);
00083       return TCL_ERROR;
00084     }
00085   array = argv[1];
00086 
00087   /* Read input image array(inimg,addr) */
00088   if (tclobj =
00089       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00090                       Tcl_NewStringObj ("inimg,addr", -1),
00091                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00092     {
00093       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
00094       if (strlen <= 0)
00095         return TCL_ERROR;
00096       sscanf (tempstr, "%x", &inimgaddr);
00097       inimg = (IMAGE *) inimgaddr;
00098     }
00099   else
00100     {
00101       return TCL_ERROR;
00102     }
00103 
00104   /* Read the input integer array(lines) */
00105   if (tclobj =
00106       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00107                       Tcl_NewStringObj ("lines", -1),
00108                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00109     {
00110       if (Tcl_GetIntFromObj (interp, tclobj, &lines) == TCL_ERROR)
00111         return TCL_ERROR;
00112     }
00113   else
00114     {
00115       return TCL_ERROR;
00116     }
00117 
00118   /* Read the input integer array(pix) */
00119   if (tclobj =
00120       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00121                       Tcl_NewStringObj ("pix", -1),
00122                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00123     {
00124       if (Tcl_GetIntFromObj (interp, tclobj, &pix) == TCL_ERROR)
00125         return TCL_ERROR;
00126     }
00127   else
00128     {
00129       return TCL_ERROR;
00130     }
00131 
00132   /* Read the input integer array(incrlines) */
00133   if (tclobj =
00134       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00135                       Tcl_NewStringObj ("incrlines", -1),
00136                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00137     {
00138       if (Tcl_GetIntFromObj (interp, tclobj, &incrlines) == TCL_ERROR)
00139         return TCL_ERROR;
00140     }
00141   else
00142     {
00143       return TCL_ERROR;
00144     }
00145 
00146   /* Read the input integer array(incrpix) */
00147   if (tclobj =
00148       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00149                       Tcl_NewStringObj ("incrpix", -1),
00150                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00151     {
00152       if (Tcl_GetIntFromObj (interp, tclobj, &incrpix) == TCL_ERROR)
00153         return TCL_ERROR;
00154     }
00155   else
00156     {
00157       return TCL_ERROR;
00158     }
00159 
00160   /* Read the output image 1 name */
00161   if (tclobj =
00162       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00163                       Tcl_NewStringObj ("outname", -1),
00164                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00165     {
00166       outname = Tcl_GetStringFromObj (tclobj, &strlen);
00167       if (strlen <= 0)
00168         return TCL_ERROR;
00169     }
00170   else
00171     {
00172       return TCL_ERROR;
00173     }
00174 
00175   RESAMPL (inimg, lines, pix, incrlines, incrpix, &outimg);
00176 
00177   if (CHECKIMG (outimg))
00178     sprintf (outimg->text, "%s", outname);
00179   outimgaddr = (int) outimg;
00180 
00181   sprintf (msg, "%x", outimgaddr);
00182   Tcl_SetResult (interp, msg, TCL_VOLATILE);
00183 
00184   return TCL_OK;
00185 }
00186 
00187 /*-Copyright Information------------------------------------------------------*/
00188 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00189 /*----------------------------------------------------------------------------*/
00190 /*-General Information--------------------------------------------------------*/
00191 /*                                                                            */
00192 /*   This procedure provides an interface to the SADIE function               */
00193 /*   SUBSAMPL from Tcl/Tk.  It expects a tcl global array                     */
00194 /*   with these indices to exist:                                             */
00195 /*      array(inimg,addr)         --  SADIE image address                     */
00196 /*      array(from,band)          --  int                                     */
00197 /*      array(from,pix)           --  int                                     */
00198 /*      array(from,line)          --  int                                     */
00199 /*      array(to,band)            --  int                                     */
00200 /*      array(to,pix)             --  int                                     */
00201 /*      array(to,line)            --  int                                     */
00202 /*      array(incr,band)          --  int                                     */
00203 /*      array(incr,pix)           --  int                                     */
00204 /*      array(incr,line)          --  int                                     */
00205 /*      array(outname)            --  char*                                   */
00206 /*                                                                            */
00207 /*----------------------------------------------------------------------------*/
00208 /*-Interface Information------------------------------------------------------*/
00209 int
00210 Sadie_Geometry_WinSubCmd (ClientData client_data, Tcl_Interp * interp,
00211                           int argc, char *argv[])
00212 {
00213   Tcl_Obj *tclobj = NULL;
00214   char msg[SLEN];
00215   char *array = NULL;
00216   char *tempstr = NULL;
00217   int strlen;
00218   int inimgaddr;
00219   IMAGE *inimg = NULL;
00220   int outimgaddr;
00221   IMAGE *outimg = NULL;
00222   char *outname = NULL;
00223   int fromband, frompix, fromline, toband, topix, toline, incrband, incrpix,
00224     incrline;
00225 
00226   if (argc != 2)
00227     {
00228       Tcl_AppendResult (interp, "wrong # args: should be \"",
00229                         argv[0], " arrayname\"", (char *) NULL);
00230       return TCL_ERROR;
00231     }
00232   array = argv[1];
00233 
00234   /* Read input image array(inimg,addr) */
00235   if (tclobj =
00236       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00237                       Tcl_NewStringObj ("inimg,addr", -1),
00238                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00239     {
00240       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
00241       if (strlen <= 0)
00242         return TCL_ERROR;
00243       sscanf (tempstr, "%x", &inimgaddr);
00244       inimg = (IMAGE *) inimgaddr;
00245     }
00246   else
00247     {
00248       return TCL_ERROR;
00249     }
00250 
00251   /* Read the input integer array(from,band) */
00252   if (tclobj =
00253       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00254                       Tcl_NewStringObj ("from,band", -1),
00255                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00256     {
00257       if (Tcl_GetIntFromObj (interp, tclobj, &fromband) == TCL_ERROR)
00258         return TCL_ERROR;
00259     }
00260   else
00261     {
00262       return TCL_ERROR;
00263     }
00264 
00265   /* Read the input integer array(from,pix) */
00266   if (tclobj =
00267       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00268                       Tcl_NewStringObj ("from,pix", -1),
00269                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00270     {
00271       if (Tcl_GetIntFromObj (interp, tclobj, &frompix) == TCL_ERROR)
00272         return TCL_ERROR;
00273     }
00274   else
00275     {
00276       return TCL_ERROR;
00277     }
00278 
00279   /* Read the input integer array(from,line) */
00280   if (tclobj =
00281       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00282                       Tcl_NewStringObj ("from,line", -1),
00283                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00284     {
00285       if (Tcl_GetIntFromObj (interp, tclobj, &fromline) == TCL_ERROR)
00286         return TCL_ERROR;
00287     }
00288   else
00289     {
00290       return TCL_ERROR;
00291     }
00292 
00293   /* Read the input integer array(to,band) */
00294   if (tclobj =
00295       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00296                       Tcl_NewStringObj ("to,band", -1),
00297                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00298     {
00299       if (Tcl_GetIntFromObj (interp, tclobj, &toband) == TCL_ERROR)
00300         return TCL_ERROR;
00301     }
00302   else
00303     {
00304       return TCL_ERROR;
00305     }
00306 
00307   /* Read the input integer array(to,pix) */
00308   if (tclobj =
00309       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00310                       Tcl_NewStringObj ("to,pix", -1),
00311                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00312     {
00313       if (Tcl_GetIntFromObj (interp, tclobj, &topix) == TCL_ERROR)
00314         return TCL_ERROR;
00315     }
00316   else
00317     {
00318       return TCL_ERROR;
00319     }
00320 
00321   /* Read the input integer array(to,line) */
00322   if (tclobj =
00323       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00324                       Tcl_NewStringObj ("to,line", -1),
00325                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00326     {
00327       if (Tcl_GetIntFromObj (interp, tclobj, &toline) == TCL_ERROR)
00328         return TCL_ERROR;
00329     }
00330   else
00331     {
00332       return TCL_ERROR;
00333     }
00334 
00335   /* Read the input integer array(incr,band) */
00336   if (tclobj =
00337       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00338                       Tcl_NewStringObj ("incr,band", -1),
00339                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00340     {
00341       if (Tcl_GetIntFromObj (interp, tclobj, &incrband) == TCL_ERROR)
00342         return TCL_ERROR;
00343     }
00344   else
00345     {
00346       return TCL_ERROR;
00347     }
00348 
00349   /* Read the input integer array(incr,pix) */
00350   if (tclobj =
00351       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00352                       Tcl_NewStringObj ("incr,pix", -1),
00353                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00354     {
00355       if (Tcl_GetIntFromObj (interp, tclobj, &incrpix) == TCL_ERROR)
00356         return TCL_ERROR;
00357     }
00358   else
00359     {
00360       return TCL_ERROR;
00361     }
00362 
00363   /* Read the input integer array(incr,line) */
00364   if (tclobj =
00365       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00366                       Tcl_NewStringObj ("incr,line", -1),
00367                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00368     {
00369       if (Tcl_GetIntFromObj (interp, tclobj, &incrline) == TCL_ERROR)
00370         return TCL_ERROR;
00371     }
00372   else
00373     {
00374       return TCL_ERROR;
00375     }
00376 
00377   /* Read the output image 1 name */
00378   if (tclobj =
00379       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00380                       Tcl_NewStringObj ("outname", -1),
00381                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00382     {
00383       outname = Tcl_GetStringFromObj (tclobj, &strlen);
00384       if (strlen <= 0)
00385         return TCL_ERROR;
00386     }
00387   else
00388     {
00389       return TCL_ERROR;
00390     }
00391 
00392   SUBSAMPL (inimg, fromband - 1, fromline - 1, frompix - 1, incrband,
00393             incrline, incrpix, ((toband - fromband) + 1),
00394             ((toline - fromline) + 1), ((topix - frompix) + 1), &outimg);
00395 
00396   if (CHECKIMG (outimg))
00397     sprintf (outimg->text, "%s", outname);
00398   outimgaddr = (int) outimg;
00399 
00400   sprintf (msg, "%x", outimgaddr);
00401   Tcl_SetResult (interp, msg, TCL_VOLATILE);
00402 
00403   return TCL_OK;
00404 }
00405 
00406 /*-Copyright Information------------------------------------------------------*/
00407 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00408 /*----------------------------------------------------------------------------*/
00409 /*-General Information--------------------------------------------------------*/
00410 /*                                                                            */
00411 /*   This procedure provides an interface to the SADIE function               */
00412 /*   EXPAND from Tcl/Tk.  It expects a tcl global array                       */
00413 /*   with these indices to exist:                                             */
00414 /*      array(inimg,addr)         --  SADIE image address                     */
00415 /*      array(lines)              --  int                                     */
00416 /*      array(pix)                --  int                                     */
00417 /*      array(option)             --  int                                     */
00418 /*      array(outname)            --  char*                                   */
00419 /*                                                                            */
00420 /*----------------------------------------------------------------------------*/
00421 /*-Interface Information------------------------------------------------------*/
00422 int
00423 Sadie_Geometry_ScaleCmd (ClientData client_data, Tcl_Interp * interp,
00424                          int argc, char *argv[])
00425 {
00426   Tcl_Obj *tclobj = NULL;
00427   char msg[SLEN];
00428   char *array = NULL;
00429   char *tempstr = NULL;
00430   int strlen;
00431   int inimgaddr;
00432   IMAGE *inimg = NULL;
00433   int outimgaddr;
00434   IMAGE *outimg = NULL;
00435   char *outname = NULL;
00436   double lines, pix, option;
00437 
00438   if (argc != 2)
00439     {
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   /* Read input image array(inimg,addr) */
00447   if (tclobj =
00448       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00449                       Tcl_NewStringObj ("inimg,addr", -1),
00450                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00451     {
00452       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
00453       if (strlen <= 0)
00454         return TCL_ERROR;
00455       sscanf (tempstr, "%x", &inimgaddr);
00456       inimg = (IMAGE *) inimgaddr;
00457     }
00458   else
00459     {
00460       return TCL_ERROR;
00461     }
00462 
00463   /* Read the input integer array(lines) */
00464   if (tclobj =
00465       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00466                       Tcl_NewStringObj ("lines", -1),
00467                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00468     {
00469       if (Tcl_GetDoubleFromObj (interp, tclobj, &lines) == TCL_ERROR)
00470         return TCL_ERROR;
00471     }
00472   else
00473     {
00474       return TCL_ERROR;
00475     }
00476 
00477   /* Read the input integer array(pix) */
00478   if (tclobj =
00479       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00480                       Tcl_NewStringObj ("pix", -1),
00481                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00482     {
00483       if (Tcl_GetDoubleFromObj (interp, tclobj, &pix) == TCL_ERROR)
00484         return TCL_ERROR;
00485     }
00486   else
00487     {
00488       return TCL_ERROR;
00489     }
00490 
00491   /* Read the input integer array(option) */
00492   if (tclobj =
00493       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00494                       Tcl_NewStringObj ("option", -1),
00495                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00496     {
00497       if (Tcl_GetDoubleFromObj (interp, tclobj, &option) == TCL_ERROR)
00498         return TCL_ERROR;
00499     }
00500   else
00501     {
00502       return TCL_ERROR;
00503     }
00504 
00505   /* Read the output image 1 name */
00506   if (tclobj =
00507       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00508                       Tcl_NewStringObj ("outname", -1),
00509                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00510     {
00511       outname = Tcl_GetStringFromObj (tclobj, &strlen);
00512       if (strlen <= 0)
00513         return TCL_ERROR;
00514     }
00515   else
00516     {
00517       return TCL_ERROR;
00518     }
00519 
00520   EXPAND (inimg, lines, pix, option, &outimg);
00521 
00522   if (CHECKIMG (outimg))
00523     sprintf (outimg->text, "%s", outname);
00524   outimgaddr = (int) outimg;
00525 
00526   sprintf (msg, "%x", outimgaddr);
00527   Tcl_SetResult (interp, msg, TCL_VOLATILE);
00528 
00529   return TCL_OK;
00530 }
00531 
00532 /*-Copyright Information------------------------------------------------------*/
00533 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00534 /*----------------------------------------------------------------------------*/
00535 /*-General Information--------------------------------------------------------*/
00536 /*                                                                            */
00537 /*   This procedure provides an interface to the SADIE function               */
00538 /*   ROTATE from Tcl/Tk.  It expects a tcl global array                       */
00539 /*   with these indices to exist:                                             */
00540 /*      array(inimg,addr)         --  SADIE image address                     */
00541 /*      array(angle)              --  double                                  */
00542 /*      array(option)             --  double                                  */
00543 /*      array(graylevel)          --  PIXEL                                   */
00544 /*      array(outname)            --  char*                                   */
00545 /*                                                                            */
00546 /*----------------------------------------------------------------------------*/
00547 /*-Interface Information------------------------------------------------------*/
00548 int
00549 Sadie_Geometry_RotateCmd (ClientData client_data, Tcl_Interp * interp,
00550                           int argc, char *argv[])
00551 {
00552   Tcl_Obj *tclobj = NULL;
00553   char msg[SLEN];
00554   char *array = NULL;
00555   char *tempstr = NULL;
00556   int strlen;
00557   int inimgaddr;
00558   IMAGE *inimg = NULL;
00559   int outimgaddr;
00560   IMAGE *outimg = NULL;
00561   char *outname = NULL;
00562   double angle, option;
00563   PIXEL graylevel;
00564   double tempdouble;
00565 
00566   if (argc != 2)
00567     {
00568       Tcl_AppendResult (interp, "wrong # args: should be \"",
00569                         argv[0], " arrayname\"", (char *) NULL);
00570       return TCL_ERROR;
00571     }
00572   array = argv[1];
00573 
00574   /* Read input image array(inimg,addr) */
00575   if (tclobj =
00576       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00577                       Tcl_NewStringObj ("inimg,addr", -1),
00578                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00579     {
00580       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
00581       if (strlen <= 0)
00582         return TCL_ERROR;
00583       sscanf (tempstr, "%x", &inimgaddr);
00584       inimg = (IMAGE *) inimgaddr;
00585     }
00586   else
00587     {
00588       return TCL_ERROR;
00589     }
00590 
00591   /* Read the input double array(angle) */
00592   if (tclobj =
00593       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00594                       Tcl_NewStringObj ("angle", -1),
00595                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00596     {
00597       if (Tcl_GetDoubleFromObj (interp, tclobj, &angle) == TCL_ERROR)
00598         return TCL_ERROR;
00599     }
00600   else
00601     {
00602       return TCL_ERROR;
00603     }
00604 
00605   /* Read the input double array(option) */
00606   if (tclobj =
00607       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00608                       Tcl_NewStringObj ("option", -1),
00609                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00610     {
00611       if (Tcl_GetDoubleFromObj (interp, tclobj, &option) == TCL_ERROR)
00612         return TCL_ERROR;
00613     }
00614   else
00615     {
00616       return TCL_ERROR;
00617     }
00618 
00619   /* Read the input PIXEL array(graylevel) */
00620   if (tclobj =
00621       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00622                       Tcl_NewStringObj ("graylevel", -1),
00623                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00624     {
00625       if (Tcl_GetDoubleFromObj (interp, tclobj, &tempdouble) == TCL_ERROR)
00626         return TCL_ERROR;
00627       graylevel = (PIXEL) tempdouble;
00628     }
00629   else
00630     {
00631       return TCL_ERROR;
00632     }
00633 
00634   /* Read the output image 1 name */
00635   if (tclobj =
00636       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00637                       Tcl_NewStringObj ("outname", -1),
00638                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00639     {
00640       outname = Tcl_GetStringFromObj (tclobj, &strlen);
00641       if (strlen <= 0)
00642         return TCL_ERROR;
00643     }
00644   else
00645     {
00646       return TCL_ERROR;
00647     }
00648 
00649   ROTATE (inimg, angle, graylevel, option, &outimg);
00650 
00651   if (CHECKIMG (outimg))
00652     sprintf (outimg->text, "%s", outname);
00653   outimgaddr = (int) outimg;
00654 
00655   sprintf (msg, "%x", outimgaddr);
00656   Tcl_SetResult (interp, msg, TCL_VOLATILE);
00657 
00658   return TCL_OK;
00659 }
00660 
00661 /*-Copyright Information------------------------------------------------------*/
00662 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00663 /*----------------------------------------------------------------------------*/
00664 /*-General Information--------------------------------------------------------*/
00665 /*                                                                            */
00666 /*   This procedure provides an interface to the SADIE function               */
00667 /*   TRNSFORM from Tcl/Tk.  It expects a tcl global array                     */
00668 /*   with these indices to exist:                                             */
00669 /*      array(inimg,addr)         --  SADIE image address                     */
00670 /*      array(option)             --  int                                     */
00671 /*      array(outname)            --  char*                                   */
00672 /*                                                                            */
00673 /*----------------------------------------------------------------------------*/
00674 /*-Interface Information------------------------------------------------------*/
00675 int
00676 Sadie_Geometry_MirrorCmd (ClientData client_data, Tcl_Interp * interp,
00677                           int argc, char *argv[])
00678 {
00679   Tcl_Obj *tclobj = NULL;
00680   char msg[SLEN];
00681   char *array = NULL;
00682   char *tempstr = NULL;
00683   int strlen;
00684   int inimgaddr;
00685   IMAGE *inimg = NULL;
00686   int outimgaddr;
00687   IMAGE *outimg = NULL;
00688   char *outname = NULL;
00689   int option;
00690 
00691   if (argc != 2)
00692     {
00693       Tcl_AppendResult (interp, "wrong # args: should be \"",
00694                         argv[0], " arrayname\"", (char *) NULL);
00695       return TCL_ERROR;
00696     }
00697   array = argv[1];
00698 
00699   /* Read input image array(inimg,addr) */
00700   if (tclobj =
00701       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00702                       Tcl_NewStringObj ("inimg,addr", -1),
00703                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00704     {
00705       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
00706       if (strlen <= 0)
00707         return TCL_ERROR;
00708       sscanf (tempstr, "%x", &inimgaddr);
00709       inimg = (IMAGE *) inimgaddr;
00710     }
00711   else
00712     {
00713       return TCL_ERROR;
00714     }
00715 
00716   /* Read the input integer array(option) */
00717   if (tclobj =
00718       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00719                       Tcl_NewStringObj ("option", -1),
00720                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00721     {
00722       if (Tcl_GetIntFromObj (interp, tclobj, &option) == TCL_ERROR)
00723         return TCL_ERROR;
00724     }
00725   else
00726     {
00727       return TCL_ERROR;
00728     }
00729 
00730   /* Read the output image 1 name */
00731   if (tclobj =
00732       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00733                       Tcl_NewStringObj ("outname", -1),
00734                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00735     {
00736       outname = Tcl_GetStringFromObj (tclobj, &strlen);
00737       if (strlen <= 0)
00738         return TCL_ERROR;
00739     }
00740   else
00741     {
00742       return TCL_ERROR;
00743     }
00744 
00745   TRNSFORM (inimg, option, &outimg);
00746 
00747   if (CHECKIMG (outimg))
00748     sprintf (outimg->text, "%s", outname);
00749   outimgaddr = (int) outimg;
00750 
00751   sprintf (msg, "%x", outimgaddr);
00752   Tcl_SetResult (interp, msg, TCL_VOLATILE);
00753 
00754   return TCL_OK;
00755 }
00756 
00757 /*-Copyright Information------------------------------------------------------*/
00758 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00759 /*----------------------------------------------------------------------------*/
00760 /*-General Information--------------------------------------------------------*/
00761 /*                                                                            */
00762 /*   This procedure provides an interface to the SADIE function               */
00763 /*   GEOMCOEF from Tcl/Tk.  It expects a tcl global array                     */
00764 /*   with these indices to exist:                                             */
00765 /*       array(pointcount)                                                    */
00766 /*       array(termcount)                                                     */
00767 /*       array(trans,x,1-6)                                                   */
00768 /*       array(trans,y,1-6)                                                   */
00769 /*       array(ref,x,1-6)                                                     */
00770 /*       array(ref,y,1-6)                                                     */
00771 /*                                                                            */
00772 /*----------------------------------------------------------------------------*/
00773 /*-Interface Information------------------------------------------------------*/
00774 int
00775 Sadie_Geometry_ContPtsCmd (ClientData client_data, Tcl_Interp * interp,
00776                            int argc, char *argv[])
00777 {
00778   char *tclvar;
00779   int npts, nterms;
00780   double transx[6], transy[6], refx[6], refy[6];
00781   char index[50], *var = NULL;
00782   int i;
00783 
00784   if (argc != 2)
00785     {
00786       Tcl_AppendResult (interp, "wrong # args: should be \"",
00787                         argv[0], " arrayname\"", (char *) NULL);
00788       return TCL_ERROR;
00789     }
00790   var = argv[1];
00791 
00792   if (!
00793       (tclvar =
00794        Tcl_GetVar2 (interp, var, "pointcount",
00795                     TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)))
00796     {
00797       return TCL_ERROR;
00798     }
00799   if (Tcl_GetInt (interp, tclvar, &npts) != TCL_OK)
00800     {
00801       return TCL_ERROR;
00802     }
00803 
00804   if (!
00805       (tclvar =
00806        Tcl_GetVar2 (interp, var, "termcount",
00807                     TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)))
00808     {
00809       return TCL_ERROR;
00810     }
00811   if (Tcl_GetInt (interp, tclvar, &nterms) != TCL_OK)
00812     {
00813       return TCL_ERROR;
00814     }
00815 
00816   for (i = 0; i < 6; i++)
00817     {
00818       /* Get the transformation image x-control points */
00819       sprintf (index, "trans,x,%d", i + 1);
00820       if (!
00821           (tclvar =
00822            Tcl_GetVar2 (interp, var, index,
00823                         TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)))
00824         {
00825           return TCL_ERROR;
00826         }
00827       if (Tcl_GetDouble (interp, tclvar, &transx[i]) != TCL_OK)
00828         {
00829           return TCL_ERROR;
00830         }
00831 
00832       /* Get the transformation image y-control points */
00833       sprintf (index, "trans,y,%d", i + 1);
00834       if (!
00835           (tclvar =
00836            Tcl_GetVar2 (interp, var, index,
00837                         TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)))
00838         {
00839           return TCL_ERROR;
00840         }
00841       if (Tcl_GetDouble (interp, tclvar, &transy[i]) != TCL_OK)
00842         {
00843           return TCL_ERROR;
00844         }
00845 
00846       /* Get the reference image x-control points */
00847       sprintf (index, "ref,x,%d", i + 1);
00848       if (!
00849           (tclvar =
00850            Tcl_GetVar2 (interp, var, index,
00851                         TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)))
00852         {
00853           return TCL_ERROR;
00854         }
00855       if (Tcl_GetDouble (interp, tclvar, &refx[i]) != TCL_OK)
00856         {
00857           return TCL_ERROR;
00858         }
00859 
00860       /* Get the reference image y-control points */
00861       sprintf (index, "ref,y,%d", i + 1);
00862       if (!
00863           (tclvar =
00864            Tcl_GetVar2 (interp, var, index,
00865                         TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)))
00866         {
00867           return TCL_ERROR;
00868         }
00869       if (Tcl_GetDouble (interp, tclvar, &refy[i]) != TCL_OK)
00870         {
00871           return TCL_ERROR;
00872         }
00873 
00874     }
00875 
00876   GEOMCOEF ((double *) transx, (double *) transy, (double *) refx,
00877             (double *) refy, (short) npts, (short) nterms,
00878             (double *) xpolyterms, (double *) ypolyterms);
00879   numpolyterms = nterms;
00880 
00881   return TCL_OK;
00882 }
00883 
00884 /*-Copyright Information------------------------------------------------------*/
00885 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
00886 /*----------------------------------------------------------------------------*/
00887 /*-General Information--------------------------------------------------------*/
00888 /*                                                                            */
00889 /*   This procedure provides an interface to the SADIE function               */
00890 /*   GEOMWARP from Tcl/Tk.  It expects a tcl global array                     */
00891 /*   with these indices to exist:                                             */
00892 /*      array(inimg,addr)         --  SADIE image address                     */
00893 /*      array(lines)              --  int                                     */
00894 /*      array(pix)                --  int                                     */
00895 /*      array(option)             --  double                                  */
00896 /*      array(graylevel)          --  PIXEL                                   */
00897 /*      array(outname)            --  char*                                   */
00898 /*                                                                            */
00899 /*----------------------------------------------------------------------------*/
00900 /*-Interface Information------------------------------------------------------*/
00901 int
00902 Sadie_Geometry_GeomWarpCmd (ClientData client_data, Tcl_Interp * interp,
00903                             int argc, char *argv[])
00904 {
00905   Tcl_Obj *tclobj = NULL;
00906   char msg[SLEN];
00907   char *array = NULL;
00908   char *tempstr = NULL;
00909   int strlen;
00910   int inimgaddr;
00911   IMAGE *inimg = NULL;
00912   int outimgaddr;
00913   IMAGE *outimg = NULL;
00914   char *outname = NULL;
00915   int lines, pix;
00916   double option;
00917   PIXEL graylevel;
00918   double tempdouble;
00919 
00920   if (argc != 2)
00921     {
00922       Tcl_AppendResult (interp, "wrong # args: should be \"",
00923                         argv[0], " arrayname\"", (char *) NULL);
00924       return TCL_ERROR;
00925     }
00926   array = argv[1];
00927 
00928   /* Read input image array(inimg,addr) */
00929   if (tclobj =
00930       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00931                       Tcl_NewStringObj ("inimg,addr", -1),
00932                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00933     {
00934       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
00935       if (strlen <= 0)
00936         return TCL_ERROR;
00937       sscanf (tempstr, "%x", &inimgaddr);
00938       inimg = (IMAGE *) inimgaddr;
00939     }
00940   else
00941     {
00942       return TCL_ERROR;
00943     }
00944 
00945   /* Read the input integer array(lines) */
00946   if (tclobj =
00947       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00948                       Tcl_NewStringObj ("lines", -1),
00949                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00950     {
00951       if (Tcl_GetIntFromObj (interp, tclobj, &lines) == TCL_ERROR)
00952         return TCL_ERROR;
00953     }
00954   else
00955     {
00956       return TCL_ERROR;
00957     }
00958 
00959   /* Read the input integer array(pix) */
00960   if (tclobj =
00961       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00962                       Tcl_NewStringObj ("pix", -1),
00963                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00964     {
00965       if (Tcl_GetIntFromObj (interp, tclobj, &pix) == TCL_ERROR)
00966         return TCL_ERROR;
00967     }
00968   else
00969     {
00970       return TCL_ERROR;
00971     }
00972 
00973   /* Read the input double array(option) */
00974   if (tclobj =
00975       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00976                       Tcl_NewStringObj ("option", -1),
00977                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00978     {
00979       if (Tcl_GetDoubleFromObj (interp, tclobj, &option) == TCL_ERROR)
00980         return TCL_ERROR;
00981     }
00982   else
00983     {
00984       return TCL_ERROR;
00985     }
00986 
00987   /* Read the input PIXEL array(graylevel) */
00988   if (tclobj =
00989       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
00990                       Tcl_NewStringObj ("graylevel", -1),
00991                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
00992     {
00993       if (Tcl_GetDoubleFromObj (interp, tclobj, &tempdouble) == TCL_ERROR)
00994         return TCL_ERROR;
00995       graylevel = (PIXEL) tempdouble;
00996     }
00997   else
00998     {
00999       return TCL_ERROR;
01000     }
01001 
01002   /* Read the output image 1 name */
01003   if (tclobj =
01004       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01005                       Tcl_NewStringObj ("outname", -1),
01006                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01007     {
01008       outname = Tcl_GetStringFromObj (tclobj, &strlen);
01009       if (strlen <= 0)
01010         return TCL_ERROR;
01011     }
01012   else
01013     {
01014       return TCL_ERROR;
01015     }
01016 
01017   GEOMWARP (inimg, inimg->nbnd, (short) lines, (short) pix,
01018             (double *) xpolyterms, (double *) ypolyterms,
01019             (short) numpolyterms, option, graylevel, &outimg);
01020 
01021   if (CHECKIMG (outimg))
01022     sprintf (outimg->text, "%s", outname);
01023   outimgaddr = (int) outimg;
01024 
01025   sprintf (msg, "%x", outimgaddr);
01026   Tcl_SetResult (interp, msg, TCL_VOLATILE);
01027 
01028   return TCL_OK;
01029 }
01030 
01031 /*-Copyright Information------------------------------------------------------*/
01032 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
01033 /*----------------------------------------------------------------------------*/
01034 /*-General Information--------------------------------------------------------*/
01035 /*                                                                            */
01036 /*   This procedure provides an interface to the SADIE function               */
01037 /*   HMOSAIC from Tcl/Tk.  It expects a tcl global array                      */
01038 /*   with these indices to exist:                                             */
01039 /*      array(inimg,addr1)        --  SADIE image address                     */
01040 /*      array(inimg,addr2)        --  SADIE image address                     */
01041 /*      array(offset)             --  int                                     */
01042 /*      array(fill)               --  PIXEL                                   */
01043 /*      array(outname)            --  char*                                   */
01044 /*                                                                            */
01045 /*----------------------------------------------------------------------------*/
01046 /*-Interface Information------------------------------------------------------*/
01047 int
01048 Sadie_Geometry_HMosaicCmd (ClientData client_data, Tcl_Interp * interp,
01049                            int argc, char *argv[])
01050 {
01051   Tcl_Obj *tclobj = NULL;
01052   char msg[SLEN];
01053   char *array = NULL;
01054   char *tempstr = NULL;
01055   int strlen;
01056   int inimgaddr1, inimgaddr2;
01057   IMAGE *inimg1 = NULL, *inimg2 = NULL;
01058   int outimgaddr;
01059   IMAGE *outimg = NULL;
01060   char *outname = NULL;
01061   int offset;
01062   PIXEL fill;
01063   double tempdouble;
01064 
01065   if (argc != 2)
01066     {
01067       Tcl_AppendResult (interp, "wrong # args: should be \"",
01068                         argv[0], " arrayname\"", (char *) NULL);
01069       return TCL_ERROR;
01070     }
01071   array = argv[1];
01072 
01073   /* Read input image array(inimg,addr1) */
01074   if (tclobj =
01075       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01076                       Tcl_NewStringObj ("inimg,addr1", -1),
01077                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01078     {
01079       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01080       if (strlen <= 0)
01081         return TCL_ERROR;
01082       sscanf (tempstr, "%x", &inimgaddr1);
01083       inimg1 = (IMAGE *) inimgaddr1;
01084     }
01085   else
01086     {
01087       return TCL_ERROR;
01088     }
01089 
01090   /* Read input image array(inimg,addr2) */
01091   if (tclobj =
01092       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01093                       Tcl_NewStringObj ("inimg,addr2", -1),
01094                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01095     {
01096       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01097       if (strlen <= 0)
01098         return TCL_ERROR;
01099       sscanf (tempstr, "%x", &inimgaddr2);
01100       inimg2 = (IMAGE *) inimgaddr2;
01101     }
01102   else
01103     {
01104       return TCL_ERROR;
01105     }
01106 
01107   /* Read the input integer array(offset) */
01108   if (tclobj =
01109       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01110                       Tcl_NewStringObj ("offset", -1),
01111                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01112     {
01113       if (Tcl_GetIntFromObj (interp, tclobj, &offset) == TCL_ERROR)
01114         return TCL_ERROR;
01115     }
01116   else
01117     {
01118       return TCL_ERROR;
01119     }
01120 
01121   /* Read the input PIXEL array(fill) */
01122   if (tclobj =
01123       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01124                       Tcl_NewStringObj ("fill", -1),
01125                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01126     {
01127       if (Tcl_GetDoubleFromObj (interp, tclobj, &tempdouble) == TCL_ERROR)
01128         return TCL_ERROR;
01129       fill = (PIXEL) tempdouble;
01130     }
01131   else
01132     {
01133       return TCL_ERROR;
01134     }
01135 
01136   /* Read the output image 1 name */
01137   if (tclobj =
01138       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01139                       Tcl_NewStringObj ("outname", -1),
01140                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01141     {
01142       outname = Tcl_GetStringFromObj (tclobj, &strlen);
01143       if (strlen <= 0)
01144         return TCL_ERROR;
01145     }
01146   else
01147     {
01148       return TCL_ERROR;
01149     }
01150 
01151   HMOSAIC (inimg1, inimg2, offset, fill, &outimg);
01152 
01153   if (CHECKIMG (outimg))
01154     sprintf (outimg->text, "%s", outname);
01155   outimgaddr = (int) outimg;
01156 
01157   sprintf (msg, "%x", outimgaddr);
01158   Tcl_SetResult (interp, msg, TCL_VOLATILE);
01159 
01160   return TCL_OK;
01161 }
01162 
01163 /*-Copyright Information------------------------------------------------------*/
01164 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
01165 /*----------------------------------------------------------------------------*/
01166 /*-General Information--------------------------------------------------------*/
01167 /*                                                                            */
01168 /*   This procedure provides an interface to the SADIE function               */
01169 /*   VMOSAIC from Tcl/Tk.  It expects a tcl global array                      */
01170 /*   with these indices to exist:                                             */
01171 /*      array(inimg,addr1)        --  SADIE image address                     */
01172 /*      array(inimg,addr2)        --  SADIE image address                     */
01173 /*      array(offset)             --  int                                     */
01174 /*      array(fill)               --  PIXEL                                   */
01175 /*      array(outname)            --  char*                                   */
01176 /*                                                                            */
01177 /*----------------------------------------------------------------------------*/
01178 /*-Interface Information------------------------------------------------------*/
01179 int
01180 Sadie_Geometry_VMosaicCmd (ClientData client_data, Tcl_Interp * interp,
01181                            int argc, char *argv[])
01182 {
01183   Tcl_Obj *tclobj = NULL;
01184   char msg[SLEN];
01185   char *array = NULL;
01186   char *tempstr = NULL;
01187   int strlen;
01188   int inimgaddr1, inimgaddr2;
01189   IMAGE *inimg1 = NULL, *inimg2 = NULL;
01190   int outimgaddr;
01191   IMAGE *outimg = NULL;
01192   char *outname = NULL;
01193   int offset;
01194   PIXEL fill;
01195   double tempdouble;
01196 
01197   if (argc != 2)
01198     {
01199       Tcl_AppendResult (interp, "wrong # args: should be \"",
01200                         argv[0], " arrayname\"", (char *) NULL);
01201       return TCL_ERROR;
01202     }
01203   array = argv[1];
01204 
01205   /* Read input image array(inimg,addr1) */
01206   if (tclobj =
01207       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01208                       Tcl_NewStringObj ("inimg,addr1", -1),
01209                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01210     {
01211       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01212       if (strlen <= 0)
01213         return TCL_ERROR;
01214       sscanf (tempstr, "%x", &inimgaddr1);
01215       inimg1 = (IMAGE *) inimgaddr1;
01216     }
01217   else
01218     {
01219       return TCL_ERROR;
01220     }
01221 
01222   /* Read input image array(inimg,addr2) */
01223   if (tclobj =
01224       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01225                       Tcl_NewStringObj ("inimg,addr2", -1),
01226                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01227     {
01228       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01229       if (strlen <= 0)
01230         return TCL_ERROR;
01231       sscanf (tempstr, "%x", &inimgaddr2);
01232       inimg2 = (IMAGE *) inimgaddr2;
01233     }
01234   else
01235     {
01236       return TCL_ERROR;
01237     }
01238 
01239   /* Read the input integer array(offset) */
01240   if (tclobj =
01241       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01242                       Tcl_NewStringObj ("offset", -1),
01243                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01244     {
01245       if (Tcl_GetIntFromObj (interp, tclobj, &offset) == TCL_ERROR)
01246         return TCL_ERROR;
01247     }
01248   else
01249     {
01250       return TCL_ERROR;
01251     }
01252 
01253   /* Read the input PIXEL array(fill) */
01254   if (tclobj =
01255       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01256                       Tcl_NewStringObj ("fill", -1),
01257                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01258     {
01259       if (Tcl_GetDoubleFromObj (interp, tclobj, &tempdouble) == TCL_ERROR)
01260         return TCL_ERROR;
01261       fill = (PIXEL) tempdouble;
01262     }
01263   else
01264     {
01265       return TCL_ERROR;
01266     }
01267 
01268   /* Read the output image 1 name */
01269   if (tclobj =
01270       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01271                       Tcl_NewStringObj ("outname", -1),
01272                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01273     {
01274       outname = Tcl_GetStringFromObj (tclobj, &strlen);
01275       if (strlen <= 0)
01276         return TCL_ERROR;
01277     }
01278   else
01279     {
01280       return TCL_ERROR;
01281     }
01282 
01283   VMOSAIC (inimg1, inimg2, offset, fill, &outimg);
01284 
01285   if (CHECKIMG (outimg))
01286     sprintf (outimg->text, "%s", outname);
01287   outimgaddr = (int) outimg;
01288 
01289   sprintf (msg, "%x", outimgaddr);
01290   Tcl_SetResult (interp, msg, TCL_VOLATILE);
01291 
01292   return TCL_OK;
01293 }
01294 
01295 /*-Copyright Information------------------------------------------------------*/
01296 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
01297 /*----------------------------------------------------------------------------*/
01298 /*-General Information--------------------------------------------------------*/
01299 /*                                                                            */
01300 /*   This procedure provides an interface to the SADIE function               */
01301 /*   MOSAIC from Tcl/Tk.  It expects a tcl global array                       */
01302 /*   with these indices to exist:                                             */
01303 /*      array(lines)              --  int                                     */
01304 /*      array(pix)                --  int                                     */
01305 /*      array(fill)               --  PIXEL                                   */
01306 /*      array(outname)            --  char*                                   */
01307 /*                                                                            */
01308 /*----------------------------------------------------------------------------*/
01309 /*-Interface Information------------------------------------------------------*/
01310 int
01311 Sadie_Geometry_GenMosaicCmd (ClientData client_data, Tcl_Interp * interp,
01312                              int argc, char *argv[])
01313 {
01314   Tcl_Obj *tclobj = NULL;
01315   char msg[SLEN];
01316   char *array = NULL;
01317   char *tempstr = NULL;
01318   int strlen;
01319   int inimgaddr[2];
01320   IMAGE *inimg[2];
01321   int outimgaddr;
01322   IMAGE *outimg = NULL;
01323   char *outname = NULL;
01324   short offsetlines[2], offsetpix[2];
01325   int lines, pix, tempint;
01326   PIXEL fill;
01327   double tempdouble;
01328 
01329   if (argc != 2)
01330     {
01331       Tcl_AppendResult (interp, "wrong # args: should be \"",
01332                         argv[0], " arrayname\"", (char *) NULL);
01333       return TCL_ERROR;
01334     }
01335   array = argv[1];
01336 
01337   /* Read input image array(inimg,addr1) */
01338   if (tclobj =
01339       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01340                       Tcl_NewStringObj ("inimg,addr1", -1),
01341                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01342     {
01343       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01344       if (strlen <= 0)
01345         return TCL_ERROR;
01346       sscanf (tempstr, "%x", &inimgaddr[0]);
01347       inimg[0] = (IMAGE *) inimgaddr[0];
01348     }
01349   else
01350     {
01351       return TCL_ERROR;
01352     }
01353 
01354   /* Read input image array(inimg,addr2) */
01355   if (tclobj =
01356       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01357                       Tcl_NewStringObj ("inimg,addr2", -1),
01358                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01359     {
01360       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01361       if (strlen <= 0)
01362         return TCL_ERROR;
01363       sscanf (tempstr, "%x", &inimgaddr[1]);
01364       inimg[1] = (IMAGE *) inimgaddr[1];
01365     }
01366   else
01367     {
01368       return TCL_ERROR;
01369     }
01370 
01371   /* Read the input integer array(lines) */
01372   if (tclobj =
01373       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01374                       Tcl_NewStringObj ("lines", -1),
01375                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01376     {
01377       if (Tcl_GetIntFromObj (interp, tclobj, &lines) == TCL_ERROR)
01378         return TCL_ERROR;
01379     }
01380   else
01381     {
01382       return TCL_ERROR;
01383     }
01384 
01385   /* Read the input integer array(pix) */
01386   if (tclobj =
01387       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01388                       Tcl_NewStringObj ("pix", -1),
01389                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01390     {
01391       if (Tcl_GetIntFromObj (interp, tclobj, &pix) == TCL_ERROR)
01392         return TCL_ERROR;
01393     }
01394   else
01395     {
01396       return TCL_ERROR;
01397     }
01398 
01399   /* Read the input integer array(offset1,lines) */
01400   if (tclobj =
01401       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01402                       Tcl_NewStringObj ("offset1,lines", -1),
01403                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01404     {
01405       if (Tcl_GetIntFromObj (interp, tclobj, &tempint) == TCL_ERROR)
01406         return TCL_ERROR;
01407       offsetlines[0] = (short) tempint;
01408     }
01409   else
01410     {
01411       return TCL_ERROR;
01412     }
01413 
01414   /* Read the input integer array(offset2,lines) */
01415   if (tclobj =
01416       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01417                       Tcl_NewStringObj ("offset2,lines", -1),
01418                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01419     {
01420       if (Tcl_GetIntFromObj (interp, tclobj, &tempint) == TCL_ERROR)
01421         return TCL_ERROR;
01422       offsetlines[1] = (short) tempint;
01423     }
01424   else
01425     {
01426       return TCL_ERROR;
01427     }
01428 
01429   /* Read the input integer array(offset1,pix) */
01430   if (tclobj =
01431       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01432                       Tcl_NewStringObj ("offset1,pix", -1),
01433                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01434     {
01435       if (Tcl_GetIntFromObj (interp, tclobj, &tempint) == TCL_ERROR)
01436         return TCL_ERROR;
01437       offsetpix[0] = (short) tempint;
01438     }
01439   else
01440     {
01441       return TCL_ERROR;
01442     }
01443 
01444   /* Read the input integer array(offset2,pix) */
01445   if (tclobj =
01446       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01447                       Tcl_NewStringObj ("offset2,pix", -1),
01448                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01449     {
01450       if (Tcl_GetIntFromObj (interp, tclobj, &tempint) == TCL_ERROR)
01451         return TCL_ERROR;
01452       offsetpix[1] = (short) tempint;
01453     }
01454   else
01455     {
01456       return TCL_ERROR;
01457     }
01458 
01459   /* Read the input PIXEL array(fill) */
01460   if (tclobj =
01461       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01462                       Tcl_NewStringObj ("fill", -1),
01463                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01464     {
01465       if (Tcl_GetDoubleFromObj (interp, tclobj, &tempdouble) == TCL_ERROR)
01466         return TCL_ERROR;
01467       fill = (PIXEL) tempdouble;
01468     }
01469   else
01470     {
01471       return TCL_ERROR;
01472     }
01473 
01474   /* Read the output image 1 name */
01475   if (tclobj =
01476       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01477                       Tcl_NewStringObj ("outname", -1),
01478                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01479     {
01480       outname = Tcl_GetStringFromObj (tclobj, &strlen);
01481       if (strlen <= 0)
01482         return TCL_ERROR;
01483     }
01484   else
01485     {
01486       return TCL_ERROR;
01487     }
01488 
01489   MOSAIC (inimg, 2, lines, pix, offsetlines, offsetpix, fill, &outimg);
01490 
01491   if (CHECKIMG (outimg))
01492     sprintf (outimg->text, "%s", outname);
01493   outimgaddr = (int) outimg;
01494 
01495   sprintf (msg, "%x", outimgaddr);
01496   Tcl_SetResult (interp, msg, TCL_VOLATILE);
01497 
01498   return TCL_OK;
01499 }
01500 
01501 /*-Copyright Information------------------------------------------------------*/
01502 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
01503 /*----------------------------------------------------------------------------*/
01504 /*-General Information--------------------------------------------------------*/
01505 /*                                                                            */
01506 /*   This procedure provides an interface to the SADIE function               */
01507 /*   INSERT from Tcl/Tk.  It expects a tcl global array                       */
01508 /*   with these indices to exist:                                             */
01509 /*      array(inimg,addr1)        --  SADIE image address                     */
01510 /*      array(inimg,addr2)        --  SADIE image address                     */
01511 /*      array(offset,lines)       --  int                                     */
01512 /*      array(offset,pix)         --  int                                     */
01513 /*      array(outname)            --  char*                                   */
01514 /*                                                                            */
01515 /*----------------------------------------------------------------------------*/
01516 /*-Interface Information------------------------------------------------------*/
01517 int
01518 Sadie_Geometry_InsertCmd (ClientData client_data, Tcl_Interp * interp,
01519                           int argc, char *argv[])
01520 {
01521   Tcl_Obj *tclobj = NULL;
01522   char msg[SLEN];
01523   char *array = NULL;
01524   char *tempstr = NULL;
01525   int strlen;
01526   int inimgaddr1, inimgaddr2;
01527   IMAGE *inimg1 = NULL, *inimg2 = NULL;
01528   int outimgaddr;
01529   IMAGE *outimg = NULL;
01530   char *outname = NULL;
01531   int offsetlines, offsetpix;
01532 
01533   if (argc != 2)
01534     {
01535       Tcl_AppendResult (interp, "wrong # args: should be \"",
01536                         argv[0], " arrayname\"", (char *) NULL);
01537       return TCL_ERROR;
01538     }
01539   array = argv[1];
01540 
01541   /* Read input image array(inimg,addr1) */
01542   if (tclobj =
01543       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01544                       Tcl_NewStringObj ("inimg,addr1", -1),
01545                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01546     {
01547       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01548       if (strlen <= 0)
01549         return TCL_ERROR;
01550       sscanf (tempstr, "%x", &inimgaddr1);
01551       inimg1 = (IMAGE *) inimgaddr1;
01552     }
01553   else
01554     {
01555       return TCL_ERROR;
01556     }
01557 
01558   /* Read input image array(inimg,addr2) */
01559   if (tclobj =
01560       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01561                       Tcl_NewStringObj ("inimg,addr2", -1),
01562                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01563     {
01564       tempstr = Tcl_GetStringFromObj (tclobj, &strlen);
01565       if (strlen <= 0)
01566         return TCL_ERROR;
01567       sscanf (tempstr, "%x", &inimgaddr2);
01568       inimg2 = (IMAGE *) inimgaddr2;
01569     }
01570   else
01571     {
01572       return TCL_ERROR;
01573     }
01574 
01575   /* Read the input integer array(offset,lines) */
01576   if (tclobj =
01577       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01578                       Tcl_NewStringObj ("offset,lines", -1),
01579                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01580     {
01581       if (Tcl_GetIntFromObj (interp, tclobj, &offsetlines) == TCL_ERROR)
01582         return TCL_ERROR;
01583     }
01584   else
01585     {
01586       return TCL_ERROR;
01587     }
01588 
01589   /* Read the input integer array(offset,pix) */
01590   if (tclobj =
01591       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01592                       Tcl_NewStringObj ("offset,pix", -1),
01593                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01594     {
01595       if (Tcl_GetIntFromObj (interp, tclobj, &offsetpix) == TCL_ERROR)
01596         return TCL_ERROR;
01597     }
01598   else
01599     {
01600       return TCL_ERROR;
01601     }
01602 
01603   /* Read the output image 1 name */
01604   if (tclobj =
01605       Tcl_ObjGetVar2 (interp, Tcl_NewStringObj (array, -1),
01606                       Tcl_NewStringObj ("outname", -1),
01607                       TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG))
01608     {
01609       outname = Tcl_GetStringFromObj (tclobj, &strlen);
01610       if (strlen <= 0)
01611         return TCL_ERROR;
01612     }
01613   else
01614     {
01615       return TCL_ERROR;
01616     }
01617 
01618   INSERT (inimg1, inimg2, offsetlines, offsetpix, &outimg);
01619 
01620   if (CHECKIMG (outimg))
01621     sprintf (outimg->text, "%s", outname);
01622   outimgaddr = (int) outimg;
01623 
01624   sprintf (msg, "%x", outimgaddr);
01625   Tcl_SetResult (interp, msg, TCL_VOLATILE);
01626 
01627   return TCL_OK;
01628 }
01629 
01630 /*-Copyright Information------------------------------------------------------*/
01631 /* Copyright (c) 1999 by the University of Arizona Digital Image Analysis Lab */
01632 /*----------------------------------------------------------------------------*/
01633 /*-General Information--------------------------------------------------------*/
01634 /*                                                                            */
01635 /*   This procedure initializes the all of the procedures                     */
01636 /*   in this file by registering them with Tcl.                               */
01637 /*                                                                            */
01638 /*----------------------------------------------------------------------------*/
01639 /*-Interface Information------------------------------------------------------*/
01640 int
01641 Sadie_Geometry_Init (Tcl_Interp * interp)
01642 {
01643   Tcl_CreateCommand (interp, "Sadie_Geometry_AvgSub",
01644                      Sadie_Geometry_AvgSubCmd, (ClientData) NULL, NULL);
01645   Tcl_CreateCommand (interp, "Sadie_Geometry_WinSub",
01646                      Sadie_Geometry_WinSubCmd, (ClientData) NULL, NULL);
01647   Tcl_CreateCommand (interp, "Sadie_Geometry_Scale", Sadie_Geometry_ScaleCmd,
01648                      (ClientData) NULL, NULL);
01649   Tcl_CreateCommand (interp, "Sadie_Geometry_Rotate",
01650                      Sadie_Geometry_RotateCmd, (ClientData) NULL, NULL);
01651   Tcl_CreateCommand (interp, "Sadie_Geometry_Mirror",
01652                      Sadie_Geometry_MirrorCmd, (ClientData) NULL, NULL);
01653   Tcl_CreateCommand (interp, "Sadie_Geometry_ContPts",
01654                      Sadie_Geometry_ContPtsCmd, (ClientData) NULL, NULL);
01655   Tcl_CreateCommand (interp, "Sadie_Geometry_GeomWarp",
01656                      Sadie_Geometry_GeomWarpCmd, (ClientData) NULL, NULL);
01657   Tcl_CreateCommand (interp, "Sadie_Geometry_HMosaic",
01658                      Sadie_Geometry_HMosaicCmd, (ClientData) NULL, NULL);
01659   Tcl_CreateCommand (interp, "Sadie_Geometry_VMosaic",
01660                      Sadie_Geometry_VMosaicCmd, (ClientData) NULL, NULL);
01661   Tcl_CreateCommand (interp, "Sadie_Geometry_GenMosaic",
01662                      Sadie_Geometry_GenMosaicCmd, (ClientData) NULL, NULL);
01663   Tcl_CreateCommand (interp, "Sadie_Geometry_Insert",
01664                      Sadie_Geometry_InsertCmd, (ClientData) NULL, NULL);
01665 
01666   return TCL_OK;
01667 }

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