home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / imagetoo / imagtlc1.asc < prev    next >
Text File  |  1992-07-17  |  8KB  |  206 lines

  1. 2.1    NCSA ImageTool
  2.  
  3.  
  4. Formatting Your Data Files    2.1
  5.  
  6. National Center for Supercomputing Applications
  7.  
  8. January 1991
  9.  
  10.                                                                 
  11.  
  12.  
  13.  
  14.  
  15.  
  16. 2.1    NCSA ImageTool
  17.  
  18.  
  19. Formatting Your Data Files    2.1
  20.  
  21.  
  22. National Center for Supercomputing Applications
  23.  
  24.  
  25. January 1991
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33. Chapter 2    Formatting Your Data Files
  34.  
  35.  
  36.  
  37. Chapter Overview
  38. File Formats
  39. RGB and HSI Color Models
  40. Raw Raster Files
  41. Raw Palette Files
  42. HDF Files
  43. NCSA ImageTool Default Files
  44. Specifying the Dimensions of Raw Raster Files
  45.  
  46. Chapter Overview
  47.  
  48. This chapter explains how NCSA ImageTool reads and displays 
  49. data files. The chapter contains a detailed discussion of the file 
  50. formats NCSA ImageTool can read and mentions other software 
  51. packages that will enhance the use of this program. 
  52.  
  53.  
  54. File Formats
  55.  
  56. To understand the file formats required by NCSA ImageTool, you 
  57. need to know how visualization programs represent colors. This 
  58. chapter covers two of those methods. Raster, palette, and HDF files 
  59. are also discussed.
  60.  
  61.  
  62. RGB and HSI Color Models
  63. The most popular method of color representation is the RGB (red, 
  64. green, blue) model where all colors can be represented as a 
  65. combination of these three colors. For example, a high 
  66. concentration of red and green with very little blue forms a shade 
  67. of yellow. A different color model uses a mixture of hue, 
  68. saturation, and intensity. This model is called the HSI model. 
  69. NCSA ImageTool assumes the RGB model when reading palette 
  70. files.
  71.  
  72.  
  73. Raw Raster Files
  74. A raw raster file is a stream of raw, binary, 8-bit raster data in 
  75. row-major order. Each 8-bit byte corresponds to a pixel in the 
  76. image. The image is represented in row-major order; that is, the 
  77. first raster line appears first in the file, succeeded by the next 
  78. raster line, and so forth. Though raw raster files are easy to create, 
  79. the raw raster file format is not very flexible and therefore, not 
  80. highly recommended.
  81.  
  82. If you choose to use raw raster files to store your image data, you 
  83. must specify the dimensions of the dataset before the file can be 
  84. read by NCSA Image. The section entitled "Specifying the 
  85. Dimensions of Raw Raster Files" discusses the procedures for 
  86. specifying the dimensions of your dataset.
  87.  
  88.  
  89. Raw Palette Files
  90. A raw palette file is a stream of 768 bytes. Raw palette files can 
  91. store 256 colors, which can be selected from a palette of over 16 
  92. million possible colors. Palette files are based on the red, green, 
  93. and blue representation of color, the RGB color model. The files 
  94. consist of, in order, 256 bytes of red, 256 bytes of green, and 256 bytes 
  95. of blue. The 256 color palette entries are calculated by combining 
  96. the nth element (red), the (n+256)th element (green), and the 
  97. (n+512)th element (blue) to create the nth RGB component.
  98.  
  99. In other words, a palette file is a lookup table with 256 entries that 
  100. tell which color to associate with each of the 256 possible pixel 
  101. values. Each of the 256 palette entries in the palette is chosen from a 
  102. master palette of 224 RGB colors. Each palette entry consists of three 
  103. bytes, one each for red, green, and blue; the first red component, the 
  104. first green component, and the first blue component, for example, 
  105. comprise the first palette entry.
  106.  
  107. When you load a palette file, the hardware color table entries are 
  108. remapped according to the new palette; that is, each color in the 
  109. palette file is assigned to its corresponding entry in the hardware 
  110. color table.
  111.  
  112. NOTE:  The data values for user-defined palettes must be within 
  113. the range of 0 to 255; however, the Macintosh reserves the palette 
  114. values 0 and 255 for white and black, respectively. Consequently, 
  115. you may have to scale your data to the range from 1 to 254, for NCSA 
  116. Image overrides other assignments to 0 and 255 with white and 
  117. black, respectively.
  118.  
  119.  
  120. HDF Files
  121. Hierarchical Data Format, or HDF, is a flexible, standard file 
  122. format designed at NCSA for sharing of graphical and floating-
  123. point data among different programs and machines. This general 
  124. purpose and extensible file format allows you to store raster 
  125. images, their dimensions, color tables, and annotations all in the 
  126. same file. In addition, you may store floating-point data, scaling 
  127. information, dimensions, annotations, and units of measurement 
  128. in a single file. HDF files are accessible from NCSA software for 
  129. the Macintosh such as NCSA Image, NCSA DataScope, NCSA 
  130. PalEdit, and NCSA Layout as well as user programs, other NCSA 
  131. software, and HDF utilities. These files can be used on such 
  132. machines as the CRAY X-MP/48, CRAY-2, Sun Workstation, IBM 
  133. PC, and Alliant. The portability and usefulness of HDF files is 
  134. shown in Figure 2.1.
  135.  
  136. Figure  2.1    HDF Environment
  137.  
  138.                                                                
  139.  
  140.  
  141. Why Should I Use HDF?
  142. HDF lets you store datasets with extra file information about your 
  143. data, for example, the dimensions of your image. This makes the 
  144. files easier to read and manage by programs such as NCSA 
  145. ImageTool and saves you the trouble of tracking this information 
  146. externally.
  147.  
  148.  
  149. What Information Goes into an HDF File?
  150. Both raster images and scientific floating-point data can be stored 
  151. in HDF files for use in NCSA ImageTool.
  152.  
  153. A raster image set contains a raster image, together with its 
  154. dimensions. It may also contain a palette. You may specify that the 
  155. raster image be stored in compressed or non-compressed form.
  156.  
  157. A scientific dataset can store scientific data in an array of 32-bit 
  158. floating-point numbers of any dimension, together with 
  159. information regarding the rank and size of each dimension. 
  160. When storing your datasets in HDF files, you have the option of 
  161. storing other information such as labels for the data and the axes, 
  162. scales for the axes, and the maximum and minimum values of the 
  163. data.
  164. How Do I Create an HDF File?
  165. Public domain software is available from NCSA for creating HDF 
  166. files. NCSA's HDF libraries support both Fortran and C calls on 
  167. any of the following machines:  Cray (UNICOS), Sun (UNIX), 
  168. Alliant (Concentrix), Macintosh, and IBM PC (MS-DOS).
  169.  
  170. The best way to store your data in an HDF file is to incorporate 
  171. calls to the appropriate HDF library in the program that produces 
  172. your image or scientific data. These calls can store your raw 
  173. image, palette, scientific data, and other information in an HDF 
  174. file in proper format.
  175.  
  176. If you have access to the HDF libraries, you can store floating-point 
  177. data in your file, and read it directly. NCSA ImageTool reads 
  178. floating-point data rather than 8-bit binary data whenever the 
  179. former is available, but performs image processing operations on 
  180. the 256-color representation (i.e., 8-bit binary data), not on the 
  181. floating-point data from which the 256-color image was 
  182. constructed.
  183.  
  184. NOTE:  If you have a UNIX-based system, you can use the 
  185. command line utility called r8tohdf to convert one or more raw 
  186. raster images and palettes to HDF format.
  187.  
  188.  
  189. Where Can I Obtain More Information about HDF?
  190. Refer to Appendix C, "Obtaining NCSA Software," on information 
  191. to obtain NCSA HDF as well as other NCSA software.
  192.  
  193.  
  194. Specifying the Dimensions of Raw Raster Files
  195.  
  196. To read and display an image, NCSA Image must be able to 
  197. ascertain its dimensions. If you use an image stored in an HDF 
  198. file, which can contain an image along with information about the 
  199. image dimensions and associated color table, NCSA Image can 
  200. read the dimensions from the HDF file. 
  201.  
  202. However, raw raster files do not provide this convenience. You 
  203. must specify the image dimensions in the dimension areas 
  204. (Xdim, Ydim) of the control panel.
  205.  
  206.