Main Page   Data Structures   File List   Data Fields   Globals  

expand.c

Go to the documentation of this file.
00001 #include        "sadie.h"
00002 
00003 /*-Copyright Information------------------------------------------------------*/
00004 /* Copyright (c) 1988 by the University of Arizona Digital Image Analysis Lab */
00005 /*----------------------------------------------------------------------------*/
00006 /*-General Information--------------------------------------------------------*/
00007 /*                                                                            */
00008 /*   This function expands or contracts an image by scale factors.            */
00009 /*                                                                            */
00010 /*----------------------------------------------------------------------------*/
00011 /*-Interface Information------------------------------------------------------*/
00012 void
00013 EXPAND (IMAGE * in,             /*  I   Pointer to the input image.                           */
00014         double jfact,           /*  I   Line scale factor.                                    */
00015         double kfact,           /*  I   Pixel scale factor.                                   */
00016         double option,          /*  I   Switch, determines interpolation method:              */
00017         /*      < 0.0   -   Cubic interpolation (alpha = option).     */
00018         /*      = 0.0   -   Bilinear interpolation.                   */
00019         /*      > 0.0   -   Nearest neighbor interpolation.           */
00020         IMAGE ** out            /*  O   Address of a pointer to the output image.             */
00021 /*----------------------------------------------------------------------------*/
00022   )
00023 {
00024   register short i;
00025   char msg[SLEN];
00026   double xc[3], yc[3];
00027 
00028   if (TIMES)
00029     TIMING (T_EXPAND);
00030   if (NAMES)
00031     {
00032       MESSAGE ('I', "");
00033       MESSAGE ('I', "EXPAND");
00034       MESSAGE ('I', "");
00035       sprintf (msg, " Input image:              %s", in->text);
00036       MESSAGE ('I', msg);
00037       sprintf (msg, " Scale factor: lines:    %12.4e", jfact);
00038       MESSAGE ('I', msg);
00039       sprintf (msg, "               pixels:   %12.4e", kfact);
00040       MESSAGE ('I', msg);
00041       if (option < 0.0)
00042         {
00043           sprintf (msg, " Parametric cubic interpolation, alpha = %5.2f",
00044                    option);
00045           MESSAGE ('I', msg);
00046         }
00047       else if (option == 0.0)
00048         {
00049           MESSAGE ('I', " Bilinear interpolation");
00050         }
00051       else if (option > 0.0)
00052         {
00053           MESSAGE ('I', " Nearest-neighbor interpolation");
00054         }
00055       MESSAGE ('I', " ...............");
00056     }
00057 
00058   /* check input */
00059   if (!CHECKIMG (in))
00060     {
00061       MESSAGE ('E', " Can't identify image.");
00062       goto the_end;
00063     }
00064   else if (jfact <= 0.0)
00065     {
00066       MESSAGE ('E', " Line scaling factor must be greater than zero.");
00067       goto the_end;
00068     }
00069   else if (kfact <= 0.0)
00070     {
00071       MESSAGE ('E', " Pixel scaling factor must be greater than zero.");
00072       goto the_end;
00073     }
00074 
00075   /* compute transformation coefficients and perform transformation */
00076   if (jfact == (double) ((short) jfact) && kfact == (double) ((short) kfact)
00077       && option > 0.0)
00078     {
00079       DUPL (in, 0, 0, 0, 1, (short) jfact, (short) kfact, in->nbnd, in->nlin,
00080             in->npix, out);
00081     }
00082   else
00083     {
00084       for (i = 0; i < 3; xc[i] = yc[i] = 0.0, i++);
00085       xc[1] = 1.0 / kfact;
00086       yc[2] = 1.0 / jfact;
00087       GEOMWARP (in, in->nbnd, (short) ceil (jfact * (double) in->nlin),
00088                 (short) ceil (kfact * (double) in->npix), xc, yc, 3, option,
00089                 (PIXEL) SMIN, out);
00090     }
00091 
00092 the_end:
00093   if (TIMES)
00094     TIMING (T_EXIT);
00095 }

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