Main Page   Data Structures   File List   Data Fields   Globals  

dupl.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 enlarges an image by replicating bands, lines, and pixels. */
00009 /*                                                                            */
00010 /*----------------------------------------------------------------------------*/
00011 /*-Interface Information------------------------------------------------------*/
00012 void DUPL (
00013 IMAGE *in,      /*  I   Pointer to the input image.                           */
00014 short ibgn,     /*  I   First replicated band.                                */
00015 short jbgn,     /*  I   First replicated line.                                */
00016 short kbgn,     /*  I   First replicated pixel.                               */
00017 short ifact,    /*  I   Band replication factor.                              */
00018 short jfact,    /*  I   Line replication factor.                              */
00019 short kfact,    /*  I   Pixel replication factor.                             */
00020 short isize,    /*  I   Number of replicated bands.                           */
00021 short jsize,    /*  I   Number of replicated lines.                           */
00022 short ksize,    /*  I   Number of replicated pixels.                          */
00023 IMAGE **out     /*  O   Address of a pointer to the output image.             */
00024 /*----------------------------------------------------------------------------*/
00025 ) { register short i, j, k, l, m, n;
00026     char msg[SLEN];
00027 
00028     if (TIMES) TIMING(T_DUPL);
00029     if (NAMES) {
00030         MESSAGE('I',"");
00031         MESSAGE('I',"DUPL");
00032         MESSAGE('I',"");
00033         sprintf(msg," Input image:                                   %s",in->text);
00034         MESSAGE('I',msg);
00035         sprintf(msg," First replicated band, line, pixel:            %d, %d, %d",ibgn+1,jbgn+1,kbgn+1);
00036         MESSAGE('I',msg);  
00037         sprintf(msg," Replication factor for bands, lines, pixels:   %d, %d, %d",ifact,jfact,kfact);
00038         MESSAGE('I',msg);
00039         sprintf(msg," Number of replicated bands, lines, pixels:     %d, %d, %d",isize,jsize,ksize);
00040         MESSAGE('I',msg); 
00041         MESSAGE('I'," ...............");
00042     }
00043 
00044     /* check input */
00045     if (!CHECKIMG(in)) {
00046         MESSAGE('E'," Can't identify image.");
00047         goto the_end;
00048     } else if (0 > ibgn  ||  ibgn+isize > in->nbnd) {
00049         MESSAGE('E'," Block band range to be duplicated must be located completely inside input image.");
00050         goto the_end;
00051     } else if (0 > jbgn  ||  jbgn+jsize > in->nlin) {
00052         MESSAGE('E'," Block line range to be duplicated must be located completely inside input image.");
00053         goto the_end;
00054     } else if (0 > kbgn  ||  kbgn+ksize > in->npix) {
00055         MESSAGE('E'," Block pixel range to be duplicated must be located completely inside input image.");
00056         goto the_end;
00057     } else if (ifact <= 0) {
00058         MESSAGE('E'," Band duplication factor must be greater than zero.");
00059         goto the_end;
00060     } else if (jfact <= 0) {
00061         MESSAGE('E'," Line duplication factor must be greater than zero.");
00062         goto the_end;
00063     } else if (kfact <= 0) {
00064         MESSAGE('E'," Pixel duplication factor must be greater than zero.");
00065         goto the_end;
00066     } else if (isize <= 0) {
00067         MESSAGE('E'," Size of block in bands to be duplicated must be greater then zero.");
00068         goto the_end;
00069     } else if (jsize <= 0) {
00070         MESSAGE('E'," Size of block in lines to be duplicated must be greater then zero.");
00071         goto the_end;
00072     } else if (ksize <= 0) {
00073         MESSAGE('E'," Size of block in pixels/line to be duplicated must be greater then zero.");
00074         goto the_end;
00075     }
00076 
00077     /* create image of appropriate size */
00078     if (!CHECKIMG(*out)) GETMEM(isize*ifact,jsize*jfact,ksize*kfact,out);
00079     if (!*out) goto the_end;
00080 
00081     /* duplicate the image data */
00082     for (i=ibgn; i<ibgn+isize; i++) {
00083         for (j=jbgn; j<jbgn+jsize; j++) {
00084             for (k=kbgn; k<kbgn+ksize; k++) {
00085                 for (l=0; l<ifact; l++) {
00086                     for (m=0; m<jfact; m++) {
00087                         for (n=0; n<kfact; n++) {
00088                             (*out)->data[i*ifact+l][j*jfact+m][k*kfact+n] = in->data[i][j][k];
00089                         }
00090                     }
00091                 }
00092             }
00093         }
00094     }
00095     (*out)->gmin = in->gmin;
00096     (*out)->gmax = in->gmax;
00097 
00098     the_end:
00099     if (TIMES) TIMING(T_EXIT);
00100 }

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