Convert - Image Conversion

Convert an image to a different format, optionally rescaling the data and/or changing the pixel type.

Detailed 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 from 2% to 98% of the data values. 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: * grayscale : to display mono image as standard color image * rgb : select 3 bands in the input image (multi-bands) * all : keep all bands.

Parameters

This section describes in details the parameters available for this application. Table [1] presents a summary of these parameters and the parameters keys to be used in command-line and programming languages. Application key is Convert .

[1]Table: Parameters table for Image Conversion.
Parameter Key Parameter Name Parameter Type
in Input image Input image
type Rescale type Choices
type none None Choice
type linear Linear Choice
type log2 Log2 Choice
type.linear.gamma Gamma correction factor Float
mask Input mask Input image
hcp Histogram Cutting Parameters Group
hcp.high High Cut Quantile Float
hcp.low Low Cut Quantile Float
out Output Image Output image
channels Channels selection Choices
channels all Default mode Choice
channels grayscale Grayscale mode Choice
channels rgb RGB composition Choice
channels.grayscale.channel Grayscale channel Int
channels.rgb.red Red Channel Int
channels.rgb.green Green Channel Int
channels.rgb.blue Blue Channel Int
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file

Input image: Input image.

Rescale type: Transfer function for the rescaling. Available choices are:

  • None
  • Linear
  • Gamma correction factor: Gamma correction factor.
  • Log2

Input mask: The masked pixels won’t be used to adapt the dynamic (the mask must have the same dimensions as the input image).

[Histogram Cutting Parameters]: Parameters to cut the histogram edges before rescaling.

  • High Cut Quantile: Quantiles to cut from histogram high values before computing min/max rescaling (in percent, 2 by default).
  • Low Cut Quantile: Quantiles to cut from histogram low values before computing min/max rescaling (in percent, 2 by default).

Output Image: Output image.

Channels selection: It’s possible to select the channels of the output image. There are 3 modes, the available choices are:. Available choices are:

  • Default mode: Select all bands in the input image, (1,...,n).
  • Grayscale mode: Display single channel as standard color image.
  • Grayscale channel
  • RGB composition: Select 3 bands in the input image (multi-bands), by default (1,2,3).
  • Red Channel: Red channel index.
  • Green Channel: Green channel index.
  • Blue Channel: Blue channel index.

Available RAM (Mb): Available memory for processing (in MB).

Load otb application from xml file: Load otb application from xml file.

Save otb application to xml file: Save otb application to xml file.

Example

To run this example in command-line, use the following:

otbcli_Convert -in QB_Toulouse_Ortho_XS.tif -out otbConvertWithScalingOutput.png -type linear -channels rgb

To run this example from Python, use the following code snippet:

#!/usr/bin/python

# Import the otb applications package
import otbApplication

# The following line creates an instance of the Convert application
Convert = otbApplication.Registry.CreateApplication("Convert")

# The following lines set all the application parameters:
Convert.SetParameterString("in", "QB_Toulouse_Ortho_XS.tif")

Convert.SetParameterString("out", "otbConvertWithScalingOutput.png")

Convert.SetParameterString("type","linear")

Convert.SetParameterString("channels","rgb")

# The following line execute the application
Convert.ExecuteAndWriteOutput()

Limitations

None

Authors

This application has been written by OTB-Team.

See Also

These additional resources can be useful for further information:
Rescale