Min-max contrast stretch

This tool performs a minimum-maximum contrast stretch on a raster image. This operation maps each grid cell value in the input raster image (z) onto a new scale that ranges from the user-specified lower-tail clip value (L) to the upper-tail clip value (U), with the specified number of tonal values (n), such that:

zn = (z - L) / (U - L) × n

where zn is the output value. Notice that any values in the input image that are less than L are assigned a value of L in the output image. Similarly, any input values greater than U are assigned a value of U in the output image. This is a type of linear contrast stretch with saturation at the tails of the frequency distribution. This is the same kind of stretch that is used to display raster type data on the fly in Whitebox, such that the lower and upper tail values are set using the minimum and maximum display values in the Layer Properties and the number of tonal values is determined by the number of palette entries.

See Also:

Scripting:

The following is an example of a Python script that uses this tool:

wd = pluginHost.getWorkingDirectory()
inputFile = wd + "input.dep"
outputFile = wd + "output.dep"
lowerTail = "10.0"
upperTail = "245.0"
numTones = "256"
args = [inputFile, outputFile, lowerTail, upperTail, numTones]
pluginHost.runPlugin("MinMaxContrastStretch", args, False)

This is a Groovy script also using this tool:

def wd = pluginHost.getWorkingDirectory()
def inputFile = wd + "input.dep"
def outputFile = wd + "output.dep"
def lowerTail = "10.0"
def upperTail = "245.0"
def numTones = "256"
String[] args = [inputFile, outputFile, lowerTail, upperTail, numTones]
pluginHost.runPlugin("MinMaxContrastStretch", args, false)

Credits: