vil_viffheader.h
Go to the documentation of this file.
1 #ifndef vil_viffheader_h_
2 #define vil_viffheader_h_
3 /*
4 * Copyright 1990, 1991, 1992 (c) Khoral Research, Inc.
5 *
6 * All rights reserved.
7 *
8 * The viff.h file is a plain ascii C include file. It is a copy of the
9 * file in KHOROS_HOME/include/viff.h, but with a less restrictive
10 * copyright. The purpose of this file is allow others to build in
11 * interoperability to their software, without having to get a Khoros license to
12 * distribute their software. Redistribution of any other component of
13 * Khoros still needs a separate license that is available via the Khoros
14 * Consortium.
15 *
16 * For further information, contact:
17 *
18 * khoros-request@khoros.unm.edu
19 *
20 *----------------------------------------------------------------------
21 *
22 * Copyright 1990, University of New Mexico. All rights reserved.
23 *
24 * Permission to copy, modify, and use this include file is hereby
25 * granted, provided that this notice is retained thereon and
26 * on all copies. UNM makes no representations as too the sui-
27 * tability and operability of this software for any purpose.
28 * It is provided "as is" without express or implied warranty.
29 *
30 * UNM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
31 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
32 * NESS. IN NO EVENT SHALL UNM BE LIABLE FOR ANY SPECIAL,
33 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY OTHER DAMAGES WHAT-
34 * SOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
35 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
36 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PER-
37 * FORMANCE OF THIS SOFTWARE.
38 *
39 *----------------------------------------------------------------------
40 */
41 
42 /*
43 file: viff.h
44 
45 contains: Khoros Visualization/Image File Format.
46  Design considerations included the need
47  for portability, expandability and simplicity.
48 
49 written by: John Rasure
50 
51 date: 5/5/88
52 
53 modifications: Scott R. Wilson 1/13/88
54  Scott R. Wilson 5/3/88 - Version 2, Release 0
55  Scott Wilson, John Rasure, Tom Sauer, and
56  Mark Young: 2/18/89 - Version 3 Release 0
57  Scott Wilson - Version 3.1
58  Tom Sauer - 7/12/89 removed the #defines for
59  location dimension
60  Scott Wilson - Correct comment for
61  subrow_size 5/9/90
62  Scott Wilson - Deleted unneeded include of
63  vdefines.h 18-Jan-91
64 */
65 
66 #include <vxl_config.h> /* for vxl_uint_32 */
67 
68 
69 /* this is a C header file. you cannot use // comments in it
70 //:
71 // \file
72 // \brief Khoros Visualization/Image File Format.
73 // \author John Rassure
74 // \date May 5, 1988
75 //
76 // \verbatim
77 // ******************************************************************
78 // Khoros Visualization/Image File Format
79 //
80 // A Khoros data file is organized as a 1Kbyte header
81 // followed by additional information. The first two
82 // bytes of the header tell what kind of stuff the
83 // additional information is. For Khoros image files,
84 // the additional information consists of the maps,
85 // the location data, and then the image or vector data.
86 //
87 // There is a supporting document for this file called
88 // "The Khoros Visualization/Image File Format" that will help to
89 // explain the various fields, see $KHOROS_HOME/manual/viff_format.
90 //
91 // The header fields where carefully selected to
92 // prevent contradictions between categories, i.e. they
93 // were chosen to be orthogonal to each other. However,
94 // in several situations this causes the fields to supply
95 // redundant information.
96 //
97 // Note that the structure contains pointers to the various
98 // chunks of data. These will make sense ONLY when the
99 // data is in memory.
100 //
101 // *imagedata - points to a sequence of images, an image is
102 // made up of bands, and the bands are in a sequence; or
103 // it can point to vectors, where the vector dimension is
104 // the number of bands.
105 //
106 // *maps - points to a sequence of 2-dimensional maps, a map
107 // is organized as stacked columns. A data value indexes map rows.
108 //
109 // *location - points to bands of coordinate values, ie if
110 // two dimensional locations, then there would be a band
111 // of x's followed by a band of y's.
112 //
113 // The Khoros convention for the image orientation is
114 // with the image origin in the upper left hand corner.
115 //
116 // ******************************************************************
117 //
118 // Modified 2010 for use with VXL for loading and saving viff images.
119 // Derived from appropriately licensed copy found in archive of old
120 // file formats stored in ./viffheader.h.original and found at
121 // http://www.redwoodsoft.com/~dru/museum/gfx/gff/vendspec/viff/viff.h
122 //
123 // Ian Scott 15 Jan 2010
124 // \endverbatim
125 */
126 
127 
128 #define VIFF_HEADERSIZE 1024
130 
132 {
133  VFF_TYP_BIT= 0, /* pixels are on or off (binary image)*/
134 /* Note: This is an X11 XBitmap
135  with bits packed into a byte and
136  padded to a byte */
137  VFF_TYP_1_BYTE= 1, /* pixels are byte (unsigned char) */
138  VFF_TYP_2_BYTE= 2, /* pixels are two byte (short int) */
139  VFF_TYP_4_BYTE= 4, /* pixels are four byte (integer) */
140  VFF_TYP_FLOAT= 5, /* pixels are float (single precision)*/
141  VFF_TYP_COMPLEX= 6, /* pixels are complex float */
142  VFF_TYP_DOUBLE= 9, /* pixels are float (double precision)*/
143  VFF_TYP_DCOMPLEX= 10 /* pixels are double complex */
144 };
145 
146 /* image structure definition */
147 
148 struct vil_viff_xvimage {
150  unsigned ncols, unsigned nrows,
151  vil_viff_data_storage storage_type,
152  unsigned num_data_bands);
153 
155 
156  /* Administrative or file management information */
157 
158  char identifier; /* a magic number (XV_FILE_MAGIC_NUM) that tells
159  the world that this is an
160  Khoros file */
161 
162  char file_type; /* tells if this file is a VIFF file if equal to XV_FILE_TYPE_XVIFF*/
163 
164  char release; /* release number */
165 
166  char version; /* version number */
167 
168  char machine_dep; /* indicates peculiarities of */
169  /* machine architecture */
170 
171  char trash[3]; /* preserves word boundaries */
172  /* groups of 4 bytes */
173 
174  char comment[512]; /* text for image commentary */
175 
176  /* Things that specify the spatial properties of the image, pixel
177  organization, and data storage arrangement. */
178 
179  vxl_uint_32 row_size; /* length of row in pixels,
180  i.e. number of columns */
181 
182  vxl_uint_32 col_size; /* length of column in pixels,
183  i.e. number or rows */
184 
185  vxl_uint_32 subrow_size; /* Length of subrows. This is useful
186  when one wants pixel vectors to
187  represent 2D objects (images).
188  The size of each pixel "image"
189  would be subrow_size (columns)
190  by num_data_bands/subrow_size (rows).
191  This field may be ignored except
192  by routines that need the 2D
193  interpretation. */
194 
195  /* The product of row_size and col_size is used to indicate
196  the number of locations when the location type is explicit,
197  the product also indicates the number of pixels in a band,
198  or the number of vectors. */
199 
200  vxl_sint_32 startx, starty; /* subimage starting position (upper
201  left hand corner), negative indicates
202  that it is not a subimage */
203 
204  float pixsizx, pixsizy; /* Actual size of pixel at time of
205  digitization in meters */
206 
207  vxl_uint_32 location_type; /* implied or explicit location
208  data (implied locations are
209  derived from row_size and
210  col_size) */
211 
212  vxl_uint_32 location_dim; /* explicit locations can be of
213  any dimension */
214 
215  vxl_uint_32 num_of_images; /* number of images
216  pointed to by *imagedata,
217  do not confuse with number of
218  bands */
219 
220  vxl_uint_32 num_data_bands; /* Number of bands per data pixel,
221  or number of bands per image, or
222  dimension of vector data, or
223  number of elements in a vector */
224 
225  vxl_uint_32 data_storage_type; /* storage type for disk data */
226 
227  vxl_uint_32 data_encode_scheme; /* encoding scheme of disk data */
228 
229  /* Things that determine how the mapping (if any) of data bands is
230  to be done to obtain the actual "image" or data. */
231 
232  vxl_uint_32 map_scheme; /* How mapping (if any) is to occur */
233 
234  vxl_uint_32 map_storage_type;/* Storage type of cells in the maps */
235 
236  vxl_uint_32 map_row_size; /* number of columns in map array */
237 
238  vxl_uint_32 map_col_size; /* number of entries in map (rows) */
239 
240  vxl_uint_32 map_subrow_size; /* Length of subrows. This is useful
241  when using the output vector from
242  the map as a 2-D image, rather
243  than just a vector. The size of
244  the 2-D image would be:
245  map_subrow_size (columns) by
246  map_row_size/map_subrow_size
247  (rows). This field may be ignored
248  except by routines that need the 2D
249  interpretation */
250 
251  vxl_uint_32 map_enable; /* Tells if the disk data is valid
252  with or without being sent thru the
253  map. Some data MUST be mapped to be
254  valid. */
255 
256  vxl_uint_32 maps_per_cycle; /* number of maps to constitue a "cycle"
257  for VFF_MS_CYCLE */
258 
259  /* Specification of the particular color model in use when working with a
260  color image. This just tells what the coordinate system and axis orientation
261  of the color space is. */
262 
263  vxl_uint_32 color_space_model;
264 
265  /* Extra fields for use by the user as needed. These are NOT SUPPORTED
266  in any way, except for being read and written correctly with respect
267  to machine dependencies. */
268 
269  vxl_uint_32 ispare1,ispare2; /* Spare long ints */
270 
271  float fspare1,fspare2; /* Spare floats */
272 
273  /* Pointers to the actual data - these are valid only when in memory! */
274 
275  char reserve[VIFF_HEADERSIZE - (21*sizeof(vxl_sint_32))
276  - (520*sizeof(char))
277  - (2*sizeof(char *)) - (4*sizeof(float))
278  - (sizeof(float *))];
279  /* maximum header information is
280  1024 bytes, what is not currently
281  used is saved in reserve */
282 
283  char *maps; /* a pointer to the maps, must be cast into
284  the proper type */
285 
286  float *location; /* a pointer to the location data (for
287  explicit locations, each location is
288  paired with data pointed to by
289  *imagedata); all locations are
290  in float */
291 
292  char *imagedata; /* a pointer to the input data (straight off
293  of disk), must be cast into the proper type */
294 
295 } ;
296 
297 
298 #define XV_FILE_MAGIC_NUM 0xab /* Khoros file identifier */
299 #define XV_FILE_TYPE_XVIFF 1 /* indicates an image file */
300 
301 /* definitions for version number,
302 char release; */
303 #define XV_IMAGE_VER_NUM 3 /* Version 3 (3.1) */
304 
305 /* definitions for release number,
306 char version; */
307 #define XV_IMAGE_REL_NUM 1 /* Release 1 */
308 
309 /* definitions for subimage information,
310 vxl_sint_32 startx, starty; */
311 #define VFF_NOTSUB ~0 /* a negative number indicates that
312 the image is not a subimage */
313 
314 /* definitions for machine dependencies,
315 char machine_dep; */
316 #define VFF_DEP_IEEEORDER 0x2 /* IEEE byte ordering */
317 #define VFF_DEP_DECORDER 0x4 /* DEC (VAX) byte ordering */
318 #define VFF_DEP_NSORDER 0x8 /* NS32000 byte ordering */
319 #define VFF_DEP_CRAYORDER 0xA /* Cray byte size and ordering */
320 
321 #define VFF_DEP_BIGENDIAN VFF_DEP_IEEEORDER
322 #define VFF_DEP_LITENDIAN VFF_DEP_NSORDER
323 
324 /* definitions for data encoding scheme on disk - i.e. it may be
325  compressed using RLE, or uncompressed (RAW).
326  vxl_uint_32 data_encode_scheme; */
327 #define VFF_DES_RAW 0 /* Raw - no compression */
328 #define VFF_DES_COMPRESS 1 /* Compressed using ALZ */
329 #define VFF_DES_RLE 2 /* Compressed using RLE */
330 #define VFF_DES_TRANSFORM 3 /* Transform based compression */
331 #define VFF_DES_CCITT 4 /* CCITT standard compression */
332 #define VFF_DES_ADPCM 5 /* ADPCM compression */
333 #define VFF_DES_GENERIC 6 /* User-specified compression */
334 
335 /* definitions for map data or cells storage type,
336  vxl_uint_32 map_storage_type; */
337 #define VFF_MAPTYP_NONE 0 /* No cell type is assigned */
338 #define VFF_MAPTYP_1_BYTE 1 /* cells are byte (unsigned char) */
339 #define VFF_MAPTYP_2_BYTE 2 /* cells are two byte (short int) */
340 #define VFF_MAPTYP_4_BYTE 4 /* cells are four byte (integer) */
341 #define VFF_MAPTYP_FLOAT 5 /* cells are float (single precision) */
342 #define VFF_MAPTYP_COMPLEX 6 /* cells are complex FLOAT */
343 #define VFF_MAPTYP_DOUBLE 7 /* cells are float (double precision) */
344 
345 /* definitions for mapping schemes, vxl_uint_32 map_scheme; */
346 #define VFF_MS_NONE 0 /* No mapping is to be done, and no
347  maps are to be stored. */
348 #define VFF_MS_ONEPERBAND 1 /* Each data band has its own map */
349 #define VFF_MS_CYCLE 2 /* An array of maps is selected in order
350  by groups of maps_per_cycle, allowing
351  "rotating the color map" */
352 #define VFF_MS_SHARED 3 /* All data band share the same map */
353 #define VFF_MS_GROUP 4 /* All data bands are "grouped"
354  together to point into one map */
355 
356 /* definitions for enabling the map, vxl_uint_32 map_enable; */
357 #define VFF_MAP_OPTIONAL 1 /* The data is valid without being
358  sent thru the color map. If a
359  map is defined, the data may
360  optionally be sent thru it. */
361 #define VFF_MAP_FORCE 2 /* The data MUST be sent thru the map
362  to be interpreted */
363 
364 /* definitions for color map models, vxl_uint_32 color_space_model; */
365 
366 /* the models use the following convention:
367  ntsc: national television systems committee
368  cie: Commission Internationale de L'Eclairage
369  ucs: universal chromaticity scale
370  RGB: red band, green band, blue band
371  CMY: cyan band, magenta band, yellow band
372  YIQ: luminance, I and Q represent chrominance
373  HSV: hue, saturation, value
374  IHS: intensity, hue, saturation
375  XYZ:
376  UVW:
377  SOW:
378  Lab:
379  Luv:
380 
381  For more information on how to interpret the combined meaning of the
382  colorspace fields, see the document in $KHOROS_HOME/manual/viff_format,
383  which contains detailed descriptions on the fields along with numerous
384  examples of proper use. */
385 
386 #define VFF_CM_NONE 0
387 #define VFF_CM_ntscRGB 1
388 #define VFF_CM_ntscCMY 2
389 #define VFF_CM_ntscYIQ 3
390 #define VFF_CM_HSV 4
391 #define VFF_CM_HLS 5
392 #define VFF_CM_IHS 6
393 #define VFF_CM_cieRGB 7
394 #define VFF_CM_cieXYZ 8
395 #define VFF_CM_cieUVW 9
396 #define VFF_CM_cieucsUVW 10
397 #define VFF_CM_cieucsSOW 11
398 #define VFF_CM_cieucsLab 12
399 #define VFF_CM_cieucsLuv 13
400 #define VFF_CM_GENERIC 14 /* the color space is user defined */
401 #define VFF_CM_genericRGB 15 /* an RGB image but not conforming
402  to any standard */
403 
404 /* definitions for location type, vxl_uint_32 location_type; */
405 #define VFF_LOC_IMPLICIT 1 /* The location of image pixels
406  or vector data is given by using
407  the implied 2D array given by
408  row_size and col_size. */
409 #define VFF_LOC_EXPLICIT 2 /* The location of the image pixels
410  or the vectors is explicit */
411 
412 
413 #endif /* vil_viffheader_h_ */
vxl_sint_32 starty
vxl_uint_32 ispare1
vxl_uint_32 location_type
vxl_uint_32 map_col_size
vxl_uint_32 map_row_size
vxl_uint_32 data_encode_scheme
vxl_sint_32 startx
vxl_uint_32 subrow_size
vxl_uint_32 location_dim
vxl_uint_32 map_enable
vxl_uint_32 row_size
vxl_uint_32 map_storage_type
vxl_uint_32 ispare2
vxl_uint_32 color_space_model
vxl_uint_32 data_storage_type
vxl_uint_32 map_scheme
vxl_uint_32 num_data_bands
char reserve[VIFF_HEADERSIZE -(21 *sizeof(vxl_sint_32)) -(520 *sizeof(char)) -(2 *sizeof(char *)) -(4 *sizeof(float)) -(sizeof(float *))]
vxl_uint_32 num_of_images
vxl_uint_32 col_size
vil_viff_data_storage
vxl_uint_32 map_subrow_size
vxl_uint_32 maps_per_cycle