Main Page   Data Structures   File List   Data Fields   Globals  

dupl.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 enlarges an image by replicating bands, lines, and pixels. */
00009 /*                                                                            */
00010 /*----------------------------------------------------------------------------*/
00011 /*-Interface Information------------------------------------------------------*/
00012 void
00013 DUPL (IMAGE * in,               /*  I   Pointer to the input image.                           */
00014       short ibgn,               /*  I   First replicated band.                                */
00015       short jbgn,               /*  I   First replicated line.                                */
00016       short kbgn,               /*  I   First replicated pixel.                               */
00017       short ifact,              /*  I   Band replication factor.                              */
00018       short jfact,              /*  I   Line replication factor.                              */
00019       short kfact,              /*  I   Pixel replication factor.                             */
00020       short isize,              /*  I   Number of replicated bands.                           */
00021       short jsize,              /*  I   Number of replicated lines.                           */
00022       short ksize,              /*  I   Number of replicated pixels.                          */
00023       IMAGE ** out              /*  O   Address of a pointer to the output image.             */
00024 /*----------------------------------------------------------------------------*/
00025   )
00026 {
00027   register short i, j, k, l, m, n;
00028   char msg[SLEN];
00029 
00030   if (TIMES)
00031     TIMING (T_DUPL);
00032   if (NAMES)
00033     {
00034       MESSAGE ('I', "");
00035       MESSAGE ('I', "DUPL");
00036       MESSAGE ('I', "");
00037       sprintf (msg, " Input image:                                   %s",
00038                in->text);
00039       MESSAGE ('I', msg);
00040       sprintf (msg,
00041                " First replicated band, line, pixel:            %d, %d, %d",
00042                ibgn + 1, jbgn + 1, kbgn + 1);
00043       MESSAGE ('I', msg);
00044       sprintf (msg,
00045                " Replication factor for bands, lines, pixels:   %d, %d, %d",
00046                ifact, jfact, kfact);
00047       MESSAGE ('I', msg);
00048       sprintf (msg,
00049                " Number of replicated bands, lines, pixels:     %d, %d, %d",
00050                isize, jsize, ksize);
00051       MESSAGE ('I', msg);
00052       MESSAGE ('I', " ...............");
00053     }
00054 
00055   /* check input */
00056   if (!CHECKIMG (in))
00057     {
00058       MESSAGE ('E', " Can't identify image.");
00059       goto the_end;
00060     }
00061   else if (0 > ibgn || ibgn + isize > in->nbnd)
00062     {
00063       MESSAGE ('E',
00064                " Block band range to be duplicated must be located completely inside input image.");
00065       goto the_end;
00066     }
00067   else if (0 > jbgn || jbgn + jsize > in->nlin)
00068     {
00069       MESSAGE ('E',
00070                " Block line range to be duplicated must be located completely inside input image.");
00071       goto the_end;
00072     }
00073   else if (0 > kbgn || kbgn + ksize > in->npix)
00074     {
00075       MESSAGE ('E',
00076                " Block pixel range to be duplicated must be located completely inside input image.");
00077       goto the_end;
00078     }
00079   else if (ifact <= 0)
00080     {
00081       MESSAGE ('E', " Band duplication factor must be greater than zero.");
00082       goto the_end;
00083     }
00084   else if (jfact <= 0)
00085     {
00086       MESSAGE ('E', " Line duplication factor must be greater than zero.");
00087       goto the_end;
00088     }
00089   else if (kfact <= 0)
00090     {
00091       MESSAGE ('E', " Pixel duplication factor must be greater than zero.");
00092       goto the_end;
00093     }
00094   else if (isize <= 0)
00095     {
00096       MESSAGE ('E',
00097                " Size of block in bands to be duplicated must be greater then zero.");
00098       goto the_end;
00099     }
00100   else if (jsize <= 0)
00101     {
00102       MESSAGE ('E',
00103                " Size of block in lines to be duplicated must be greater then zero.");
00104       goto the_end;
00105     }
00106   else if (ksize <= 0)
00107     {
00108       MESSAGE ('E',
00109                " Size of block in pixels/line to be duplicated must be greater then zero.");
00110       goto the_end;
00111     }
00112 
00113   /* create image of appropriate size */
00114   if (!CHECKIMG (*out))
00115     GETMEM (isize * ifact, jsize * jfact, ksize * kfact, out);
00116   if (!*out)
00117     goto the_end;
00118 
00119   /* duplicate the image data */
00120   for (i = ibgn; i < ibgn + isize; i++)
00121     {
00122       for (j = jbgn; j < jbgn + jsize; j++)
00123         {
00124           for (k = kbgn; k < kbgn + ksize; k++)
00125             {
00126               for (l = 0; l < ifact; l++)
00127                 {
00128                   for (m = 0; m < jfact; m++)
00129                     {
00130                       for (n = 0; n < kfact; n++)
00131                         {
00132                           (*out)->data[i * ifact + l][j * jfact +
00133                                                       m][k * kfact + n] =
00134                             in->data[i][j][k];
00135                         }
00136                     }
00137                 }
00138             }
00139         }
00140     }
00141   (*out)->gmin = in->gmin;
00142   (*out)->gmax = in->gmax;
00143 
00144 the_end:
00145   if (TIMES)
00146     TIMING (T_EXIT);
00147 }

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