### NDF2GIF

Converts an NDF into a GIF file.

#### Description:

This Bourne-shell script converts an NDF into a 256 grey-level Graphics Interchange Format (GIF) file. One- or two-dimensional images can be handled and various methods of scaling the data are provided. The script uses the Convert utility NDF2TIFF to produce a TIFF file and then various NETPBM utilities to convert the TIFF file into a GIF file.

If the ‘high’ scaling value is less than the ‘low’ value, the output image will be a negative. Bad values are set to 0 for positives and 255 for negatives.

Error messages are converted into Starlink style (preceded by !).

#### Usage:

ndf2gif in [out] [scale] $\left\{\right\$
low=? high=? percentiles=? [nbins=?] sigmas=?

#### Parameters:

The name of the input NDF (the .sdf extension is not required).
##### OUT = FILENAME (Write)
The name of the GIF file to be generated (a .gif name extension is added if it is omitted). If OUT is omitted, the value of the IN parameter is used. Any existing file with the same name will be overwritten.

The following parameters are actually parameters of the ADAM task NDF2TIFF. Their values on the NDF2GIF command line are just passed through to NDF2TIFF, which may prompt for other required values. The output parameters SCAHIGH and SCALOW will be found in NDF2TIFF’s parameter file.

Only required if SCALE is "Scale". The array value that scales to 255 in the TIFF file. All larger array values are set to 255 when HIGH is greater than LOW, otherwise all array values less than HIGH are set to 255. The dynamic default is the maximum data value. There is an efficiency gain when both LOW and HIGH are given on the command line, because the extreme values need not be computed. The highest data value is suggested in prompts.
Only required if SCALE is "Scale". The array value that scales to 0 in the TIFF file. All smaller array values are also set to 0 when LOW is less than HIGH, otherwise all array values greater than LOW are set to 0. The dynamic default is the minimum data value. There is an efficiency gain when both LOW and HIGH are given on the command line, because the extreme values need not be computed. The lowest data value is suggested in prompts.
The output message filtering level, QUIET, NORMAL or VERBOSE. If set to verbose, the scaling limits used will be displayed. [NORMAL]
Only used if SCALE is "Percentiles". The number of histogram bins used to compute percentiles for scaling. (Percentiles mode) [2048]
##### PERCENTILES( 2 ) = _REAL (Read)
Only required if SCALE is "Percentiles". The percentiles that define the scaling limits. For example, [25,75] would scale between the quartile values.
The type of scaling to be applied to the array. The options, which may be abbreviated to an unambiguous string and are case-insensitive, are described below:
• "Range" — The image is scaled between the minimum and maximum data values. (This is the default.)
• "Faint" — The image is scaled from the mean minus one standard deviation to the mean plus seven standard deviations.
• "Percentiles" — The image is scaled between the values corresponding to two percentiles.
• "Scale" — You define the upper and lower limits between which the image is to be scaled. The application suggests the maximum and the minimum values minimum values when prompting.
• "Sigmas" — The image is scaled between two standard-deviation limits.
["Range"]
##### SIGMAS( 2 ) = _REAL (Read)
Only required if SCALE is "Sigmas". The standard-deviation bounds that define the scaling limits. To obtain values either side of the mean both a negative and a positive value are required. Thus [-2,3] would scale between the mean minus two and the mean plus three standard deviations. [3,-2] would give the negative of that.

#### Results Parameters

##### SCAHIGH = _DOUBLE (Write)
The array value scaled to the maximum colour index for display.
##### SCALOW = _DOUBLE (Write)
The array value scaled to the minimum colour index for display.

#### Examples:

ndf2gif old new
This converts the NDF called old (in file old.sdf) into a GIF file new.gif.
ndf2gif horse scale=pe
This converts the NDF called horse (in file horse.sdf) into a GIF file horse.gif using percentile scaling. The user will be prompted for the percentiles to use.

#### Notes:

The following points should be remembered:
• This initial version of the script generates only 256 grey levels and does not use the image colour lookup table so absolute data values may be lost.

• The NETPBM utilities tifftopnm and ppmtogif must be available on your PATH.

#### Related Applications

Convert: GIF2NDF, NDF2TIFF.