OnnxPredictionFiltering2d
Computes a prediction on a two-dimensional image from an ONNX model and generates an image representing the prediction scores.
Access to parameter description
For an overview, please refer to the Deep Learning section.
This algorithm produces an image containing the raw prediction scores given by the model. Depending on how the model has been trained, it can be used either to perform image filtering, or segmentation by applying an appropriate post-processing step afterwards.
The following steps are applied:

Figure 1. Membrane segmentation by deep learning prediction with noise to noise model.
See also
Access to parameter description
For an overview, please refer to the Deep Learning section.
This algorithm produces an image containing the raw prediction scores given by the model. Depending on how the model has been trained, it can be used either to perform image filtering, or segmentation by applying an appropriate post-processing step afterwards.
The following steps are applied:
- Pre-processing
- Prediction
- Post-processing to optionally restore the prediction result into the input data range

Figure 1. Membrane segmentation by deep learning prediction with noise to noise model.
See also
Function Syntax
This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > onnxPredictionFiltering2d( std::shared_ptr< iolink::ImageView > inputImage, std::string modelPath, OnnxPredictionFiltering2d::DataFormat dataFormat, OnnxPredictionFiltering2d::InputNormalizationType inputNormalizationType, iolink::Vector2d normalizationRange, OnnxPredictionFiltering2d::NormalizationScope normalizationScope, iolink::Vector2u32 tileSize, uint32_t tileOverlap, OnnxPredictionFiltering2d::OutputNormalizationType outputNormalizationType, OnnxPredictionFiltering2d::OutputType outputType, std::shared_ptr< iolink::ImageView > outputImage = NULL );
Class Syntax
Parameters
Parameter Name | Description | Type | Supported Values | Default Value | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
inputImage |
The input image. It can be a grayscale or color image, depending on the selected model. | Image | Binary, Label, Grayscale or Multispectral | nullptr | ||||||
![]() |
modelPath |
The path to the ONNX model file. | String | "" | |||||||
![]() |
dataFormat |
The tensor layout expected as input by the model. The input image is automatically converted to this layout by the algorithm.
|
Enumeration | NHWC | |||||||
![]() |
inputNormalizationType |
The type of normalization to apply before computing the prediction. It is recommended to apply the same pre-processing as during the training.
|
Enumeration | STANDARDIZATION | |||||||
![]() |
normalizationRange |
The data range in which the input image is normalized before computing the prediction. It is recommended to apply the same pre-processing as during the training. This parameter is ignored if the normalization type is set to none. | Vector2d | Any value | {0.f, 1.f} | ||||||
![]() |
normalizationScope |
The scope for computing normalization (mean, standard deviation, minimum or maximum). This parameter is ignored if the normalization type is set to none.
|
Enumeration | GLOBAL | |||||||
![]() |
tileSize |
The width and height in pixels of the sliding window. This size includes the user defined tile overlap. | Vector2u32 | Any value | {256, 256} | ||||||
![]() |
tileOverlap |
The number of pixels used as overlap between the tiles. An overlap of zero may lead to artifacts in the prediction result. A non-zero overlap reduces such artifacts but increases the computation time. | UInt32 | Any value | 32 | ||||||
![]() |
outputNormalizationType |
The type of normalization to apply after computing the prediction. This parameter is ignored if the input normalization type is set to none.
|
Enumeration | NONE | |||||||
![]() |
outputType |
The output data type. It can either be the same as the input type or forced to float. This parameter is ignored if the input normalization type is set to none.
|
Enumeration | SAME_AS_INPUT | |||||||
![]() |
outputImage |
The output image. Dimensions, and calibration of the output image are forced to the same values as the input. Its number of channels depends on the selected model. Its type depends on the selected output type. | Image | nullptr |
Object Examples
std::shared_ptr< iolink::ImageView > autorad = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "autorad.tif" ); OnnxPredictionFiltering2d onnxPredictionFiltering2dAlgo; onnxPredictionFiltering2dAlgo.setInputImage( autorad ); onnxPredictionFiltering2dAlgo.setModelPath( std::string( IMAGEDEVDATA_OBJECTS_FOLDER ) + "noise2noise.onnx" ); onnxPredictionFiltering2dAlgo.setDataFormat( OnnxPredictionFiltering2d::DataFormat::NHWC ); onnxPredictionFiltering2dAlgo.setInputNormalizationType( OnnxPredictionFiltering2d::InputNormalizationType::NONE ); onnxPredictionFiltering2dAlgo.setNormalizationRange( {0, 1} ); onnxPredictionFiltering2dAlgo.setNormalizationScope( OnnxPredictionFiltering2d::NormalizationScope::GLOBAL ); onnxPredictionFiltering2dAlgo.setTileSize( {128, 128} ); onnxPredictionFiltering2dAlgo.setTileOverlap( 32 ); onnxPredictionFiltering2dAlgo.setOutputNormalizationType( OnnxPredictionFiltering2d::OutputNormalizationType::NONE ); onnxPredictionFiltering2dAlgo.setOutputType( OnnxPredictionFiltering2d::OutputType::SAME_AS_INPUT ); onnxPredictionFiltering2dAlgo.execute(); std::cout << "outputImage:" << onnxPredictionFiltering2dAlgo.outputImage()->toString();
Function Examples
std::shared_ptr< iolink::ImageView > autorad = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "autorad.tif" ); auto result = onnxPredictionFiltering2d( autorad, std::string( IMAGEDEVDATA_OBJECTS_FOLDER ) + "noise2noise.onnx", OnnxPredictionFiltering2d::DataFormat::NHWC, OnnxPredictionFiltering2d::InputNormalizationType::NONE, {0, 1}, OnnxPredictionFiltering2d::NormalizationScope::GLOBAL, {128, 128}, 32, OnnxPredictionFiltering2d::OutputNormalizationType::NONE, OnnxPredictionFiltering2d::OutputType::SAME_AS_INPUT ); std::cout << "outputImage:" << result->toString();