Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ViffHeader.hh
1 /*
2 This file is distributed as part of the BIAS library (Basic ImageAlgorithmS)
3 but it has not been developed by the authors of BIAS.
4 
5 For copyright, author and license information see below.
6 */
7 
8 
9 
10 #ifndef __VIFFHEADER_HH__
11 #define __VIFFHEADER_HH__
12 /*
13 ******************************************************************
14 Khoros Visualization/Image File Format
15 
16 A Khoros data file is organized as a 1Kbyte header
17 followed by additional information. The first two
18 bytes of the header tell what kind of stuff the
19 additional information is. For Khoros image files,
20 the additional information consists of the maps,
21 the location data, and then the image or vector data.
22 
23 There is a supporting document for this file called
24 "The Khoros Visualization/Image File Format" that will help to
25 expalin the various fields, see $KHOROS_HOME/manual/viff_format.
26 
27 The header fields where carefully selected to
28 prevent contradictions between categories, i.e. they
29 were chosen to be orthogonal to each other. However,
30 in several situations this causes the fields to supply
31 redundant information.
32 
33 Note that the structure contains pointers to the various
34 chunks of data. These will make sense ONLY when the
35 data is in memory.
36 
37 *imagedata - points to a sequence of images, an image is
38 made up of bands, and the bands are in a sequence; or
39 it can point to vectors, where the vector dimension is
40 the number of bands.
41 
42 *maps - points to a sequence of 2-dimensional maps, a map
43 is organized as stacked columns. A data value indexes map rows.
44 
45 *location - points to bands of coordinate values, ie if
46 two dimensional locations, then there would be a band
47 of x's followed by a band of y's.
48 
49 The Khoros convention for the image orientarion is
50 with the image origin in the upper left hand corner.
51 
52 ******************************************************************
53 */
54 
55 
56 /*
57 * The VIFF header size for a Cray is 4096 because of the
58 * word size on a cray. So, set the headersize to be 4096
59 * for the cray and 1024 of all other machines.
60 */
61 
62 #if defined(CRAY)
63 # define VIFF_HEADERSIZE 4096
64 #else
65 # define VIFF_HEADERSIZE 1024
66 #endif
67 
68 
69 /* image structure definition */
70 
71 class xvimage {
72 public:
73 
74  /* Administrative or file management information */
75 
76  char identifier; /* a magic number that tells
77  the world that this is an
78  Khoros file */
79 
80  char file_type; /* tells if this file is a VIFF file */
81 
82  char release; /* release number */
83 
84  char version; /* version number */
85 
86  char machine_dep; /* indicates peculiarities of */
87  /* machine architecture */
88 
89  char trash[3]; /* preserves word boundaries */
90  /* groups of 4 bytes */
91 
92  char comment[512]; /* text for image commentary */
93 
94  /* Things that specify the spatial properties of the image, pixel
95  organization, and data storage arrangement. */
96 
97  unsigned long row_size; /* length of row in pixels,
98  i.e. number of columns */
99 
100  unsigned long col_size; /* length of column in pixels,
101  i.e. number or rows */
102 
103  unsigned long subrow_size; /* Length of subrows. This is useful
104  when one wants pixel vectors to
105  represent 2D objects (images).
106  The size of each pixel "image"
107  would be subrow_size (columns)
108  by num_data_bands/subrow_size (rows).
109  This field may be ignored except
110  by routines that need the 2D
111  interpretation. */
112 
113  /* The product of row_size and col_size is used to indicate
114  the number of locations when the location type is explicit,
115  the product also indicates the number of pixels in a band,
116  or the number of vectors. */
117 
118  long startx, starty; /* subimage starting position (upper
119  left hand corner), negative indicates
120  that it is not a subimage */
121 
122  float pixsizx, pixsizy; /* Actual size of pixel at time of
123  digitization in meters */
124 
125  unsigned long location_type; /* implied or explicit location
126  data (implied locations are
127  derived from row_size and
128  col_size */
129 
130  unsigned long location_dim; /* explicit locations can be of
131  any dimension */
132 
133  unsigned long num_of_images; /* number of images
134  pointed to by *imagedata,
135  do not confuse with number of
136  bands */
137 
138  unsigned long num_data_bands; /* Number of bands per data pixel,
139  or number of bands per image, or
140  dimension of vector data, or
141  number of elements in a vector */
142 
143  unsigned long data_storage_type; /* storage type for disk data */
144 
145  unsigned long data_encode_scheme; /* encoding scheme of disk data */
146 
147  /* Things that determine how the mapping (if any) of data bands is
148  to be done to obtain the actual "image" or data. */
149 
150  unsigned long map_scheme; /* How mapping (if any) is to occur */
151 
152  unsigned long map_storage_type;/* Storage type of cells in the maps */
153 
154  unsigned long map_row_size; /* number of columns in map array */
155 
156  unsigned long map_col_size; /* number of entries in map (rows) */
157 
158  unsigned long map_subrow_size; /* Length of subrows. This is useful
159  when using the output vector from
160  the map as a 2-D image, rather
161  than just a vector. The size of
162  the 2-D image would be:
163  map_subrow_size (columns) by
164  map_row_size/map_subrow_size
165  (rows). This field may be ignored
166  except by routines that need the 2D
167  interpretation */
168 
169  unsigned long map_enable; /* Tells if the disk data is valid
170  with or without being sent thru the
171  map. Some data MUST be mapped to be
172  valid. */
173 
174  unsigned long maps_per_cycle; /* number of maps to constitue a "cycle"
175  for VFF_MS_CYCLE */
176 
177  /* Specification of the particular color model in use when working with a
178  color image. This just tells what the coordinate system and axis orientation
179  of the color space is. */
180 
181  unsigned long color_space_model;
182 
183  /* Extra fields for use by the user as needed. These are NOT SUPPORTED
184  in any way, except for being read and written correctly with respect
185  to machine dependencies. */
186 
187  unsigned long ispare1,ispare2; /* Spare long ints */
188 
189  float fspare1,fspare2; /* Spare floats */
190 
191  /* Pointers to the actual data - these are valid only when in memory! */
192 
193  char reserve[VIFF_HEADERSIZE - (21*sizeof(long))
194  - (520*sizeof(char))
195  - (2*sizeof(char *)) - (4*sizeof(float))
196  - (sizeof(float *))];
197  /* maximum header information is
198  1024 bytes, what is not currently
199  used is saved in reserve */
200 
201  char *maps; /* a pointer to the maps, must be cast into
202  the proper type */
203 
204  float *location; /* a pointer to the location data (for
205  explicit locations, each location is
206  paired with data pointed to by
207  *imagedata, all locations are
208  in float */
209 
210  char *imagedata; /* a pointer to the input data (straight off
211  of disk, must be cast into the proper type */
212 
213 } ;
214 
215 /* definitions for version number,
216 char release; */
217 #define XV_IMAGE_VER_NUM 3 /* Version 3 (3.1) */
218 
219 /* definitions for release number,
220 char version; */
221 #define XV_IMAGE_REL_NUM 1 /* Release 1 */
222 
223 /* definitions for subimage information,
224 long startx, starty; */
225 #define VFF_NOTSUB ~0 /* a negative number indicates that
226 the image is not a subimage */
227 
228 /* definitions for machine dependencies,
229 char machine_dep; */
230 #define VFF_DEP_IEEEORDER 0x2 /* IEEE byte ordering */
231 #define VFF_DEP_DECORDER 0x4 /* DEC (VAX) byte ordering */
232 #define VFF_DEP_NSORDER 0x8 /* NS32000 byte ordering */
233 #define VFF_DEP_CRAYORDER 0xA /* Cray byte size and ordering */
234 
235 #define VFF_DEP_BIGENDIAN VFF_DEP_IEEEORDER
236 #define VFF_DEP_LITENDIAN VFF_DEP_NSORDER
237 
238 
239 /* definitions for data storage type,
240 unsigned long data_storage_type; */
241 #define VFF_TYP_BIT 0 /* pixels are on or off (binary image)*/
242 /* Note: This is an X11 XBitmap
243 with bits packed into a byte and
244 padded to a byte */
245 #define VFF_TYP_1_BYTE 1 /* pixels are byte (unsigned char) */
246 #define VFF_TYP_2_BYTE 2 /* pixels are two byte (short int) */
247 #define VFF_TYP_4_BYTE 4 /* pixels are four byte (integer) */
248 #define VFF_TYP_FLOAT 5 /* pixels are float (single precision)*/
249 #define VFF_TYP_COMPLEX 6 /* pixels are complex float */
250 #define VFF_TYP_DOUBLE 9 /* pixels are float (double precision)*/
251 
252 #define VFF_TYP_DCOMPLEX 10 /* double complex */
253 
254 /* definitions for data encoding scheme on disk - i.e. it may be
255 compressed using RLE, or uncompressed (RAW).
256 unsigned long data_encode_scheme; */
257 #define VFF_DES_RAW 0 /* Raw - no compression */
258 #define VFF_DES_COMPRESS 1 /* Compressed using ALZ */
259 #define VFF_DES_RLE 2 /* Compressed using RLE */
260 #define VFF_DES_TRANSFORM 3 /* Transform based compression */
261 #define VFF_DES_CCITT 4 /* CCITT standard compression */
262 #define VFF_DES_ADPCM 5 /* ADPCM compression */
263 #define VFF_DES_GENERIC 6 /* User-specified compression */
264 
265 /* definitions for map data or cells storage type,
266 unsigned long map_storage_type; */
267 #define VFF_MAPTYP_NONE 0 /* No cell type is assigned */
268 #define VFF_MAPTYP_1_BYTE 1 /* cells are byte (unsigned char) */
269 #define VFF_MAPTYP_2_BYTE 2 /* cells are two byte (short int) */
270 #define VFF_MAPTYP_4_BYTE 4 /* cells are four byte (integer) */
271 #define VFF_MAPTYP_FLOAT 5 /* cells are float (single precision) */
272 #define VFF_MAPTYP_COMPLEX 6 /* cells are complex FLOAT */
273 #define VFF_MAPTYP_DOUBLE 7 /* cells are float (double precision) */
274 
275 /* definitions for mapping schemes,
276 unsigned long map_scheme; */
277 #define VFF_MS_NONE 0 /* No mapping is to be done, and no
278 maps are to be stored. */
279 #define VFF_MS_ONEPERBAND 1 /* Each data band has its own map */
280 #define VFF_MS_CYCLE 2 /* An array of maps is selected in order
281 by groups of maps_per_cycle, allowing
282 "rotating the color map" */
283 #define VFF_MS_SHARED 3 /* All data band share the same map */
284 #define VFF_MS_GROUP 4 /* All data bands are "grouped"
285 together to point into one map */
286 /* definitions for enabling the map,
287 unsigned long map_enable; */
288 #define VFF_MAP_OPTIONAL 1 /* The data is valid without being
289 sent thru the color map. If a
290 map is defined, the data may
291 optionally be sent thru it. */
292 #define VFF_MAP_FORCE 2 /* The data MUST be sent thru the map
293 to be interpreted */
294 
295 /* definitions for color map models,
296 unsigned long color_space_model; */
297 
298 /* the models use the following convention:
299 ntsc: national television systems committee
300 cie: Commission Internationale de L'Eclairage
301 ucs: universal chromaticity scale
302 RGB: red band, green band, blue band
303 CMY: cyan band, magenta band, yellow band
304 YIQ: luminance, I and Q represent chrominance
305 HSV: hue, saturation, value
306 IHS: intensity, hue, saturation
307 XYZ:
308 UVW:
309 SOW:
310 Lab:
311 Luv:
312 
313 For more information on how to interpret the combined meaning of the
314 colorspace fields, see the document in $KHOROS_HOME/manual/viff_format,
315 which contains detailed descriptions on the fields along with numerous
316 examples of proper use. */
317 
318 #define VFF_CM_NONE 0
319 #define VFF_CM_ntscRGB 1
320 #define VFF_CM_ntscCMY 2
321 #define VFF_CM_ntscYIQ 3
322 #define VFF_CM_HSV 4
323 #define VFF_CM_HLS 5
324 #define VFF_CM_IHS 6
325 #define VFF_CM_cieRGB 7
326 #define VFF_CM_cieXYZ 8
327 #define VFF_CM_cieUVW 9
328 #define VFF_CM_cieucsUVW 10
329 #define VFF_CM_cieucsSOW 11
330 #define VFF_CM_cieucsLab 12
331 #define VFF_CM_cieucsLuv 13
332 #define VFF_CM_GENERIC 14 /* the color space is user defined */
333 #define VFF_CM_genericRGB 15 /* an RGB image but not conforming
334 to any standard */
335 
336 /* definitions for location type,
337 unsigned long location_type; */
338 #define VFF_LOC_IMPLICIT 1 /* The location of image pixels
339 or vector data is given by using
340 the implied 2D array given by
341 row_size and col_size. */
342 #define VFF_LOC_EXPLICIT 2 /* The location of the image pixels
343 or the vectors is explicit */
344 
345 
346 /* The following are a couple of defines that make it easier
347 to use the image size data */
348 #define number_of_rows col_size
349 #define number_of_cols row_size
350 
351 
352 #endif
unsigned long location_type
Definition: ViffHeader.hh:125
unsigned long ispare1
Definition: ViffHeader.hh:187
char comment[512]
Definition: ViffHeader.hh:92
long starty
Definition: ViffHeader.hh:118
unsigned long map_scheme
Definition: ViffHeader.hh:150
unsigned long data_storage_type
Definition: ViffHeader.hh:143
unsigned long maps_per_cycle
Definition: ViffHeader.hh:174
unsigned long subrow_size
Definition: ViffHeader.hh:103
long startx
Definition: ViffHeader.hh:118
unsigned long col_size
Definition: ViffHeader.hh:100
unsigned long map_col_size
Definition: ViffHeader.hh:156
unsigned long num_data_bands
Definition: ViffHeader.hh:138
char * maps
Definition: ViffHeader.hh:201
unsigned long data_encode_scheme
Definition: ViffHeader.hh:145
unsigned long location_dim
Definition: ViffHeader.hh:130
float pixsizy
Definition: ViffHeader.hh:122
char identifier
Definition: ViffHeader.hh:76
float pixsizx
Definition: ViffHeader.hh:122
unsigned long map_enable
Definition: ViffHeader.hh:169
float fspare1
Definition: ViffHeader.hh:189
unsigned long row_size
Definition: ViffHeader.hh:97
unsigned long color_space_model
Definition: ViffHeader.hh:181
char reserve[VIFF_HEADERSIZE-(21 *sizeof(long))-(520 *sizeof(char))-(2 *sizeof(char *))-(4 *sizeof(float))-(sizeof(float *))]
Definition: ViffHeader.hh:196
unsigned long map_row_size
Definition: ViffHeader.hh:154
char trash[3]
Definition: ViffHeader.hh:89
char file_type
Definition: ViffHeader.hh:80
char version
Definition: ViffHeader.hh:84
float fspare2
Definition: ViffHeader.hh:189
unsigned long ispare2
Definition: ViffHeader.hh:187
char release
Definition: ViffHeader.hh:82
char machine_dep
Definition: ViffHeader.hh:86
unsigned long map_storage_type
Definition: ViffHeader.hh:152
unsigned long map_subrow_size
Definition: ViffHeader.hh:158
char * imagedata
Definition: ViffHeader.hh:210
unsigned long num_of_images
Definition: ViffHeader.hh:133
float * location
Definition: ViffHeader.hh:204