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 BSQTOBIL (
00015 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 ) { register short i, j, k, l, m, nbnd, nlin, npix;
00021     char   msg[SLEN];
00022     double pinc, psum;
00023 
00024     if (TIMES) TIMING(T_BSQTOBIL);
00025     if (NAMES) {
00026         MESSAGE('I',"");
00027         MESSAGE('I',"BSQTOBIL");
00028         MESSAGE('I',"");
00029         sprintf(msg," Number of input images:   %d",nimg);
00030         MESSAGE('I',msg);
00031         for (i=0; i<nimg; i++) {
00032             sprintf(msg," Input image %3d:          %s",i+1,in[i]->text);
00033             MESSAGE('I',msg);
00034         }
00035         MESSAGE('I'," ...............");
00036     }
00037 
00038     /* check input */
00039     for (i=0; i<nimg; i++) {
00040         if (!CHECKIMG(in[i])) {
00041             MESSAGE('E'," Can't identify image(s).");
00042             goto the_end;
00043         }
00044     }
00045     for (nlin=in[0]->nlin,i=1; i<nimg; i++) {
00046         if (nlin != in[i]->nlin) {
00047             MESSAGE('E'," Number of lines must be identical in all images.");
00048             goto the_end;
00049         }
00050     }
00051     for (npix=in[0]->npix,i=1; i<nimg; i++) {
00052         if (npix != in[i]->npix) {
00053             MESSAGE('E'," Number of pixels/line must be identical in all images.");
00054             goto the_end;
00055         }
00056     }
00057 
00058     /* create image of appropriate size */
00059     for (nbnd=0,i=0; i<nimg; nbnd += in[i++]->nbnd);
00060     if (!CHECKIMG(*out)) GETMEM(nbnd,nlin,npix,out);
00061     if (!*out) goto the_end;
00062 
00063     /* initialize progress indicator */
00064     if (LINES  &&  !PROGRESS(psum=0.0)) goto the_end;
00065     pinc = 1.0/(double)nbnd/(double)nlin;
00066 
00067     /* combine images */
00068     for (m=0,i=0; i<nimg; i++) {
00069         for (j=0; j<in[i]->nbnd; j++,m++) {
00070             for (k=0; k<nlin; k++) {
00071                 for (l=0; l<npix; l++) {
00072                     (*out)->data[m][k][l] = in[i]->data[j][k][l];
00073                 }
00074                 if (LINES  &&  !PROGRESS(psum+=pinc)) goto the_end;
00075             }
00076         }
00077     }
00078 
00079     the_end:
00080     if (TIMES) TIMING(T_EXIT);
00081 }

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