Level Surface

Use this tool to level tilted or curved surfaces, e.g., spheres or cylinders, in the images. You may use images with arbitrary pixel types as input, e.g., 16 bit images. If you want to process objects or areas in the images that are tilted or curved, e.g., if you want to read text and numbers on tilted or curved objects, you can use this tool to level the surface for further processing steps.

The tool provides two different types of compensation methods: a tilt compensation for tilted surfaces and a curvature compensation for curved surfaces.

To level the surface, the fitting data for the compensation of the tilt or curvature are calculated first. They can be determined from different sources: from a training image or from the processing images. For a tilt compensation, the fitting data represent the parameters of the gray values approximation by a first order surface. For a curvature compensation, the approximation is done by a second order surface. The resulting fitting data are then used to compensate the tilt or the curvature in the image. If you want to compensate the surface only at a specific area in the images, you can define the desired area in the processing image with regions of interest (ROIs) or processing regions.

This tool provides a training mode but the training mode is only required if the fitting data for the compensation are determined from a training image. If you want to determine the fitting data from the processing images, the training image has no effect. See the topic Working with the Training Mode to learn more about how to work with tools that require a training.

If you are working with images that have been acquired from a 3D sensor, it might be necessary to perform some additional preprocessing steps. The conversion of the images to 8-bit images is mandatory to ensure that the images can be processed correctly in subsequent tools. Other preprocessing steps can be performed according to your requirements. The provided MERLIC tools of the category 3D Height Image are especially designed for this preprocessing tasks. For more detailed information about the recommended order of the preprocessing steps, please see the topic 3D Height Image.

Determining the Fitting Data

You can choose between different sources to determine the fitting data. The selected source at the parameter "Source for Fitting Data" specifies how the fitting data are determined and from which image.

Determining the Fitting Data From a Training Image

In this mode the fitting data for the compensation of tilted or curvature surfaces are determined automatically from the selected training image.

  1. Select the source "Training Image (Training ROI)" at the parameter "Source for Fitting Data".
  2. Select the training image you want to use for determining the fitting data.
  3. Change to the training image.
  4. Draw a region of interest (ROI) into the training image to select the tilted or curved surface and to restrict the area in which the fitting data are extracted.

The determined fitting data will be used to level the surface in all processing images.

If this mode is selected, possibly defined regions in "Region for Fitting" will be ignored.

Defining the Fitting Data From the Processing Images

In this mode the fitting data are determined from the processing images.

  1. Select the source "Processing Image (Region/ROI for Fitting)" at the parameter "Source for Fitting Data".
  2. Define the region from which the fitting data are determined by connecting a region of a previous tool to the parameter "Region for Fitting" or by drawing an ROI over the respective image part. If no region and no ROI is defined, the fitting data are determined from the whole image.

The fitting data will be applied only to level the surface of the current processing image. For each processing image, the fitting data will be determined anew.

Parameters

Depending on the selected source at the parameter "Source for Fitting Data", some connectors are grayed out. This means that they are not applicable for the currently selected source and thus have no effect.

Basic Parameters

Image:

This parameter represents the image in which the surface is leveled. If you are using images with a pixel type different than 8 bit, you have to convert the images either before or directly after this tool to make sure that they can be processed in subsequent tools.

Source for Fitting Data:

This parameter defines from which image the fitting data for the tilt or curvature compensation are determined. It is set to "Training Image (Training ROI)" by default.

Value

Description

Training Image (Training ROI)

The fitting data are calculated based on the gray values in the training image. This means the fitting data are determined once and used in all processing images.

Processing Image (Region/ROI for Fitting)

The fitting data are calculated based on the gray values in the processing image. This means the fitting data are determined anew for each processing image. The training image will be ignored.

Additional Parameters

ROI for Fitting:

