DynamicConvert

Change the pixel type and rescale the image’s dynamic

Description

This application performs an image pixel type conversion (short, ushort, uchar, int, uint, float and double types are handled). The output image is written in the specified format (ie. that corresponds to the given extension). The conversion can include a rescale of the data range, by default it’s set between the 2nd to the 98th percentile. The rescale can be linear or log2. The choice of the output channels can be done with the extended filename, but less easy to handle. To do this, a ‘channels’ parameter allows you to select the desired bands at the output. There are 3 modes, the available choices are:

  • All: keep all bands.

  • Grayscale: to display mono image as standard color image

  • RGB: select 3 bands in the input image (multi-bands)

Parameters

Input image -in image Mandatory
Input image

Output Image -out image [dtype] Mandatory
Output image

Rescale type -type [linear|log2] Default value: linear
Transfer function for the rescaling

  • Linear

  • Log2

Linear options

Gamma correction factor -type.linear.gamma float Default value: 1
Gamma correction factor


Input mask -mask image
Optional mask to indicate which pixels are valid for computing the histogram quantiles. Pixels where the mask is zero will not contribute to the histogram. The mask must have the same dimensions as the input image.

Histogram quantile cutting

Cut the histogram edges before rescaling

High cut quantile -quantile.high float Default value: 2
Quantiles to cut from histogram high values before computing min/max rescaling (in percent, 2 by default)

Low cut quantile -quantile.low float Default value: 2
Quantiles to cut from histogram low values before computing min/max rescaling (in percent, 2 by default)


Channels selection -channels [all|grayscale|rgb] Default value: all
It’s possible to select the channels of the output image. There are 3 modes, the available choices are:

  • Default mode
    Select all bands in the input image, (1,…,n).

  • Grayscale mode
    Display single channel as standard color image.

  • RGB composition
    Select 3 bands in the input image (multi-bands), by default (1,2,3).

Grayscale mode options

Grayscale channel -channels.grayscale.channel int Default value: 1

RGB composition options

Red Channel -channels.rgb.red int Mandatory
Red channel index.

Green Channel -channels.rgb.green int Mandatory
Green channel index.

Blue Channel -channels.rgb.blue int Mandatory
Blue channel index.


Output min value -outmin float Default value: 0
Minimum value of the output image.

Output max value -outmax float Default value: 255
Maximum value of the output image.

Available RAM (MB) -ram int Default value: 256
Available memory for processing (in MB).

Examples

From the command-line:

otbcli_DynamicConvert -in QB_Toulouse_Ortho_XS.tif -out otbConvertWithScalingOutput.png -type linear -channels rgb -outmin 0 -outmax 255

From Python:

import otbApplication

app = otbApplication.Registry.CreateApplication("DynamicConvert")

app.SetParameterString("in", "QB_Toulouse_Ortho_XS.tif")
app.SetParameterString("out", "otbConvertWithScalingOutput.png")
app.SetParameterString("type","linear")
app.SetParameterString("channels","rgb")
app.SetParameterFloat("outmin", 0)
app.SetParameterFloat("outmax", 255)

app.ExecuteAndWriteOutput()

Limitations

The application does not support complex pixel types as output.

See also

Rescale