Coyote Graphics Routines

Date: Fri Mar 27 12:14:20 2015

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


top cgClipScl

Image Processing

result = cgClipScl(image [, clip], NEGATIVE=NEGATIVE [, OMAX=byte] [, OMIN=byte] [, THRESHOLD=THRESHOLD])

This is a utility routine to perform linear scaling (similar to BYTSCL) on image arrays. If differs from BYTSCL only in that a user-specified percentage of pixels can be clipped from the image histogram, prior to scaling. By default, two percent of the pixels are clipped. Clipping occurs at both ends of the image histogram.

Return value

A byte scaled image is returned.


image in required

The image to be scaled. Written for 2D images, but arrays of any size are treated alike.

clip in optional type=float default=2.0

The percent of image clipping. Must be value between 0 and 49. Clipping occurs from both ends of image histogram, so a clip of 2.0 linearly scales approximately 96% of the image histogram. Clipping percents are approximations only, and depend entirely on the distribution of pixels in the image. For interactive scaling, see cgStretch.



If set, the "negative" of the result is returned.

OMAX in optional type=byte default=255

The output image is scaled between OMIN and OMAX.

OMIN in optional type=byte default=0

The output image is scaled between OMIN and OMAX.

THRESHOLD out optional

A two-element array containing the image thresholds that were used for the clipping.


To display a clipped image:

cgLoadCT, 0 ; Gray-scale colors. image = cgDemoData(22) ; Load image. cgImage, cgClipScl(image, 4)

Author information



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


Copyright (c) 2007-2015, Fanning Software Consulting, Inc.


Change History:

Written by: David W. Fanning, 6 September 2007. Not sure what this program was doing, but not what I thought. I've reworked the algorithm to scale the data appropriately. 25 Oct 2011. DWF. Renamed cgClipScl from ClipScl. 27 March 2015. DWF.

File attributes

Modification date: Fri Mar 27 12:06:40 2015
Lines: 178
Docformat: rst rst