Main Page   Data Structures   File List   Data Fields   Globals  

bsqtobil.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 combines several images to form a single multi-band        */
00009 /*   image (for disk or tape I/O). The input images may themselves be         */
00010 /*   multi-band, in which case the bands are concatenated sequentially.       */
00011 /*                                                                            */
00012 /*----------------------------------------------------------------------------*/
00013 /*-Interface Information------------------------------------------------------*/
00014 void
00015 BSQTOBIL (IMAGE ** in,          /*  I   Pointer to an array[nimg] containing pointers         */
00016           /*      to the input images.                                  */
00017           short nimg,           /*  I   Number of input images.                               */
00018           IMAGE ** out          /*  O   Address of a pointer to the output image.             */
00019 /*----------------------------------------------------------------------------*/
00020   )
00021 {
00022   register short i, j, k, l, m, nbnd, nlin, npix;
00023   char msg[SLEN];
00024   double pinc, psum;
00025 
00026   if (TIMES)
00027     TIMING (T_BSQTOBIL);
00028   if (NAMES)
00029     {
00030       MESSAGE ('I', "");
00031       MESSAGE ('I', "BSQTOBIL");
00032       MESSAGE ('I', "");
00033       sprintf (msg, " Number of input images:   %d", nimg);
00034       MESSAGE ('I', msg);
00035       for (i = 0; i < nimg; i++)
00036         {
00037           sprintf (msg, " Input image %3d:          %s", i + 1, in[i]->text);
00038           MESSAGE ('I', msg);
00039         }
00040       MESSAGE ('I', " ...............");
00041     }
00042 
00043   /* check input */
00044   for (i = 0; i < nimg; i++)
00045     {
00046       if (!CHECKIMG (in[i]))
00047         {
00048           MESSAGE ('E', " Can't identify image(s).");
00049           goto the_end;
00050         }
00051     }
00052   for (nlin = in[0]->nlin, i = 1; i < nimg; i++)
00053     {
00054       if (nlin != in[i]->nlin)
00055         {
00056           MESSAGE ('E', " Number of lines must be identical in all images.");
00057           goto the_end;
00058         }
00059     }
00060   for (npix = in[0]->npix, i = 1; i < nimg; i++)
00061     {
00062       if (npix != in[i]->npix)
00063         {
00064           MESSAGE ('E',
00065                    " Number of pixels/line must be identical in all images.");
00066           goto the_end;
00067         }
00068     }
00069 
00070   /* create image of appropriate size */
00071   for (nbnd = 0, i = 0; i < nimg; nbnd += in[i++]->nbnd);
00072   if (!CHECKIMG (*out))
00073     GETMEM (nbnd, nlin, npix, out);
00074   if (!*out)
00075     goto the_end;
00076 
00077   /* initialize progress indicator */
00078   if (LINES && !PROGRESS (psum = 0.0))
00079     goto the_end;
00080   pinc = 1.0 / (double) nbnd / (double) nlin;
00081 
00082   /* combine images */
00083   for (m = 0, i = 0; i < nimg; i++)
00084     {
00085       for (j = 0; j < in[i]->nbnd; j++, m++)
00086         {
00087           for (k = 0; k < nlin; k++)
00088             {
00089               for (l = 0; l < npix; l++)
00090                 {
00091                   (*out)->data[m][k][l] = in[i]->data[j][k][l];
00092                 }
00093               if (LINES && !PROGRESS (psum += pinc))
00094                 goto the_end;
00095             }
00096         }
00097     }
00098 
00099 the_end:
00100   if (TIMES)
00101     TIMING (T_EXIT);
00102 }

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