home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / software / unix / saoimage / saodoc.tar / scale.txt < prev   
Text File  |  1989-11-29  |  10KB  |  192 lines

  1.  
  2. SAOimage scaling
  3.  
  4.  
  5. scaling from image file values to the range of the display color map
  6.  
  7. the color map
  8.  
  9. The workstation display only associates colors with a small, finite set
  10. of values (typically integer values between 0 and 255).  The values used
  11. by the workstations are associated to the colors in its palette through
  12. a color map (e.g. 0=black, 1=dark blue, ...).  Some of the color map
  13. entries are reserved for such things as the colors of the screen or
  14. window background, the mouse cursor, and terminal window text, leaving
  15. fewer color map values for an application like SAOimage to use.  See the
  16. color chapter for a more detailed discussion.
  17.  
  18. the image data
  19.  
  20. Image data may have an arbitrary range of data values.  Data values may
  21. be very large or be very small or negative values, and they may have
  22. fractional components.  Image scaling involves binning groups of image
  23. data values for each display color map value.
  24.  
  25. basic scaling
  26.  
  27. Take the case of an image with a range of values from 0 to +1199 (a
  28. range of 1200).  Imagine that SAOimage has only 200 color map values
  29. to work with.  It might assign one color map slot (or bin) to each
  30. range of six in the image.  Thus values 0 to 5 would be assigned the
  31. lowest color map slot, say 0.  6 to 11 would be assigned to 1, and so
  32. on up to the values between 1195 and 1199 going to slot 199 in the
  33. color map.  Then, if slot 0 was black, all pixels in the image with
  34. data values between 0 and 5 would appear black in the display.  If
  35. color map slot 131 was assigned the color pink, then image pixels
  36. whose data value was between 787 and 792 would appear pink in the
  37. display.
  38.  
  39. scaling distributions
  40.  
  41. The above example is an example of linear scaling.  But suppose that it
  42. was important to be able to see the differences among levels 2, 3, 4,
  43. and 5, but not so important to see a difference between 1001 and 1002.
  44. Perhaps it would be sufficient to see differences between 1001 and 1100,
  45. but 1001, 1002, 1003, etc. could all have the same color.  Then it would
  46. be better to use a scaling that used more color map slots for the lower
  47. image values than the higher image values.  Log and square root scaling
  48. do that.  To understand how that works, imagine a graph with image values
  49. along the side and color map values along the bottom.  A plot of linear
  50. scaling would be a straight line.  A log line would be curved, having
  51. less slope at the bottom (more color map values per image value range)
  52. and get steeper toward the top.  The square root function would be similar
  53. but follow a different curve.
  54.  
  55. non-linear distributions
  56.  
  57. Suppose that weighting toward one end or the other wasn't good enough.  
  58. Perhaps the data values fall in clusters with big gaps in between.
  59. Imagine an image with most of its data clustered between 0 and 200,
  60. but two or three pixels with a value of 1000.  In the linear scaling 80%
  61. of the color cells would be used for non-existent values between 200 and
  62. 1000.  Worse, as is common with CCD images, perhaps there are bad pixels
  63. with values like -1200, which have nothing to do with the data.
  64.  
  65.  equalization
  66.  
  67. It is appropriate to speak in terms of a histogram of the data values,
  68. plotting ranges of data values by the frequency (number of pixels) of
  69. their occurrence in the image.  Suppose that the ranges in the histogram
  70. were selected such that each range was associated with one color map
  71. value.  In a poor scaling distribution, many of the ranges have few or
  72. no actual occurrences in the image.  Histogram equalization is a process
  73. whereby each range is adjusted with respect to the others, until each
  74. range has about the same number of pixel occurrences in the image, thus
  75. maximizing the information in the display.  This usually produces a
  76. dramatic improvement in the amount of visible detail in the display.
  77.  
  78. The drawback of histogram equalization is that the ranges can vary
  79. greatly in size, thus a difference between two adjacent color map values
  80. may represent a big or a small difference in data values, with much
  81. irregularity from one step to the next.
  82.  
  83. windowing the scaling
  84.  
  85. Where most of the data falls within a single contiguous range, with bad
  86. pixels or infrequent events in the extremes to either end, scaling to the
  87. color map can be restricted to a specific range, with all values below that
  88. range having the same color as the minimum and all values above that range
  89. having the same color as the maximum.  This can either be accomplished by
  90. specifying the limits directly, or by looking for a section of the image
  91. which is free from extreme values, and basing the scaling on the values in
  92. that section only.
  93.  
  94. stretching the color map range
  95.  
  96. Another trick to show more detail with a limited color map is to reuse it.
  97. By wrapping the color map on itself, it could represent the range of values
  98. from 0 to 99, and then start over, 100 having the same color as 0 and 199
  99. having the same color as 99.  This works for smoothly varying data and even
  100. has a sort of contoured look to it.  Where the data fluctuations are greater
  101. than the base range, the result is a lot of meaningless noise.
  102.  
  103.  
  104. realization and efficiency within SAOimage
  105.  
  106. In order to realize reasonable execution times for rescaling the image
  107. display, SAOimage does not apply its scaling functions to real data.
  108. Where the image data was real, double, or long, the data is linearly
  109. rescaled to integer values between -32768 and 32767 (a range of 65,536).
  110. Each scaling function produces a look-up table (or map) for this range
  111. of values which is used to draw or redraw the display.  If the data has
  112. such great extremes that this range linearly applied to the data's range
  113. will be insufficient, windowing limits for the initial linear scaling can
  114. be given on the command line (-rmin, -rmax).
  115.  
  116. The scaling function is further windowed by being applied only to the
  117. range of image values actually being displayed at the time the function
  118. is invoked.  Pixels not appearing in the display window are not considered
  119. in the scaling algorithm.  Thus scaling after panning and zooming will
  120. produce different scale look-up table mappings, depending on the contents
  121. of the display.  Panning and zooming can be used in this way to find a
  122. better scaling.  To allow for extreme data that just appear at the edges
  123. (common in CCD images) data within 2 pixels of the edge of the display
  124. are not considered in the assessment of range.  In verbose mode, the
  125. scaling routine reports the range of values which it finds in the
  126. display.
  127.  
  128. One or both limits of the value range for scaling can be restricted
  129. by using the -min and -max arguments on the command line.  When given,
  130. the low end of the range will not extend below the -min value, and/or
  131. the upper end will not extend above the -max value.  The limit value 
  132. should be given in terms of original file values (not the internal
  133. short-integer values, should they differ).  The -min and/or -max
  134. value can be cleared by giving the -min or -max switch with no
  135. argument.
  136.  
  137. Panning or zooming after a scale map has been made does not cause a new
  138. scaling map to be calculated.  The display is drawn with the existing
  139. scaling map.  If the new display has values outside the range when the
  140. map was made, these values are usually clipped  in terms of a histogram of the data values,
  141. plotting ranges of data values by the frequency (number of pixels) of
  142. their occurrence in the image.  Suppose that the ranges in the histogram
  143. were selected such that each range was associated with one color map
  144. value.  In a poor scaling distribution, many of the ranges have few or
  145. no actual occurrences in the image.  Histogram equalization is a process
  146. whereby each range is adjusted with respect to the others, until each
  147. range has about the same number of pixel occurrences in the image, thus
  148. maximizing the information in the display.  This usually produces a
  149. dramatic improvement in the amount of visible detail in the display.
  150.  
  151. The drawback of histogram equalization is that the ranges can vary
  152. greatly in size, thus a difference between two adjacent color map values
  153. may represent a big or a small difference in data values, with much
  154. irregularity from one step to the next.
  155.  
  156. windowing the scaling
  157.  
  158. Where most of the data falls within a single contiguous range, with bad
  159. pixels or infrequent events in the extremes to either end, scaling to the
  160. color map can be restricted to a specific range, with all values below that
  161. range having the same color as the minimum and all values above that range
  162. having the same color as the maximum.  This can either be accomplished by
  163. specifying the limits directly, or by looking for a section of the image
  164. which is free from extreme values, and basing the scaling on the values in
  165. that section only.
  166.  
  167. stretching the color map range
  168.  
  169. Another trick to show more detail with a limited color map is to reuse it.
  170. By wrapping the color map on itself, it could represent the range of values
  171. from 0 to 99, and then start over, 100 having the same color as 0 and 199
  172. having the same color as 99.  This works for smoothly varying data and even
  173. has a sort of contoured look to it.  Where the data fluctuations are greater
  174. than the base range, the result is a lot of meaningless noise.
  175.  
  176.  
  177. realization and efficiency within SAOimage
  178.  
  179. In order to realize reasonable execution times for rescaling the image
  180. display, SAOimage does not apply its scaling functions to real data.
  181. Where the image data was real, double, or long, the data is linearly
  182. rescaled to integer values between -32768 and 32767 (a range of 65,536).
  183. Each scaling function produces a look-up table (or map) for this range
  184. of values which is used to draw or redraw the display.  If the data has
  185. such great extremes that this range linearly applied to the data's range
  186. will be insufficient, windowing limits for the initial linear scaling can
  187. be given on the command line (-rmin, -rmax).
  188.  
  189. The scaling function is further windowed by being applied only to the
  190. range of image values actually being displayed at the time the function
  191. is invoked.  Pixels not appearing in the display window are not considered
  192. in t