Coyote Graphics Routines

Date: Fri Mar 27 12:14:20 2015

single page | use frames     summary     class     fields     routine details     file attributes

.\

cgscalevector.pro


top cgScaleVector

Utilities

result = cgScaleVector(vector [, minRange] [, maxRange] [, /DOUBLE] [, MAXVALUE=MAXVALUE] [, MINVALUE=MINVALUE] [, /NAN] [, /PRESERVE_TYPE])

This is a utility routine to scale the elements of a vector or an array into a given data range.

Return value

A vector or array of the same size as the input, scaled into the data range given by minRange and maxRange'. The input vector is confined to the data range set by MinValue and MaxValue before scaling occurs.

Parameters

vector in required

The input vector or array to be scaled.

minRange in optional type=varies default=0

The minimum output value of the scaled vector. Set to 0 by default.

maxRange in optional type=varies default=1

The maximum output value of the scaled vector. Set to 1 by default.

Keywords

DOUBLE in optional type=boolean default=0

Set this keyword to perform scaling in double precision. Otherwise, scaling is done in floating point precision.

MAXVALUE in optional

Set this value to the maximum value of the vector, before scaling (vector < maxvalue). The default value is Max(vector).

MINVALUE in optional

Set this value to the mimimum value of the vector, before scaling (minvalue < vector). The default value is Min(vector).

NAN in optional type=boolean default=0

Set this keyword to enable not-a-number checking. NANs in vector will be ignored.

PRESERVE_TYPE in optional type=boolean default=0

Set this keyword to preserve the input data type in the output.

Examples

Simple example of scaling a vector:

IDL> x = [3, 5, 0, 10] IDL> xscaled = cgScaleVector(x, -50, 50) IDL> Print, xscaled -20.0000 0.000000 -50.0000 50.0000
Suppose your image has a minimum value of -1.7 and a maximum value = 2.5. You wish to scale this data into the range 0 to 255, but you want to use a diverging color table. Thus, you want to make sure value 0.0 is scaled to 128. You proceed like this:
scaledImage = cgScaleVector(image, 0, 255, MINVALUE=-2.5, MAXVALUE=2.5)

Author information

Author:

FANNING SOFTWARE CONSULTING:

David W. Fanning 1645 Sheely Drive Fort Collins, CO 80526 USA Phone: 970-221-0438 E-mail: david@idlcoyote.com Coyote's Guide to IDL Programming: http://www.idlcoyote.com

Copyright:

Copyright (c) 1998-2013, Fanning Software Consulting, Inc.

History:

Change History:

Written by: David W. Fanning, 12 Dec 1998. Added MAXVALUE and MINVALUE keywords. 5 Dec 1999. DWF. Added NAN keyword. 18 Sept 2000. DWF. Removed check that made minRange less than maxRange to allow ranges to be reversed on axes, etc. 28 Dec 2003. DWF. Added PRESERVE_TYPE and DOUBLE keywords. 19 February 2006. DWF. Added FPUFIX to cut down on floating underflow errors. 11 March 2006. DWF. Renamed Scale_Vector to cgScaleVector, 16 May 2013. DWF.

File attributes

Modification date: Fri Mar 27 11:07:38 2015
Lines: 192
Docformat: rst rst