OnnxPredictionSegmentation3d
Computes a prediction on a three-dimensional image from an ONNX model and applies a post processing to generate a label or a binary image.
Access to parameter description
For an introduction, please refer to the Deep Learning section.
The following steps are applied:
If the prediction output contains two channels or more, the channel index presenting the highest score is assigned to each pixel of the output image. The first class, represented in the channel of index 0, is considered as background. The output image has the label interpretation in this case.
Figure 1. Segmentation by deep learning prediction with a model trained with the Avizo
software.
See also
Access to parameter description
For an introduction, please refer to the Deep Learning section.
The following steps are applied:
- Pre-processing
- Prediction
- Post-processing to generate a binary or label output
If the prediction output contains two channels or more, the channel index presenting the highest score is assigned to each pixel of the output image. The first class, represented in the channel of index 0, is considered as background. The output image has the label interpretation in this case.
|
|
See also
Function Syntax
This function returns outputObjectImage.
// Function prototype
std::shared_ptr< iolink::ImageView > onnxPredictionSegmentation3d( std::shared_ptr< iolink::ImageView > inputImage, std::string modelPath, OnnxPredictionSegmentation3d::DataFormat dataFormat, OnnxPredictionSegmentation3d::InputNormalizationType inputNormalizationType, iolink::Vector2d normalizationRange, OnnxPredictionSegmentation3d::NormalizationScope normalizationScope, iolink::Vector3u32 tileSize, uint32_t tileOverlap, std::shared_ptr< iolink::ImageView > outputObjectImage = nullptr );
This function returns outputObjectImage.
// Function prototype. onnx_prediction_segmentation_3d(input_image: idt.ImageType, model_path: str = "", data_format: OnnxPredictionSegmentation3d.DataFormat = OnnxPredictionSegmentation3d.DataFormat.NDHWC, input_normalization_type: OnnxPredictionSegmentation3d.InputNormalizationType = OnnxPredictionSegmentation3d.InputNormalizationType.STANDARDIZATION, normalization_range: Union[Iterable[int], Iterable[float]] = [0, 1], normalization_scope: OnnxPredictionSegmentation3d.NormalizationScope = OnnxPredictionSegmentation3d.NormalizationScope.GLOBAL, tile_size: Iterable[int] = [128, 128, 128], tile_overlap: int = 16, output_object_image: idt.ImageType = None) -> idt.ImageType
This function returns outputObjectImage.
// Function prototype. public static IOLink.ImageView OnnxPredictionSegmentation3d( IOLink.ImageView inputImage, String modelPath = "", OnnxPredictionSegmentation3d.DataFormat dataFormat = ImageDev.OnnxPredictionSegmentation3d.DataFormat.NDHWC, OnnxPredictionSegmentation3d.InputNormalizationType inputNormalizationType = ImageDev.OnnxPredictionSegmentation3d.InputNormalizationType.STANDARDIZATION, double[] normalizationRange = null, OnnxPredictionSegmentation3d.NormalizationScope normalizationScope = ImageDev.OnnxPredictionSegmentation3d.NormalizationScope.GLOBAL, uint[] tileSize = null, UInt32 tileOverlap = 16, IOLink.ImageView outputObjectImage = 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 | NDHWC | ||||||||
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, height, and depth in pixels of the sliding window. This size includes the user defined tile overlap. It must be a multiple of 2 to the power of the number of downsampling or upsampling layers.
Guidelines to select an appropriate tile size are available in the Tiling section. |
Vector3u32 | != 0 | {128, 128, 128} | |||||||
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 | 16 | |||||||
outputObjectImage |
The output image. Its dimensions, and calibration are forced to the same values as the input. Its interpretation is binary if the model produces one channel, label otherwise. | Image | nullptr |
Parameter Name | Description | Type | Supported Values | Default Value | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|
input_image |
The input image. It can be a grayscale or color image, depending on the selected model. | image | Binary, Label, Grayscale or Multispectral | None | |||||||
model_path |
The path to the ONNX model file. | string | "" | ||||||||
data_format |
The tensor layout expected as input by the model. The input image is automatically converted to this layout by the algorithm.
|
enumeration | NDHWC | ||||||||
input_normalization_type |
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 | ||||||||
normalization_range |
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, 1] | |||||||
normalization_scope |
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 | ||||||||
tile_size |
The width, height, and depth in pixels of the sliding window. This size includes the user defined tile overlap. It must be a multiple of 2 to the power of the number of downsampling or upsampling layers.
Guidelines to select an appropriate tile size are available in the Tiling section. |
vector3u32 | != 0 | [128, 128, 128] | |||||||
tile_overlap |
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 | 16 | |||||||
output_object_image |
The output image. Its dimensions, and calibration are forced to the same values as the input. Its interpretation is binary if the model produces one channel, label otherwise. | image | None |
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 | null | |||||||
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 | NDHWC | ||||||||
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 | {0f, 1f} | |||||||
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, height, and depth in pixels of the sliding window. This size includes the user defined tile overlap. It must be a multiple of 2 to the power of the number of downsampling or upsampling layers.
Guidelines to select an appropriate tile size are available in the Tiling section. |
Vector3u32 | != 0 | {128, 128, 128} | |||||||
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 | 16 | |||||||
outputObjectImage |
The output image. Its dimensions, and calibration are forced to the same values as the input. Its interpretation is binary if the model produces one channel, label otherwise. | Image | null |
Object Examples
auto chocolate_bar = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "chocolate_bar.vip" ); OnnxPredictionSegmentation3d onnxPredictionSegmentation3dAlgo; onnxPredictionSegmentation3dAlgo.setInputImage( chocolate_bar ); onnxPredictionSegmentation3dAlgo.setModelPath( std::string( IMAGEDEVDATA_OBJECTS_FOLDER ) + "segmentation3d.onnx" ); onnxPredictionSegmentation3dAlgo.setDataFormat( OnnxPredictionSegmentation3d::DataFormat::NDHWC ); onnxPredictionSegmentation3dAlgo.setInputNormalizationType( OnnxPredictionSegmentation3d::InputNormalizationType::NONE ); onnxPredictionSegmentation3dAlgo.setNormalizationRange( {0, 1} ); onnxPredictionSegmentation3dAlgo.setNormalizationScope( OnnxPredictionSegmentation3d::NormalizationScope::GLOBAL ); onnxPredictionSegmentation3dAlgo.setTileSize( {128, 128, 128} ); onnxPredictionSegmentation3dAlgo.setTileOverlap( 16 ); onnxPredictionSegmentation3dAlgo.execute(); std::cout << "outputObjectImage:" << onnxPredictionSegmentation3dAlgo.outputObjectImage()->toString();
chocolate_bar = imagedev.read_vip_image(imagedev_data.get_image_path("chocolate_bar.vip")) onnx_prediction_segmentation_3d_algo = imagedev.OnnxPredictionSegmentation3d() onnx_prediction_segmentation_3d_algo.input_image = chocolate_bar onnx_prediction_segmentation_3d_algo.model_path = imagedev_data.get_object_path("segmentation3d.onnx") onnx_prediction_segmentation_3d_algo.data_format = imagedev.OnnxPredictionSegmentation3d.NDHWC onnx_prediction_segmentation_3d_algo.input_normalization_type = imagedev.OnnxPredictionSegmentation3d.NONE onnx_prediction_segmentation_3d_algo.normalization_range = [0, 1] onnx_prediction_segmentation_3d_algo.normalization_scope = imagedev.OnnxPredictionSegmentation3d.GLOBAL onnx_prediction_segmentation_3d_algo.tile_size = [128, 128, 128] onnx_prediction_segmentation_3d_algo.tile_overlap = 16 onnx_prediction_segmentation_3d_algo.execute() print("output_object_image:", str(onnx_prediction_segmentation_3d_algo.output_object_image))
ImageView chocolate_bar = Data.ReadVipImage( @"Data/images/chocolate_bar.vip" ); OnnxPredictionSegmentation3d onnxPredictionSegmentation3dAlgo = new OnnxPredictionSegmentation3d { inputImage = chocolate_bar, modelPath = @"Data/objects/segmentation3d.onnx", dataFormat = OnnxPredictionSegmentation3d.DataFormat.NDHWC, inputNormalizationType = OnnxPredictionSegmentation3d.InputNormalizationType.NONE, normalizationRange = new double[]{0, 1}, normalizationScope = OnnxPredictionSegmentation3d.NormalizationScope.GLOBAL, tileSize = new uint[]{128, 128, 128}, tileOverlap = 16 }; onnxPredictionSegmentation3dAlgo.Execute(); Console.WriteLine( "outputObjectImage:" + onnxPredictionSegmentation3dAlgo.outputObjectImage.ToString() );
Function Examples
auto chocolate_bar = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "chocolate_bar.vip" ); auto result = onnxPredictionSegmentation3d( chocolate_bar, std::string( IMAGEDEVDATA_OBJECTS_FOLDER ) + "segmentation3d.onnx", OnnxPredictionSegmentation3d::DataFormat::NDHWC, OnnxPredictionSegmentation3d::InputNormalizationType::NONE, {0, 1}, OnnxPredictionSegmentation3d::NormalizationScope::GLOBAL, {128, 128, 128}, 16 ); std::cout << "outputObjectImage:" << result->toString();
chocolate_bar = imagedev.read_vip_image(imagedev_data.get_image_path("chocolate_bar.vip")) result = imagedev.onnx_prediction_segmentation_3d(chocolate_bar, imagedev_data.get_object_path("segmentation3d.onnx"), imagedev.OnnxPredictionSegmentation3d.NDHWC, imagedev.OnnxPredictionSegmentation3d.NONE, [0, 1], imagedev.OnnxPredictionSegmentation3d.GLOBAL, [128, 128, 128], 16) print("output_object_image:", str(result))
ImageView chocolate_bar = Data.ReadVipImage( @"Data/images/chocolate_bar.vip" ); IOLink.ImageView result = Processing.OnnxPredictionSegmentation3d( chocolate_bar, @"Data/objects/segmentation3d.onnx", OnnxPredictionSegmentation3d.DataFormat.NDHWC, OnnxPredictionSegmentation3d.InputNormalizationType.NONE, new double[]{0, 1}, OnnxPredictionSegmentation3d.NormalizationScope.GLOBAL, new uint[]{128, 128, 128}, 16 ); Console.WriteLine( "outputObjectImage:" + result.ToString() );