# coyote: CGIMGSCL

- coyote/Graphics
- coyote/Utilities
- [Source code]

Description

      This function scales an image using the same keywords and scaling available in
      cgImage and cgStretch. Set the `Stretch` keyword for the types of image scaling
      or stretching available.

Categories

      Graphics, Utilities

Returns

      Returns a scaled image.

Params

      image: in, required
         The input image that is to be scaled. Only 2D images can be scaled, although
         true-color images can be resized.
      xsize: in, optional
         The output X size of the image.
      ysize: in, optional
         The output Y size of the image.

Keywords

      bottom: in, optional, type=integer, default=0
           If the `SCALE` keyword is set, the image is scaled before display so that all
           displayed pixels have values greater than or equal to `BOTTOM` and less than
           or equal to `TOP`.
      beta: in, optional, type=float, default=3.0
           The beta factor in a Hyperpolic Sine stretch.
      clip: in, optional, type=float, default=2
           A number between 0 and 50 that indicates the percentage of pixels to clip
           off either end of the image histogram before performing a linear stretch.
      constant: in, optional, type=float, default=1.0
           A constant value applied in a logarithmic stretch.
      exclude: in, optional, type=numeric
           The value to exclude in a standard deviation stretch.
      exponent: in, optional, type=float, default=4.0
           The logarithm exponent in a compression stretch.
      gamma: in, optional, type=float, default=1.5
           The gamma factor in a gamma stretch.
      interpolate: in, optional, type=boolean, default=0
           Set this keyword to interpolate with bilinear interpolation the display image as it
           is sized to its final position in the display window. Interpolation will potentially
           create image values that do not exist in the original image. The default is to do no
           interpolation, so that image values to not change upon resizing. Interpolation can
           result in smoother looking final images.
      maxvalue: in, optional, type=varies
           If this value is defined, the data is linearly scaled between `MINVALUE`
           and `MAXVALUE`. `MAXVALUE` is set to `MAX`(image) by default. Setting this
           keyword to a value automatically sets `SCALE` to 1. If the maximum value of the
           image is greater than 255, this keyword is defined and SCALE=1.
      mean: in, optional, type=float, default=0.5
           The mean factor in a compression stretch.
      minus_one: in, optional, type=boolean, default=0
           The value of this keyword is passed along to the cgResizeImage
           command. It prevents cgResizeImage from adding an extra row and
           column to the resulting array, which can be a problem with
           small image arrays.
      minvalue: in, optional, type=varies
           If this value is defined, the data is linearly scaled between MINVALUE
           and `MAXVALUE`. `MINVALUE` is set to `MIN`(image) by default. Setting this
           keyword to a value automatically sets SCALE=1. If the minimum value of the
           image is less than 0, this keyword is defined and SCALE=1.
      missing_index: in, optional, type=integer, default=255
           The index of the missing color in the final byte scaled image.
      missing_value: in, optional, type=integer
           The number that represents the missing value in the image.
      multiplier: in, optional, type=float
           The multiplication factor in a standard deviation stretch. The standard deviation
           is multiplied by this factor to produce the thresholds for a linear stretch.
      ncolors: in, optional, type=integer, default=256
           If this keyword is supplied, the `TOP` keyword is ignored and the TOP keyword
           is set equal to  NCOLORS-1. This keyword is provided to make cgImgScl easier
           to use with the color-loading programs such as cgLOADCT::
                cgLoadCT, 5, NColors=100, Bottom=100
                scaled = cgImgScl(image, NColors=100, Bottom=100)
           Setting this keyword to a value automatically sets SCALE=1 and STRETCH='LINEAR', if not
           defined otherwise. Available only with 2D images.
      negative: in, optional, type=boolean, default=0
           Set this keyword if you want to display the image with a negative or reverse stretch.
      scale: in, optional, type=boolean, default=0
           Set this keyword to byte scale the image before display. If this keyword is not set,
           the image is not scaled before display. This keyword will be set automatically by using
           any of the keywords normally associated with byte scaling an image.
      stretch: in, optional, type=integer/string, default=0
           The type of scaling performed prior to display. May be specified as a number
           or as a string (e.g, 3 or "Log"). Available only with 2D images. If  Min(image)
           is less than zero or Max(image) is greater than 255, then the default value for
           stretch is 1.
           Number   Type of Stretch::
               0         None           No scaling whatsoever is done.
               1         Linear         scaled = BytScl(image, MIN=minValue, MAX=maxValue)
               2         Linear 2%      A histogram stretch, with a percentage of pixels clipped at both the top and bottom
               3         Gamma          scaled = cgGmaScl(image, MIN=minValue, MAX=maxValue, Gamma=gamma)
               4         Log            scaled = cgLogScl(image, MIN=minValue, MAX=maxValue, Mean=mean, Exponent=exponent)
               5         Asinh          scaled = cgAsinhScl(image, MIN=minValue, MAX=maxValue, Beta=beta)
               6         SquareRoot     A linear stretch of the square root histogram of the image values.
               7         Equalization   A linear stretch of the histogram equalized image histogram.
               8         Gaussian       A Gaussian normal function is applied to the image histogram.
               9         MODIS          Scaling done in the differential manner of the MODIS Rapid Response Team
                                        and implemented in the Coyote Library routine ScaleModis.
               10        StdDev         Standard deviation stretch. scaled = cgSDevScl(image, MULTIPLIER=2).
               11        Compression    Compress mid-tones in image with cgCompressScl.
      sigma: in, optional, type=float, default=1.0
           The sigma scale factor in a Gaussian stretch.
      top: in, optional, type=integer, default=255
           If the `SCALE` keyword is set, the image is scaled before display so that all
           displayed pixels have values greater than or equal to `BOTTOM` and less than
           or equal to `TOP`.

Examples

      Used to for image display::
         IDL> scaledImage = cgImgScl(image, Stretch=4, Exponent=2)
         IDL> cgImage, scaledImage[0:100, 200:400], /Keep_Aspect

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

History

      Change History::
        Written by David W. Fanning, 21 September 2012.
        Only define MISSING_INDEX value if needed. Change to support TRANSPARENT keyword
           in cgImage. 18 October 2012. DWF.
        Only 2D images can be scaled. 18 October 2012. DWF.
        Made LOG stretch a real log stretch and add a compression stretch. 27 March 2015. DWF.

Copyright

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