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 EXPAND (
00013 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 ) { register short i;
00023     char   msg[SLEN];
00024     double xc[3], yc[3];
00025 
00026     if (TIMES) TIMING(T_EXPAND);
00027     if (NAMES) {
00028         MESSAGE('I',"");
00029         MESSAGE('I',"EXPAND");
00030         MESSAGE('I',"");
00031         sprintf(msg," Input image:              %s",in->text);
00032         MESSAGE('I',msg);
00033         sprintf(msg," Scale factor: lines:    %12.4e",jfact);
00034         MESSAGE('I',msg);
00035         sprintf(msg,"               pixels:   %12.4e",kfact);
00036         MESSAGE('I',msg);
00037         if (option < 0.0) {
00038             sprintf(msg," Parametric cubic interpolation, alpha = %5.2f",option);
00039             MESSAGE('I',msg);
00040         } else if (option == 0.0) {
00041             MESSAGE('I'," Bilinear interpolation");
00042         } else if (option > 0.0) {
00043             MESSAGE('I'," Nearest-neighbor interpolation");
00044         }
00045         MESSAGE('I'," ...............");
00046     }
00047 
00048     /* check input */
00049     if (!CHECKIMG(in)) {
00050         MESSAGE('E'," Can't identify image.");
00051         goto the_end;
00052     } else if (jfact <= 0.0) {
00053         MESSAGE('E'," Line scaling factor must be greater than zero.");
00054         goto the_end;
00055     } else if (kfact <= 0.0) {
00056         MESSAGE('E'," Pixel scaling factor must be greater than zero.");
00057         goto the_end;
00058     }
00059 
00060     /* compute transformation coefficients and perform transformation */
00061     if (jfact == (double)((short)jfact)  &&  kfact == (double)((short)kfact)  &&  option > 0.0) {
00062         DUPL(in,0,0,0,1,(short)jfact,(short)kfact,in->nbnd,in->nlin,in->npix,out);
00063     } else {
00064         for (i=0; i<3; xc[i]=yc[i]=0.0,i++);
00065         xc[1] = 1.0/kfact;
00066         yc[2] = 1.0/jfact;
00067         GEOMWARP(in,in->nbnd,(short)ceil(jfact*(double)in->nlin),(short)ceil(kfact*(double)in->npix),xc,yc,3,option,(PIXEL)SMIN,out);
00068     }
00069 
00070     the_end:
00071     if (TIMES) TIMING(T_EXIT);
00072 }

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