Main Page   Data Structures   File List   Data Fields   Globals  

createmosaic.c

Go to the documentation of this file.
00001 #include        "sadie.h"
00002 #include        "proto.h"
00003 
00004 /*----------------------------------------------------------------------------*/
00005 /*-General Information--------------------------------------------------------*/
00006 /*                                                                            */
00007 /*   This function assembles multiple images into                             */
00008 /*   a single composite mosaic.  Individual image are specified as                        */
00009 /*                                                                            */
00010 /*----------------------------------------------------------------------------*/
00011 /*-Interface Information------------------------------------------------------*/
00012 int CREATEMOSAIC (
00013 char **imglist, /*  I   Pointer to an array[nimg] containing pointers         */
00014                 /*      to the input image names.                             */
00015 int nimg,       /*  I   Number of input images.                               */
00016 int nlin,       /*  I   Number of lines in the output image.                  */
00017 int npix,       /*  I   Number of pixels/line in the output image.            */
00018 int *xoff,      /*  I   Address of an array[nimg], containing the starting    */
00019                 /*      line coordinates of the input images in the output.   */
00020 int *yoff,      /*  I   Address of an array[nimg], containing the starting    */
00021                 /*      pixel coordinates of the input images in the output.  */
00022 PIXEL *bias,    /*  I   Address of an array[nimg], containing the bias        */
00023                 /*      offsets of the input images relative to the output.   */
00024 PIXEL *gain,    /*  I   Address of an array[nimg], containing the gain        */
00025                 /*      offsets of the input images relative to the output.   */
00026 PIXEL glev,     /*  I   Graylevel to fill otherwise empty pixels.             */
00027 IMAGE **out     /*  O   Address of a pointer to the output image.             */
00028 /*----------------------------------------------------------------------------*/
00029 ) { register int i, j, k, l, elin, epix;
00030     char msg[SLEN];
00031     IMAGE* inimg=NULL;
00032 
00033     if (TIMES) TIMING(T_MOSAIC);
00034     if (NAMES) {
00035         MESSAGE('I',"");
00036         MESSAGE('I',"----------");
00037         MESSAGE('I',"");
00038         MESSAGE('I',"GAINADJMOS");
00039         MESSAGE('I',"");
00040         sprintf(msg," Number of input images: %d",nimg);
00041         MESSAGE('I',msg);
00042         sprintf(msg," Image size: lines:      %d",nlin);
00043         MESSAGE('I',msg);
00044         sprintf(msg,"             pixels:     %d",npix);
00045         MESSAGE('I',msg);
00046         for (i=0; i<nimg; i++) {
00047             sprintf(msg," Image %d:   Offset: lines: %-4d pixels: %-4d",i,yoff[i],xoff[i]);
00048             MESSAGE('I',msg);
00049             sprintf(msg,"                   Contrast Adjustment: gain: %12.4e bias: %12.4e",gain[i],bias[i]);
00050             MESSAGE('I',msg);
00051         }
00052         sprintf(msg," Fill graylevel:       %12.4e",glev);
00053         MESSAGE('I',msg);
00054         MESSAGE('I'," ...............");
00055         MESSAGE('I',"");
00056     }
00057 
00058     for (i=0; i<nimg; i++) {
00059         printf(" Image %d:   Offset: lines: %-4d pixels: %-4d \n",i,yoff[i],xoff[i]);
00060         printf("                   Contrast Adjustment: gain: %12.4e bias: %12.4e \n",gain[i],bias[i]);
00061     }
00062 
00063     /* create image of appropriate size */
00064     if (!CHECKIMG(*out)) GETMEM(1,nlin,npix,out);
00065     if (!*out) goto the_end;
00066 
00067     /* fill the background */
00068     for (i=0; i<1; i++) {
00069         for (j=0; j<nlin; j++) {
00070             for (k=0; k<npix; k++) {
00071                 (*out)->data[i][j][k] = glev;
00072             }
00073         }
00074     }
00075 
00076     /* assemble the mosaic */
00077     for (l=0; l<nimg; l++) {
00078         DISK2IMG (imglist[l],-1,&inimg);
00079         
00080         elin = min(yoff[l]+inimg->nlin,nlin);
00081         epix = min(xoff[l]+inimg->npix,npix);
00082         for (j=yoff[l]; j<elin; j++) {
00083             for (k=xoff[l]; k<epix; k++) {
00084                 (*out)->data[0][j][k] = (PIXEL)((double)gain[l]*(double)inimg->data[0][j-yoff[l]][k-xoff[l]]+(double)bias[l]);
00085             }
00086         }
00087         
00088         RELMEM(inimg);
00089         inimg = NULL;
00090     }
00091 
00092     the_end:
00093     if (TIMES) TIMING(T_EXIT);
00094     
00095     if (inimg) RELMEM(inimg);
00096 }

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