Main Page   Data Structures   File List   Data Fields   Globals  

vmosaic.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 mosaics two images vertically.                             */
00009 /*                                                                            */
00010 /*----------------------------------------------------------------------------*/
00011 /*-Interface Information------------------------------------------------------*/
00012 void
00013 VMOSAIC (IMAGE * in1,           /*  I   Pointer to the top input image.                       */
00014          IMAGE * in2,           /*  I   Pointer to the bottom input image.                    */
00015          short kbgn,            /*  I   Number of columns (positive or negative) to offset    */
00016          /*      bottom image with respect to top image.               */
00017          PIXEL glev,            /*  I   Graylevel to fill otherwise empty pixels.             */
00018          IMAGE ** out           /*  O   Address of a pointer to the output image.             */
00019 /*----------------------------------------------------------------------------*/
00020   )
00021 {
00022   register short i, j, k, nbnd, nlin, npix;
00023   char msg[SLEN];
00024 
00025   if (TIMES)
00026     TIMING (T_VMOSAIC);
00027   if (NAMES)
00028     {
00029       MESSAGE ('I', "");
00030       MESSAGE ('I', "VMOSAIC");
00031       MESSAGE ('I', "");
00032       sprintf (msg, " Top input image:      %s", in1->text);
00033       MESSAGE ('I', msg);
00034       sprintf (msg, " Bottom input image:   %s", in2->text);
00035       MESSAGE ('I', msg);
00036       sprintf (msg, " Horizontal offset:    %d", kbgn);
00037       MESSAGE ('I', msg);
00038       sprintf (msg, " Fill graylevel:     %12.4e", glev);
00039       MESSAGE ('I', msg);
00040       MESSAGE ('I', " ...............");
00041     }
00042 
00043   /* check input */
00044   if (!CHECKIMG (in1))
00045     {
00046       MESSAGE ('E', " Can't identify upper image.");
00047       goto the_end;
00048     }
00049   else if (!CHECKIMG (in2))
00050     {
00051       MESSAGE ('E', " Can't identify lower image.");
00052       goto the_end;
00053     }
00054   else if ((nbnd = in1->nbnd) != in2->nbnd)
00055     {
00056       MESSAGE ('E', " Number of bands must be identical in both images.");
00057       goto the_end;
00058     }
00059 
00060   /* create image of appropriate size */
00061   nlin = in1->nlin + in2->nlin;
00062   npix =
00063     kbgn > 0 ? max (in1->npix, in2->npix + kbgn) : max (in1->npix - kbgn,
00064                                                         in2->npix);
00065   if (!CHECKIMG (*out))
00066     GETMEM (nbnd, nlin, npix, out);
00067   if (!*out)
00068     goto the_end;
00069 
00070   /* concatenate images */
00071   for (i = 0; i < nbnd; i++)
00072     {
00073       for (j = 0; j < nlin; j++)
00074         {
00075           for (k = 0; k < npix; k++)
00076             {
00077               (*out)->data[i][j][k] = glev;
00078             }
00079         }
00080       if (kbgn > 0)
00081         {
00082           for (j = 0; j < in1->nlin; j++)
00083             {
00084               for (k = 0; k < in1->npix; k++)
00085                 {
00086                   (*out)->data[i][j][k] = in1->data[i][j][k];
00087                 }
00088             }
00089           for (j = 0; j < in2->nlin; j++)
00090             {
00091               for (k = 0; k < in2->npix; k++)
00092                 {
00093                   (*out)->data[i][j + in1->nlin][k + kbgn] =
00094                     in2->data[i][j][k];
00095                 }
00096             }
00097         }
00098       else                      /* (kbgn <= 0) */
00099         {
00100           for (j = 0; j < in1->nlin; j++)
00101             {
00102               for (k = 0; k < in1->npix; k++)
00103                 {
00104                   (*out)->data[i][j][k - kbgn] = in1->data[i][j][k];
00105                 }
00106             }
00107           for (j = 0; j < in2->nlin; j++)
00108             {
00109               for (k = 0; k < in2->npix; k++)
00110                 {
00111                   (*out)->data[i][j + in1->nlin][k] = in2->data[i][j][k];
00112                 }
00113             }
00114         }
00115     }
00116 
00117   /* compute new minimum and maximum */
00118   if (in1->npix == in2->npix && kbgn == 0)
00119     {
00120       (*out)->gmin = min (in1->gmin, in2->gmin);
00121       (*out)->gmax = max (in1->gmax, in2->gmax);
00122     }
00123   else
00124     {
00125       (*out)->gmin = min (glev, min (in1->gmin, in2->gmin));
00126       (*out)->gmax = max (glev, max (in1->gmax, in2->gmax));
00127     }
00128 
00129 the_end:
00130   if (TIMES)
00131     TIMING (T_EXIT);
00132 }

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