Main Page   Data Structures   File List   Data Fields   Globals  

img2text.c

Go to the documentation of this file.
00001 #include        <stdio.h>
00002 #include        "sadie.h"
00003 
00004 /*-Copyright Information------------------------------------------------------*/
00005 /* Copyright (c) 1988 by the University of Arizona Digital Image Analysis Lab */
00006 /*----------------------------------------------------------------------------*/
00007 /*-General Information--------------------------------------------------------*/
00008 /*                                                                            */
00009 /*   This function writes the SADIE pixel values from main memory to disk     */
00010 /*   as text.                                                                 */
00011 /*                                                                            */
00012 /*----------------------------------------------------------------------------*/
00013 /*-Interface Information------------------------------------------------------*/
00014 void
00015 IMG2TEXT (IMAGE * in,           /*  I   Pointer to the image.                                 */
00016           char *name            /*  I   String, containing the name of the disk file.         */
00017 /*----------------------------------------------------------------------------*/
00018   )
00019 {
00020   register int i, j, k;
00021   char msg[SLEN];
00022   FILE *fp = NULL;
00023 
00024   if (TIMES)
00025     TIMING (T_IMG2TEXT);
00026 
00027   /* check input */
00028 
00029   if (!CHECKIMG (in))
00030     {
00031       MESSAGE ('E', " Can't identify image.");
00032       goto the_end;
00033     }
00034 
00035   if (NAMES)
00036     {
00037       MESSAGE ('I', "");
00038       MESSAGE ('I', "IMG2TEXT");
00039       MESSAGE ('I', "");
00040       sprintf (msg, " Input image:               %s", in->text);
00041       MESSAGE ('I', msg);
00042       sprintf (msg, " Output disk file:          %s", name);
00043       MESSAGE ('I', msg);
00044       sprintf (msg, " Output format:             ASCII Text");
00045       MESSAGE ('I', msg);
00046       MESSAGE ('I', " ...............");
00047     }
00048 
00049   /* open image file */
00050   if (!(fp = fopen (name, "w")))
00051     {
00052       sprintf (msg, " Can't open file %s.", name);
00053       MESSAGE ('E', msg);
00054       goto the_end;
00055     }
00056 
00057   for (i = 0; i < in->nbnd; i++)
00058     for (j = 0; j < in->nlin; j++)
00059       {
00060         for (k = 0; k < in->npix; k++)
00061           fprintf (fp, "%.4f ", in->data[i][j][k]);
00062         fprintf (fp, "\n");
00063       }
00064 
00065   /* close image file */
00066 the_end:
00067 
00068   if (fp)
00069     {
00070       if (fclose (fp))
00071         {
00072           sprintf (msg, " Can't close file %s.", name);
00073           MESSAGE ('W', msg);
00074         }
00075     }
00076 
00077   if (TIMES)
00078     TIMING (T_EXIT);
00079 }

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