The BYTSCL function scales all values of Array that lie in the range (Min £ x £ Max) into the range (0 £ x £ Top). For floating-point input, each value is scaled using the formula (Top + 0.9999)*x/(Max - Min). For integer input, each value is scaled using the formula ((Top + 1)*x - 1)/(Max - Min).
Result = BYTSCL( Array [, MAX=value] [, MIN=value] [, /NAN] [, TOP=value] )
The returned result has the same structure as the original parameter and is of byte type.
The array to be scaled and converted to bytes.
Set this keyword to the maximum value of Array to be considered. If MAX is not provided, Array is searched for its maximum value. All values greater or equal to MAX are set equal to TOP in the result.
| Note |
Set this keyword to the minimum value of Array to be considered. If MIN is not provided, Array is searched for its minimum value. All values less than or equal to MIN are set equal to 0 in the result.
| Note |
Set this keyword to cause the routine to check for occurrences of the IEEE floating-point values NaN or Infinity in the input data. Elements with the value NaN or Infinity are treated as missing data. (See Special Floating-Point Values for more information on IEEE floating-point values.)
Set this keyword to the maximum value of the scaled result. If TOP is not specified, 255 is used. Note that the minimum value of the scaled result is always 0.
This routine is written to make use of IDL's thread pool, which can increase execution speed on systems with multiple CPUs. The values stored in the
BYTSCL is often used to scale images into the appropriate range for 8-bit displays. As an example, enter the following commands:
; Create a simple image array and display: IM = DIST(200) TV, IM ; Scale the image into the full range of bytes (0 to 255) and ; re-display it: IM = BYTSCL(IM) ; Display the new image: TV, IM
Introduced: Original