Main Page   Data Structures   File List   Data Fields   Globals  

biltobsq.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 separates one multi-band image into individual             */
00009 /*   single-band images (for disk or tape I/O).                               */
00010 /*                                                                            */
00011 /*----------------------------------------------------------------------------*/
00012 /*-Interface Information------------------------------------------------------*/
00013 void
00014 BILTOBSQ (IMAGE * in,           /*  I   Pointer to the input image.                           */
00015           IMAGE ** out          /*  O   Pointer to an array of pointers to the output images. */
00016 /*----------------------------------------------------------------------------*/
00017   )
00018 {
00019   register short i, j, k;
00020   char msg[SLEN];
00021   double pinc, psum;
00022 
00023   if (TIMES)
00024     TIMING (T_BILTOBSQ);
00025   if (NAMES)
00026     {
00027       MESSAGE ('I', "");
00028       MESSAGE ('I', "BILTOBSQ");
00029       MESSAGE ('I', "");
00030       sprintf (msg, " Input image:  %s", in->text);
00031       MESSAGE ('I', msg);
00032       MESSAGE ('I', "");
00033       MESSAGE ('I', " ...............");
00034     }
00035 
00036   /* check input */
00037   if (!CHECKIMG (in))
00038     {
00039       MESSAGE ('E', " Can't identify image.");
00040       goto the_end;
00041     }
00042   else if (in->nbnd == 1)
00043     {
00044       MESSAGE ('E', " Input image must be multi-band.");
00045       goto the_end;
00046     }
00047 
00048   /* create images of appropriate size */
00049   for (i = 0; i < in->nbnd; i++)
00050     {
00051       if (!CHECKIMG (out[i]))
00052         GETMEM (1, in->nlin, in->npix, &out[i]);
00053       if (!out[i])
00054         goto the_end;
00055     }
00056 
00057   /* initialize progress indicator */
00058   if (LINES && !PROGRESS (psum = 0.0))
00059     goto the_end;
00060   pinc = 1.0 / (double) in->nbnd / (double) in->nlin;
00061 
00062   /* separate images */
00063   for (i = 0; i < in->nbnd; i++)
00064     {
00065       for (j = 0; j < in->nlin; j++)
00066         {
00067           for (k = 0; k < in->npix; k++)
00068             {
00069               out[i]->data[0][j][k] = in->data[i][j][k];
00070             }
00071           if (LINES && !PROGRESS (psum += pinc))
00072             goto the_end;
00073         }
00074     }
00075 
00076 the_end:
00077   if (TIMES)
00078     TIMING (T_EXIT);
00079 }

Generated on Sun May 18 15:36:07 2003 for tclSadie by doxygen1.3