~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina6/tina-tools/tinatool/tlbase/tlbaseMono_file.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  * 
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  * 
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/tlbase/tlbaseMono_file.c,v $
 37  * Date    :  $Date: 2007/02/15 01:55:50 $
 38  * Version :  $Revision: 1.5 $
 39  * CVS Id  :  $Id: tlbaseMono_file.c,v 1.5 2007/02/15 01:55:50 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes : file handling for mono_tool.c
 44  *
 45  *********
 46 */
 47 
 48 #include "tlbaseMono_file.h"
 49 
 50 #if HAVE_CONFIG_H
 51 #include <config.h>
 52 #endif
 53 
 54 #include <stdio.h>
 55 #include <sys/param.h>
 56 #include <string.h>
 57 #include <tina/sys/sysDef.h>
 58 #include <tina/sys/sysPro.h>
 59 #include <tina/file/fileDef.h>
 60 #include <tina/file/filePro.h>
 61 #include <tina/image/imgDef.h>
 62 #include <tina/image/imgPro.h>
 63 #include <tina/geometry/geomEdge_link.h>
 64 #include <tinatool/tlbase/tlbase_InfrPro.h>
 65 #include <tinatool/tlbase/tlbase_MonoDef.h>
 66 #include <tinatool/tlbase/tlbase_MonoPro.h>
 67 
 68 #define AIFF_FILE  0
 69 #define PGM_FILE   1
 70 #define RAD_FILE   2
 71 #define EDGE_FILE  3
 72 #define POLY_FILE  4
 73 #define CAMERA     5
 74 #define WISP       6
 75 #define RAS        7
 76 #define DICOM_FILE  8   
 77 
 78 
 79 void    mono_input(char *directory_name, char *base_name, int file_type)
 80 {
 81   Imrect *im;
 82   char    pathname[MAXPATHLEN];
 83   int scale_factor_flag = 0;
 84 
 85   if (directory_name != NULL)
 86   {
 87     (void) strip_spaces(base_name);
 88     (void) strip_spaces(directory_name);
 89     (void) string_append(pathname, directory_name, "/", base_name, NULL);
 90   }
 91   else
 92   {
 93     (void) strip_spaces(base_name);
 94     (void) string_append(pathname, base_name, NULL);
 95   }
 96 
 97   switch (file_type)
 98     {
 99     case AIFF_FILE:
100         mono_camera_set(input_camera_file(pathname, ""));
101       (void) strcat(pathname, ".aiff");
102       if ((im = (Imrect *) aiff_read_image(pathname)))
103         mono_image_set(im);
104       else
105         error("mono_input: null mono aiff image", warning);
106       break;
107 
108     case PGM_FILE:
109       (void) strcat(pathname, ".pgm");
110       mono_image_set(pgm_read_image(pathname));
111       break;
112 
113     case RAD_FILE:
114       (void) strcat(pathname, ".rad");
115       if ((im = (Imrect *) rad_read_image(pathname)))
116         mono_image_set(im);
117       else
118         error("mono_input: null mono raw image", warning);
119       break;
120 
121     case EDGE_FILE:
122       {
123         Imregion *region = NULL;
124         int       height = 256, width = 256;
125 
126         (void) strcat(pathname, ".edges");
127         if ((im = mono_image()))
128           {
129             height = im->height;
130             width = im->width;
131             region = im->region;
132           }
133         if (im = edges_read_file(pathname, height, width, region))
134           mono_edges_set(im);
135         else
136           error("mono_input: null mono edges", warning);
137         er_find_edge_strings(im);
138         break;
139       }
140 
141     case POLY_FILE:
142       (void) strcat(pathname, ".poly");
143       mono_geom_set(geom2_read(pathname));
144       break;
145 
146     case CAMERA:
147       mono_camera_set(input_camera_file(pathname, ""));
148       break;
149 
150     case RAS:
151       if ((im = (Imrect *) ras_read_image(pathname, uchar_v)))
152         mono_image_set(im);
153       else
154         error("mono_input: null mono ras image", warning);
155       break;
156 
157     case DICOM_FILE:
158       /* mjs 25/11/05 added scale factor flag*/
159       scale_factor_flag = get_mono_scale_factor_flag();
160       if ((im = (Imrect *) dicom_read_image(pathname, scale_factor_flag)))
161         mono_image_set(im);
162       else
163         error("mono_input: null mono dicom image", warning);
164       break;
165 
166     default:
167       error("file type not available", non_fatal);
168       return;
169 
170     }
171 }
172 
173 void    mono_output(char *directory_name, char *base_name, int file_type)
174 {
175     char    pathname[MAXPATHLEN];
176     Imrect *temp_image;
177 
178     (void) strip_spaces(base_name);
179     (void) strip_spaces(directory_name);
180     (void) string_append(pathname, directory_name, "/", base_name, NULL);
181 
182     switch (file_type)
183       {
184       case AIFF_FILE:
185         (void) strcat(pathname, ".aiff");
186         aiff_write_image(mono_image(), pathname);
187         break;
188 
189       case PGM_FILE:
190   (void) strcat(pathname, ".pgm");
191         pgm_write_image(mono_image(), pathname);
192   break;
193 
194       case RAD_FILE:
195         (void) strcat(pathname, ".rad");
196         rad_write_image(mono_image(), pathname);
197         break;
198 
199       case EDGE_FILE:
200         (void) strcat(pathname, ".edges");
201         edges_write_file(pathname, mono_edges());
202         break;
203 
204       case POLY_FILE:           /* to be updated */
205         (void) strcat(pathname, ".poly");
206         geom2_write(pathname, mono_geom_get());
207         break;
208 
209       case CAMERA:
210         (void) strcat(pathname, ".cam");
211         cam_write(pathname, mono_camera(), rdist_write_fp);
212         break;
213 
214       case WISP:
215         (void) strcat(pathname, ".wisp");
216         wisp_write_edges(pathname, mono_edges(), mono_camera());
217         break;
218 
219       default:
220          error("file type not available for output", non_fatal);
221          return;
222 
223     }
224 }
225 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.