Skip to content

Gdal contrast stretch

Dayne Broderson edited this page Feb 15, 2015 · 2 revisions
Usage: gdal_contrast_stretch <options> src.tif dst.tif

No-data values:
  -ndv val                           Set a no-data value
  -ndv 'val val ...'                 Set a no-data value using all input bands
  -ndv 'min..max min..max ...'       Set a range of no-data values
                                     (-Inf and Inf are allowed)
  -valid-range 'min..max min..max ...'  Set a range of valid data values
  -outndv <output_nodata_val>        Output no-data value

  -linear-stretch <target_avg> <target_stddev>      Linear stretch to a target range
  -percentile-range <from: 0.0-1.0> <to: 0.0-1.0>   Linear stretch using a percentile range of input
  -histeq <target_stddev>                           Histogram normalize to a target bell curve
  -dump-histogram                                   Just print the histogram to console

Input can be any integer or floating type (but not complex).  Output is 8-bit.

For example:

gdal_contrast_stretch -ndv 0 -percentile-range 0.02 0.98 \
     rgb-654-16bit.vrt rgb-654-8bit.tif
You can’t perform that action at this time.