Main Page | Data Structures | Directories | File List | Data Fields | Globals

Sadie_Geometry.c File Reference

A Tcl/Tk interface to the SADIE image warping and resampling functions. More...

#include <tcl.h>
#include <tk.h>
#include <stdio.h>
#include <string.h>
#include <sadie.h>
#include "tclsadie.h"

Go to the source code of this file.

Defines

#define MAX_POLY_TERM   6
#define N_MOSAIC_IMAGES   2
 Number of images to combine.

Functions

int Sadie_Geometry_AvgSubCmd (ClientData client_data, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 Resample an image using the averages within a sliding rectangular window.
int Sadie_Geometry_WinSubCmd (ClientData client_data, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 Extract a sub-image from an image, with optional scaling (by decimation).
int Sadie_Geometry_ScaleCmd (ClientData client_data, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 Re-scale an image using cubic, bilinear, or nearest-neighbor interpolation.
int Sadie_Geometry_RotateCmd (ClientData client_data, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 Rotate an image using cubic, bilinear, or nearest-neighbor interpolation.
int Sadie_Geometry_MirrorCmd (ClientData client_data, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 Rotate or reflect an image by pre-defined amounts.
int Sadie_Geometry_ContPtsCmd (ClientData client_data, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 Derive a best-fit polynomial from pairs of image and control points.
int Sadie_Geometry_GeomWarpCmd (ClientData client_data, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 Use a previously determined polynomial distortion model to warp an image.
int Sadie_Geometry_HMosaicCmd (ClientData client_data, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 Tile two images edge-to-edge horizontally, with an optional vertical offset.
int Sadie_Geometry_VMosaicCmd (ClientData client_data, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 Tile two images edge-to-edge vertically, with an optional horizontal offset.
int Sadie_Geometry_GenMosaicCmd (ClientData client_data, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 Combine multiple images into a single mosaic.
int Sadie_Geometry_InsertCmd (ClientData client_data, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
 Insert paste one image on top of another.
int Sadie_Geometry_Init (Tcl_Interp *interp)
 Make the commands defined in this file accessible to the Tcl interpreter.


Detailed Description

A Tcl/Tk interface to the SADIE image warping and resampling functions.

The SADIE library provides some geometric transformations (from simple re-scalings and rotations to fitting polynomial distortion models with variable numbers of terms), and the corresponding re-sampling operations to generate the transformed images. For more details see Chapter 7, Section 4 "Distortion Correction" in R. A. Schowengerdt Remote Sensing (2nd. ed.) Academic Press: 1997. Here we define some interfaces to Tcl code, without adding any additional operations.

Author:
University of Arizona Digital Image Analysis Lab
Date:
1999, 2004
Version:
Id
Sadie_Geometry.c,v 2.6 2005/03/22 22:08:40 mmunro Exp

Definition in file Sadie_Geometry.c.


Function Documentation

int Sadie_Geometry_AvgSubCmd ClientData  client_data,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj *const   objv[]
 

Resample an image using the averages within a sliding rectangular window.

The SADIE library function RESAMPL resamples an image at the specified horizontal and vertical intervals via averages within a sliding rectangular window, whose size can also be specified. We set these parameters from Tcl variables and invoke it. The Tcl data should conform to the patterns:

  • tcl_array_name(DEFAULT_IN_IMAGE_ADDR_INDEX) input image ID string.
  • tcl_array_name(lines) the number of lines in the sliding window.
  • tcl_array_name(pix) the number of pixels per line in the window.
  • tcl_array_name(incrlines) the line resampling interval.
  • tcl_array_name(incrpix) the pixel resampling interval.
  • tcl_array_name(DEFAULT_OUT_IMAGE_NAME_INDEX) output image name.

Parameters:
[in] client_data (unused).
[in] interp the main Tcl interpreter.
[in] objc number of Tcl object arguments (always two).
[in] objv Tcl object argument list (the Tcl array name).
Returns:
TCL_OK on success, TCL_ERROR on errors.

Definition at line 83 of file Sadie_Geometry.c.

int Sadie_Geometry_ContPtsCmd ClientData  client_data,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj *const   objv[]
 

Derive a best-fit polynomial from pairs of image and control points.

Given a set of pairs of points (one in image coordinates, the other in the desired reference frame, such as ground control points in map coordinates), the SADIE library function GEOMCOEF determines a polynomial that defines a good mapping between the two coordinate frames, with "good" implying some minimum of the squared errors (defferences between actual point positions and those from the transformation defined by the polynomial). The number of point pairs used by GEOMCOEF can vary, as can the number of terms in the polynomial it generates (provided they are no ambiguities by having this greater than the number of point pairs), but when providing the coordiates via Tcl array elements we always give the maximum possible number and ignore those that are unnecesary. At the moment the polynomial terms end up in global arrays, horribly usafe from the point of re-entrancy or thread safety. The Tcl data should conform to the patterns:

  • tcl_array_name(pointcount) the number of point pairs.
  • tcl_array_name(termcount) the number of polynomial terms.
  • tcl_array_name(trans,x,(point_number)) distorted frame x coordinates.
  • tcl_array_name(trans,y,(point_number)) distorted frame y coordinates.
  • tcl_array_name(ref,x,(point_number)) reference frame x coordinates.
  • tcl_array_name(ref,y,(point_number)) reference frame y coordinates.

Parameters:
[in] client_data (unused).
[in] interp the main Tcl interpreter.
[in] objc number of Tcl object arguments (always two).
[in] objv Tcl object argument list (the Tcl array name).
Returns:
TCL_OK on success, TCL_ERROR on errors.

Definition at line 363 of file Sadie_Geometry.c.

int Sadie_Geometry_GenMosaicCmd ClientData  client_data,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj *const   objv[]
 

Combine multiple images into a single mosaic.

The SADIE library function MOSAIC can potentially combine various numbers of individual images into a mosaic, but this Tcl interface restricts these to one small constant (at the moment, only two images). It places the individual images at offsets specified in pixel units relative to the top left corner of the mosaic image, filling any otherwise blank areas with pixels of the specified greyvalue. The Tcl data should conform to the patterns:

  • tcl_array_name(inimg,addr1) first input image ID string.
  • tcl_array_name(inimg,addr2) second input image ID string.
  • tcl_array_name(lines) number of lines in the mosaic.
  • tcl_array_name(pix) number of pixel columns in the mosaic.
  • tcl_array_name(offset1,lines) vertical offset for the first image.
  • tcl_array_name(offset1,pix) horizontal offset for the first image.
  • tcl_array_name(offset2,lines) vertical offset for the second image.
  • tcl_array_name(offset2,pix) horizontal offset for the second image.
  • tcl_array_name(fill) the value for otherwise blank pixels.
  • tcl_array_name(DEFAULT_OUT_IMAGE_NAME_INDEX) combined image name.

Parameters:
[in] client_data (unused).
[in] interp the main Tcl interpreter.
[in] objc number of Tcl object arguments (always two).
[in] objv Tcl object argument list (the Tcl array name).
Returns:
TCL_OK on success, TCL_ERROR on errors.

Definition at line 593 of file Sadie_Geometry.c.

int Sadie_Geometry_GeomWarpCmd ClientData  client_data,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj *const   objv[]
 

Use a previously determined polynomial distortion model to warp an image.

Given a distorted image and a series of polynomial terms that define the distortion relative to some reference frame, the SADIE library function GEOMWARP generates a new image representing the distorted image in the reference frame with the distortion removed, using interpolation guided by the distortion model. The option variable determines the interpolation technique: negative values for cubic interpolation (with the value being interpreted as the free parameter alpha for this method), zero values imply bilinear interpolation, and positive values nearest-neighbor interpolation. Note that the polynomial terms come from an uprotected global array, so there are issues with re-entrancy and thread safety. The Tcl data should conform to the patterns:

  • tcl_array_name((DEFAULT_IN_IMAGE_ADDR_INDEX) distorted image ID.
  • tcl_array_name(lines) the number of lines in the interpolated image.
  • tcl_array_name(pix) pixels per line in the interpolated image.
  • tcl_array_name(option) the interpolation option.
  • tcl_array_name(graylevel) the greyvalue with which to fill blanks.
  • tcl_array_name(DEFAULT_OUT_IMAGE_NAME_INDEX) the warped image name.

Parameters:
[in] client_data (unused).
[in] interp the main Tcl interpreter.
[in] objc number of Tcl object arguments (always two).
[in] objv Tcl object argument list (the Tcl array name).
Returns:
TCL_OK on success, TCL_ERROR on errors.

Definition at line 434 of file Sadie_Geometry.c.

int Sadie_Geometry_HMosaicCmd ClientData  client_data,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj *const   objv[]
 

Tile two images edge-to-edge horizontally, with an optional vertical offset.

The SADIE library function HMOSAIC creates a new image from two input images arranged next to each other horizontally, optionally staggering them in the vertical direction by the specified number of lines, and filling any spaces between the copied component images and their enclosing frame with pixels of the specified greyvalue. The Tcl data should conform to the patterns:

  • tcl_array_name(inimg,addr1) left input image ID string.
  • tcl_array_name(inimg,addr2) right input image ID string.
  • tcl_array_name(offset) vertical offset for the right image.
  • tcl_array_name(fill) the value for otherwise blank pixels.
  • tcl_array_name(DEFAULT_OUT_IMAGE_NAME_INDEX) tiled image name.

Parameters:
[in] client_data (unused).
[in] interp the main Tcl interpreter.
[in] objc number of Tcl object arguments (always two).
[in] objv Tcl object argument list (the Tcl array name).
Returns:
TCL_OK on success, TCL_ERROR on errors.

Definition at line 486 of file Sadie_Geometry.c.

int Sadie_Geometry_Init Tcl_Interp *  interp  ) 
 

Make the commands defined in this file accessible to the Tcl interpreter.

Parameters:
[in] interp the main Tcl interpreter.
Returns:
TCL_OK on success.

Definition at line 682 of file Sadie_Geometry.c.

Referenced by Tcl_AppInit().

int Sadie_Geometry_InsertCmd ClientData  client_data,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj *const   objv[]
 

Insert paste one image on top of another.

Given two images, the SADIE library function INSERT treats one as the background and the other as the (opaque) foreground, pasting the foreground on top of the background at the specified pixel unit offsets. The Tcl data should conform to the patterns:

  • tcl_array_name(inimg,addr1) background image ID string.
  • tcl_array_name(inimg,addr2) foreground image ID string.
  • tcl_array_name(offset,lines) vertical foreground image offset.
  • tcl_array_name(offset,pix) horizontal foreground image offset.
  • tcl_array_name(DEFAULT_OUT_IMAGE_NAME_INDEX) combined image name.

Parameters:
[in] client_data (unused).
[in] interp the main Tcl interpreter.
[in] objc number of Tcl object arguments (always two).
[in] objv Tcl object argument list (the Tcl array name).
Returns:
TCL_OK on success, TCL_ERROR on errors.

Definition at line 646 of file Sadie_Geometry.c.

int Sadie_Geometry_MirrorCmd ClientData  client_data,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj *const   objv[]
 

Rotate or reflect an image by pre-defined amounts.

The SADIE library function TRNSFORM flips an image according to a small number of simple transformations, selected by one of a set of codes defined in sadie.h :

  • FLIP0 reflect about a vertical axis.
  • FLIPM45 reflect about a -45 degree diagonal.
  • FLIPP45 reflect about a +45 degree diagonal.
  • FLIP90 reflect about a horizontal axis.
  • ROTPM0 copy without transformation.
  • ROTP90 rotate +90 degrees.
  • ROTM90 rotate -90 degrees.
  • ROT180 rotate 180 degrees.

The Tcl data should conform to the patterns:

  • tcl_array_name(DEFAULT_IN_IMAGE_ADDR_INDEX) input image ID string.
  • tcl_array_name(option) the transformation code number.
  • tcl_array_name(DEFAULT_OUT_IMAGE_NAME_INDEX) transformed image name.

Parameters:
[in] client_data (unused).
[in] interp the main Tcl interpreter.
[in] objc number of Tcl object arguments (always two).
[in] objv Tcl object argument list (the Tcl array name).
Returns:
TCL_OK on success, TCL_ERROR on errors.

Definition at line 312 of file Sadie_Geometry.c.

int Sadie_Geometry_RotateCmd ClientData  client_data,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj *const   objv[]
 

Rotate an image using cubic, bilinear, or nearest-neighbor interpolation.

The SADIE library function GEOMWARP can apply a wide range of polynomial transformations to an image, and can use three different re-sampling methods in generating the transformed image. Here we use the ROTATE function, which uses the GEOMCOEF function to derive the polynomial coefficients equivalent to the specified rotation, before invoking GEOMWARP itself, or recognizes the special cases that TRNSFORM can handle via simple flips. The angle parameter is in degrees; the option variable determines the interpolation technique: negative values for cubic interpolation (with the value being interpreted as the free parameter alpha for this method), zero values imply bilinear interpolation, and positive values nearest-neighbor interpolation. The Tcl data should conform to the patterns:

  • tcl_array_name(DEFAULT_IN_IMAGE_ADDR_INDEX) raw image ID string.
  • tcl_array_name(angle) the angle by which to rotate the image.
  • tcl_array_name(option) the interpolation option.
  • tcl_array_name(graylevel) the greyvalue with which to fill blanks.
  • tcl_array_name(DEFAULT_OUT_IMAGE_NAME_INDEX) rotated image name.

Parameters:
[in] client_data (unused).
[in] interp the main Tcl interpreter.
[in] objc number of Tcl object arguments (always two).
[in] objv Tcl object argument list (the Tcl array name).
Returns:
TCL_OK on success, TCL_ERROR on errors.

Definition at line 260 of file Sadie_Geometry.c.

int Sadie_Geometry_ScaleCmd ClientData  client_data,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj *const   objv[]
 

Re-scale an image using cubic, bilinear, or nearest-neighbor interpolation.

The SADIE library function GEOMWARP can apply a wide range of polynomial transformations to an image, and can use three different re-sampling methods in generating the transformed image. Here we use the EXPAND function, which invokes GEOMWARP to handle the simple specific case of uniform but independent scalings in the horizontal and vertical directions, unless the scale factors are trivial integer multipliers, in which case it uses the DUPL SADIE function instead. Despite the Tcl names, the lines and pix indices are to scale factors, not sizes. The option variable determines the interpolation technique: negative values for cubic interpolation (with the value being interpreted as the free parameter alpha for this method), zero values imply bilinear interpolation, and positive values nearest-neighbor interpolation. The Tcl data should conform to the patterns:

  • tcl_array_name(DEFAULT_IN_IMAGE_ADDR_INDEX) raw image ID string.
  • tcl_array_name(lines) the vertical scale factor.
  • tcl_array_name(pix) the horizontal scale factor.
  • tcl_array_name(option) the interpolation option.
  • tcl_array_name(DEFAULT_OUT_IMAGE_NAME_INDEX) resampled image name.

Parameters:
[in] client_data (unused).
[in] interp the main Tcl interpreter.
[in] objc number of Tcl object arguments (always two).
[in] objv Tcl object argument list (the Tcl array name).
Returns:
TCL_OK on success, TCL_ERROR on errors.

Definition at line 207 of file Sadie_Geometry.c.

int Sadie_Geometry_VMosaicCmd ClientData  client_data,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj *const   objv[]
 

Tile two images edge-to-edge vertically, with an optional horizontal offset.

The SADIE library function VMOSAIC creates a new image from two input images arranged next to each other vertically, optionally staggering them in the horizontal direction by the specified number of pixel columns, and filling any spaces between the copied component images and their enclosing frame with pixels of the specified greyvalue. The Tcl data should conform to the patterns:

  • tcl_array_name(inimg,addr1) top input image ID string.
  • tcl_array_name(inimg,addr2) bottom input image ID string.
  • tcl_array_name(offset) horizontal offset for the bottom image.
  • tcl_array_name(fill) the value for otherwise blank pixels.
  • tcl_array_name(DEFAULT_OUT_IMAGE_NAME_INDEX) combined image name.

Parameters:
[in] client_data (unused).
[in] interp the main Tcl interpreter.
[in] objc number of Tcl object arguments (always two).
[in] objv Tcl object argument list (the Tcl array name).
Returns:
TCL_OK on success, TCL_ERROR on errors.

Definition at line 535 of file Sadie_Geometry.c.

int Sadie_Geometry_WinSubCmd ClientData  client_data,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj *const   objv[]
 

Extract a sub-image from an image, with optional scaling (by decimation).

The SADIE library function SUBSAMPL extracts a sub-image from a SADIE image, optionally shrinking the extracted image (selecting pixels at the specified horizontal and vertical spacings, without any averaging or interpolation). The Tcl data should conform to the patterns:

  • tcl_array_name(DEFAULT_IN_IMAGE_ADDR_INDEX) raw image ID string.
  • tcl_array_name(from,band) the first band to include in the subimage.
  • tcl_array_name(to,band) the last band to include in the subimage.
  • tcl_array_name(incr,band) band spacing interval (1 for each band).
  • tcl_array_name(from,line) the first line to include in the subimage.
  • tcl_array_name(to,line) the last line to include in the subimage.
  • tcl_array_name(incr,line) line spacing interval (1 for no shrinking).
  • tcl_array_name(from,pixel) the first pixel to include in the subimage.
  • tcl_array_name(to,pixel) the last pixel to include in the subimage.
  • tcl_array_name(incr,pixel) pixel spacing interval (1 for no shrinking).
  • tcl_array_name(DEFAULT_OUT_IMAGE_NAME_INDEX) output image name.

Parameters:
[in] client_data (unused).
[in] interp the main Tcl interpreter.
[in] objc number of Tcl object arguments (always two).
[in] objv Tcl object argument list (the Tcl array name).
Returns:
TCL_OK on success, TCL_ERROR on errors.

Definition at line 136 of file Sadie_Geometry.c.


Generated on Fri Jul 8 14:55:02 2005 for tclSadie by  doxygen 1.4.2