Main Page   Data Structures   File List   Data Fields   Globals  

hmosaic.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 horizontally.                           */
00009 /*                                                                            */
00010 /*----------------------------------------------------------------------------*/
00011 /*-Interface Information------------------------------------------------------*/
00012 void HMOSAIC (
00013 IMAGE *in1,     /*  I   Pointer to the left input image.                      */
00014 IMAGE *in2,     /*  I   Pointer to the right input image.                     */
00015 short jbgn,     /*  I   Number of lines (positive or negative) to offset      */
00016                 /*      right image with respect to left 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 ) { register short i, j, k, nbnd, nlin, npix;
00021     char msg[SLEN];
00022 
00023     if (TIMES) TIMING(T_HMOSAIC);
00024     if (NAMES) {
00025         MESSAGE('I',"");
00026         MESSAGE('I',"HMOSAIC");
00027         MESSAGE('I',"");
00028         sprintf(msg," Left input image:     %s",in1->text);
00029         MESSAGE('I',msg);
00030         sprintf(msg," Right input image:    %s",in2->text);
00031         MESSAGE('I',msg);
00032         sprintf(msg," Vertical offset:      %d",jbgn);
00033         MESSAGE('I',msg);
00034         sprintf(msg," Fill graylevel:     %12.4e",glev);
00035         MESSAGE('I',msg);
00036         MESSAGE('I'," ...............");
00037     }
00038 
00039     /* check input */
00040     if (!CHECKIMG(in1)) {
00041         MESSAGE('E'," Can't identify left image.");
00042         goto the_end;
00043     } else if (!CHECKIMG(in2)) {
00044         MESSAGE('E'," Can't identify right image.");
00045         goto the_end;
00046     } else if ((nbnd=in1->nbnd) != in2->nbnd) {
00047         MESSAGE('E'," Number of bands must be identical in both images.");
00048         goto the_end;
00049     }
00050 
00051     /* create image of appropriate size */
00052     nlin = jbgn > 0  ?  max(in1->nlin,in2->nlin+jbgn) : max(in1->nlin-jbgn,in2->nlin);
00053     npix = in1->npix + in2->npix;
00054     if (!CHECKIMG(*out)) GETMEM(nbnd,nlin,npix,out);
00055     if (!*out) goto the_end;
00056 
00057     /* concatenate images */
00058     for (i=0; i<nbnd; i++) {
00059         for (j=0; j<nlin; j++) {
00060             for (k=0; k<npix; k++) {
00061                 (*out)->data[i][j][k] = glev;
00062             }
00063         }    
00064         if (jbgn > 0) {
00065             for (j=0; j<in1->nlin; j++) {
00066                 for (k=0; k<in1->npix; k++) {
00067                     (*out)->data[i][j][k]=in1->data[i][j][k];
00068                 }
00069             }
00070             for (j=0; j<in2->nlin; j++) {
00071                 for (k=0; k<in2->npix; k++) {
00072                     (*out)->data[i][j+jbgn][k+in1->npix]=in2->data[i][j][k];
00073                 }
00074             }
00075         } else /* (jbgn <= 0) */ {
00076             for (j=0; j<in1->nlin; j++) {
00077                 for (k=0; k<in1->npix; k++) {
00078                     (*out)->data[i][j-jbgn][k]=in1->data[i][j][k];
00079                 }
00080             }
00081             for (j=0; j<in2->nlin; j++) {
00082                 for (k=0; k<in2->npix; k++) {
00083                     (*out)->data[i][j][k+in1->npix]=in2->data[i][j][k];
00084                 }
00085             }
00086         }
00087     }
00088 
00089     /* compute new minimum and maximum */
00090     if (in1->nlin == in2->nlin  &&  jbgn == 0) {
00091         (*out)->gmin = min(in1->gmin,in2->gmin);
00092         (*out)->gmax = max(in1->gmax,in2->gmax);
00093     } else {
00094         (*out)->gmin = min(glev,min(in1->gmin,in2->gmin));
00095         (*out)->gmax = max(glev,max(in1->gmax,in2->gmax));
00096     }
00097 
00098     the_end:
00099     if (TIMES) TIMING(T_EXIT);
00100 }

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