# coyote: CGCOMPRESSSCL

- coyote/Image Processing
- [Source code]

Description

      This is a utility routine to perform a compression transformation
      on an image. For exponent values greater than 1.0, the upper and
      lower values of the image are compressed and centered on the mean.
      Larger exponent values provide steeper compression. See pages 68-70 in
      _Digital Image Processing with MATLAB_ by Gonzales, Wood, and Eddins.
      The function is used to improve contrast in images. The equation being
      implemented before scaling between OMIN and OMAX is as follows::
          output = 1.0D / ((1.0D + (mean / (Temporary(input) > 1e-16))^exponent) > (1e-16))

Categories

      Image Processing

Returns

      A byte scaled image is returned.

Params

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

Keywords

      exponent: in, optional, type=float, default=4.0
          The exponent in the compression transformation. By default, 4.0.
      max: in, optional
           Any value in the input image greater than this value is set to this value
           before scaling.
      mean: in, optional, type=float, default=0.5
           Values on either side of the mean will be compressed by the log. The value is a
           normalized value between 0.0 and 1.0.
      min: in, optional
           Any value in the input image less than this value is set to this value
           before scaling.
      negative, in, optional, type=boolean, default=0
           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.

Examples

      Examples of compression stretching::
         cgLoadCT, 0                                              ; Gray-scale colors.
         image = cgDemoData(22)                                   ; Load image.
         cgImage, image                                           ; No contrast.
         cgImage, cgCompressScl(image)                            ; Improved contrast.
         cgImage, cgCompressScl(image, Exponent=10, Mean=0.65)    ; Even more contrast.
         cgImage, cgCompressScl(image, /Negative, Exponent=5)     ; A negative image.

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, 20 February 2006.
        Fixed a problem with output scaling. 1 July 2009. DWF (with input from Bo Milvang-Jensen).
        Renamed cgCompressScl from LogScl when I discoverd LogScl implemented the wrong scaling equation.
           See the documentation in the retired LogScl program for details. 27 March 2015. DWF.

Copyright

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