This parameter defines the region of interest (ROI) for the fitting. Image parts outside of this ROI are not used for the fitting. In case the processing image is selected as source for the fitting, the final image area for the fitting is also determined by the region that is defined in the parameter "Processing Region" and the region defined in the parameter "Region for Fitting". If none of these regions or ROIs is empty, only the image part of the intersection of this regions and ROIs is used for the fitting.

By default the ROI is defined as an empty ROI. If you want to use a non-empty ROI for the processing, you either have to connect the parameter to an appropriate ROI result of a previous tool or you have to draw new ROIs into the image using the available ROI buttons.

The ROI defined in this parameter is only applied if the source "Processing Image (Region/ROI for Fitting)" is selected at the parameter "Source for Fitting Data".

Alignment Data:

This parameter represents the alignment data that are used to align the ROI. By default no alignment data are connected and thus no effect is visible. If you want to use specific alignment data, you have to connect the parameter to an appropriate result of a previous tool such as Determine Alignment with Matching, Determine Alignment with Straight Border, Align Image, or Rotate Image.

The Alignment Data is only applied if the source "Processing Image (Region/ROI for Fitting)" is selected at the parameter "Source for Fitting Data".

Surface Level Offset:

This parameter defines the offset for the plane of the leveled surface. By default, the value is set to 0. This means that the surface is leveled at the middle of the gray range that has been determined from the image, e.g., 128 in case of 8-bit images or 32000 in case of 16-bit images. If you want to level the surface at a different plane, you can use this parameter to define an offset. The specified value will be added to the gray value that represents the middle of the gray range. The resulting value then represents the final plane of the leveled surface.

Region for Fitting:

This parameter defines the region in which the fitting data for the tilt or curvature compensation are determined. Image parts outside of this region are not used for the fitting. In case the processing image is selected as source for the fitting, the final image area for the fitting is also determined by the region that is defined in the parameter "Processing Region" and the ROI that has been drawn or defined at the parameter "ROI for Fitting". If none of these regions or ROIs is empty, only the image part of the intersection of this regions and ROIs is used for the fitting.

By default the region is defined as empty region. To specify a region for the fitting, you have to connect the parameter to an appropriate region result of a previous tool to make sure that a region is transmitted to this tool.

The region defined in this parameter is only applied if the source "Processing Image (Region/ROI for Fitting)" is selected at the parameter "Source for Fitting Data".

Processing Region:

This parameter defines the region in which the tools functionality is applied. Image parts outside of this region are not processed, neither for determining the fitting data nor for leveling the surface.

By default the "Processing Region" is defined as empty region. To specify a "Processing Region", you have to connect the parameter to an appropriate region result of a previous tool to make sure that a region is transmitted to this tool.

Training Parameters

Basic Training Parameters

Compensation Method:

This parameter defines the method for the compensation. It is set to "Tilt Compensation" by default.

Value

Description

Tilt Compensation

This compensation method can be selected if you want to level the surface of tilted objects or areas.

Curvature Compensation

This compensation method can be used to level the surface of objects or areas that are curved.

Results

Basic Results

Leveled Image:

This result represents the image with the leveled surface.

Tool State:

"Tool State" returns information about the state of the tool and thus can be used for error handling. For more information, see Tool State Result

Additional Results

Fitting Parameters:

This result returns the fitting parameters that have been used for the compensation of the tilt or curvature, respectively. They are returned as a tuple that contains various values. In case of the compensation method "Tilt Compensation" is selected, the first three values describe the fitted surface that has been used to level the surface, e.g., the normal vector in case of a plane, whereas the last two values give information about the center.

Fitting Image:

This result returns the gray surface image with the fitting data that are used for the compensation of the tilt or curvature, respectively.

Region for Fitting Used:

This result returns the region that has been used for the fitting.

Processing Time:

This result returns the duration of the most recent execution of the tool in milliseconds. The result is provided as additional result. Therefore, it is hidden by default but it can be displayed via the button beside the tool results. For more information see the section Processing Time in the tool reference overview.

Application Examples

This tool is used in the following MERLIC Vision App examples:

  • check_correct_filling_on_3d_height_images.mvapp