Main Page   Data Structures   File List   Data Fields   Globals  

mosaic.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 assembles multiple images into a single composite mosaic.  */
00009 /*                                                                            */
00010 /*----------------------------------------------------------------------------*/
00011 /*-Interface Information------------------------------------------------------*/
00012 void MOSAIC (
00013 IMAGE **in,     /*  I   Pointer to an array[nimg] containing pointers         */
00014                 /*      to the input images.                                  */
00015 short nimg,     /*  I   Number of input images.                               */
00016 short nlin,     /*  I   Number of lines in the output image.                  */
00017 short npix,     /*  I   Number of pixels/line in the output image.            */
00018 short *jbgn,    /*  I   Address of an array[nimg], containing the starting    */
00019                 /*      line coordinates of the input images in the output.   */
00020 short *kbgn,    /*  I   Address of an array[nimg], containing the starting    */
00021                 /*      pixel coordinates of the input images in the output.  */
00022 PIXEL glev,     /*  I   Graylevel to fill otherwise empty pixels.             */
00023 IMAGE **out     /*  O   Address of a pointer to the output image.             */
00024 /*----------------------------------------------------------------------------*/
00025 ) { register short i, j, k, l, nbnd, elin, epix;
00026     char msg[SLEN];
00027 
00028     if (TIMES) TIMING(T_MOSAIC);
00029     if (NAMES) {
00030         MESSAGE('I',"");
00031         MESSAGE('I',"MOSAIC");
00032         MESSAGE('I',"");
00033         sprintf(msg," Number of input images: %d",nimg);
00034         MESSAGE('I',msg);
00035         sprintf(msg," Image size: lines:      %d",nlin);
00036         MESSAGE('I',msg);
00037         sprintf(msg,"             pixels:     %d",npix);
00038         MESSAGE('I',msg);
00039         for (i=0; i<nimg; i++) {
00040             sprintf(msg," Image: %s   Offset: lines: %-4d pixels: %-4d",in[i]->text,jbgn[i],kbgn[i]);
00041             MESSAGE('I',msg);
00042         }
00043         sprintf(msg," Fill graylevel:       %12.4e",glev);
00044         MESSAGE('I',msg);
00045         MESSAGE('I'," ...............");
00046     }
00047 
00048     /* check input */
00049     for (i=0; i<nimg; i++) {
00050         if (!CHECKIMG(in[i])) {
00051             MESSAGE('E'," Can't identify input image(s).");
00052             goto the_end;
00053         }
00054     }
00055     for (nbnd=in[0]->nbnd,i=1; i<nimg; i++) {
00056         if (nbnd != in[i]->nbnd) {
00057             MESSAGE('E'," Number of bands must be identical in all images.");
00058             goto the_end;
00059         }
00060     }
00061     for (i=0; i<nimg; i++) {
00062         if (0 > jbgn[i]  ||  jbgn[i]+in[i]->nlin > nlin) {
00063             MESSAGE('E'," Input image(s) must be located completely inside output image in the line dimension.");
00064             goto the_end;
00065         } else if (0 > kbgn[i]  ||  kbgn[i]+in[i]->npix > npix) {
00066             MESSAGE('E'," Input image(s) must be located completely inside output image in the pixel dimension.");
00067             goto the_end;
00068         }
00069     }
00070 
00071     /* create image of appropriate size */
00072     if (!CHECKIMG(*out)) GETMEM(nbnd,nlin,npix,out);
00073     if (!*out) goto the_end;
00074 
00075     /* fill the background */
00076     for (i=0; i<nbnd; i++) {
00077         for (j=0; j<nlin; j++) {
00078             for (k=0; k<npix; k++) {
00079                 (*out)->data[i][j][k] = glev;
00080             }
00081         }
00082     }
00083 
00084     /* assemble the mosaic */
00085     for (i=0; i<nbnd; i++) {
00086         for (l=0; l<nimg; l++) {
00087             elin = min(jbgn[l]+in[l]->nlin,nlin);
00088             epix = min(kbgn[l]+in[l]->npix,npix);
00089             for (j=jbgn[l]; j<elin; j++) {
00090                 for (k=kbgn[l]; k<epix; k++) {
00091                     (*out)->data[i][j][k] = in[l]->data[i][j-jbgn[l]][k-kbgn[l]];
00092                 }
00093             }
00094         }
00095     }
00096 
00097     the_end:
00098     if (TIMES) TIMING(T_EXIT);
00099 }

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