ImageDev

ConvertImage

Changes the data type and interpretation of an image.

Access to parameter description

The ConvertImage algorithm changes the arithmetic format of the input image to an output image. Conversion follows the C convention, and no overflow is checked.
When converting to a binary image type, non-zero gray level values are changed to 1, and zero gray level values stay unchanged.

The type of the output image is set by an enumerate as detailed in the Data Type Management section.
The available formats are: For conversion from Scalar to Complex, the imaginary part is set to 0 and the real part to the value of the input image.
For conversion from Complex to Scalar, the output is set to the real part of the input image.

Note: The complex is mainly for internal usage. Most of ImageDev algorithms do not acccept a complex image as input for now.

See also
See related example

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > convertImage( std::shared_ptr< iolink::ImageView > inputImage, ConvertImage::OutputType outputType, std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns outputImage.
// Function prototype.
convert_image( input_image, output_type = ConvertImage.OutputType.SIGNED_INTEGER_16_BIT, output_image = None )
This function returns outputImage.
// Function prototype.
public static IOLink.ImageView
ConvertImage( IOLink.ImageView inputImage,
              ConvertImage.OutputType outputType = ImageDev.ConvertImage.OutputType.SIGNED_INTEGER_16_BIT,
              IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Class Name ConvertImage

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral nullptr
input
outputType
The output image data type.
UNSIGNED_INTEGER_8_BIT The output image data type is 1 byte depth. Its possible intensities are unsigned integer from 0 to 255.
SIGNED_INTEGER_8_BIT The output image data type is 1 byte depth. Its possible intensities are signed integer from -128 to 127.
UNSIGNED_INTEGER_16_BIT The output image data type is 2 bytes depth. Its possible intensities are unsigned integer from 0 to 65,535.
SIGNED_INTEGER_16_BIT The output image data type is 2 bytes depth. Its possible intensities are signed integer from -32,768 to 32,767.
UNSIGNED_INTEGER_32_BIT The output image data type is 4 bytes depth. Its possible intensities are unsigned integer from 0 to 4,294,967,295.
SIGNED_INTEGER_32_BIT The output image data type is 4 bytes depth. Its possible intensities are signed integer from -2,147,483,648 to 2,147,483,647.
FLOAT_32_BIT The output image data type is 4 bytes depth. Its possible intensities are signed floating-point from -3.402823E38 to 3.402823E38.
FLOAT_64_BIT The output image data type is 8 bytes depth. Its possible intensities are signed floating-point from -1.797693E308 to 1.797693E308.
COMPLEX_FLOAT_32_BIT The output image data type is a complex of two 32-bit real floating-point.
COMPLEX_FLOAT_64_BIT The output image data type is a complex of two 64-bit real floating-point.
BINARY The output image data type is 1 byte depth and interpretation is binary. Its possible intensities are unsigned integer from 0 to 1.
LABEL_8_BIT The output image data type is 1 byte depth and interpretation is label. Its possible intensities are unsigned integer from 0 to 255.
LABEL_16_BIT The output image data type is 2 bytes depth and interpretation is label. Its possible intensities are unsigned integer from 0 to 65,535.
LABEL_32_BIT The output image data type is 4 bytes depth and interpretation is label. Its possible intensities are unsigned integer from 0 to 4,294,967,295.
Enumeration SIGNED_INTEGER_16_BIT
output
outputImage
The output image. Image nullptr

Object Examples

auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" );

ConvertImage convertImageAlgo;
convertImageAlgo.setInputImage( foam );
convertImageAlgo.setOutputType( ConvertImage::OutputType::UNSIGNED_INTEGER_8_BIT );
convertImageAlgo.execute();

std::cout << "outputImage:" << convertImageAlgo.outputImage()->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))

convert_image_algo = imagedev.ConvertImage()
convert_image_algo.input_image = foam
convert_image_algo.output_type = imagedev.ConvertImage.UNSIGNED_INTEGER_8_BIT
convert_image_algo.execute()

print( "output_image:", str( convert_image_algo.output_image ) )
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );

ConvertImage convertImageAlgo = new ConvertImage
{
    inputImage = foam,
    outputType = ConvertImage.OutputType.UNSIGNED_INTEGER_8_BIT
};
convertImageAlgo.Execute();

Console.WriteLine( "outputImage:" + convertImageAlgo.outputImage.ToString() );

Function Examples

auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" );

auto result = convertImage( foam, ConvertImage::OutputType::UNSIGNED_INTEGER_8_BIT );

std::cout << "outputImage:" << result->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))

result = imagedev.convert_image( foam, imagedev.ConvertImage.UNSIGNED_INTEGER_8_BIT )

print( "output_image:", str( result ) )
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );

IOLink.ImageView result = Processing.ConvertImage( foam, ConvertImage.OutputType.UNSIGNED_INTEGER_8_BIT );

Console.WriteLine( "outputImage:" + result.ToString() );