You copied the Doc URL to your clipboard.

# How do I configure the custom transformation of the Geometric Distortion Correction tool?

• Software

## Problem/Question

How do I configure the custom transformation of the Geometric Distortion Correction tool?

## Scenario

N/A

The Geometric Distortion Correction (GDC) custom transformation is used for a source image that cannot be described by any other provided transformation.

Each polygon in the input image transforms into a square after the transformation. In other words, any four nearby input points in any shapes are a square after the transformation, as shown in Figure 1. However, the shape and location of the polygon are changed after the transformation. Figure 1 Polygon transformation

To correct arbitrary distortions, you must provide the GDC tool with a special calibration file.

## Input point coordinates

The input points must be equidistant in the real world. Using a checkerboard image is useful, because the image gives you more freedom to select a wanted region of a fisheye frame.

The input points provide only a basic idea about where the output points should be. The libgdc library still needs to calculate intermediate points, depending on the transformation. Assume that you have 4x6 input points, which exist in the form of coordinates. The output image is 1200x1600 p ixels. This means that you need to use only 4 input points to generate 1200 points in the horizontal direction. The 1200 points in the horizontal direction are intermediate points, which are generated by libgdc. Similarly, you need to use only 6 points to generate 1600 points in the vertical direction.

To maximize the accuracy of the GDC tool, the ideal scenario is to have one to one mapping between the input points and the output points. For all output points for which there are no input points, the coordinates are interpolated by using the four nearest points.

Input points support an int type and a float type. The int type indicates that the input point is a real pixel point. The float type indicates that the input point is in a position between some pixels. For the input points with the float type:

• All the output pixels are interpolated.

• In most cases, the output pixel is not taken exactly from a fixed pixel.

## Create a configuration file

This section shows you how to create a configuration file for the following examples:

• Example 1: Distortion correction transformation.

• Example 2: Distortion correction transformation with a 90-degree rotation effect.

Figure 2 is given as a source image to show you how to create a configuration file. Figure 2 Source image

### Example 1: Distortion correction transformation

Follow these steps to cre ate a configuration file:

1. Determine the input points in Figure 2.

2. Record the coordinates of all the red points in Figure 2. Make sure that the input points are continuous.

If you want to implement the distortion correction transformation, all the red points in the orange line in Figure 3 are the first line coordinate data. The red point at the left-top corner of checkerboard is the starting point of the first line coordinate data. Record the coordinates of all the red points line by line as shown in Figure 4. Figure 3 Distortion correction transformation

3. Create a configuration file after getting all the input point coordinates. Consider Figure 4 for an example. Figure 4 Configuration file

Follow these rules whe n creating a configuration file.

• On line 1, the first number Y represents the number of points in the vertical direction. The second number X on the first row represents the number of points in the horizontal direction.

In Figure 4, the number of points in the vertical direction is 7 (Y=7), and the number of points in the horizontal direction is 28 (X=28).

These input points are equidistant, so the ratio between the number of points defines the aspect ratio of the output image.

• On Line 2, the two numbers determine the center point by the formula: (Y-1)/2 and (X-1)/2. In Figure 4, the numbers 3 and 13.5 determine the center point of the selected region.

• From Line 3 to Line 10, data is in the Y:X format, which represents the coordinates of the red points in the input image. For the coordinates, the custom configuration file supports both int and float types. There are total 7x28 points in Figure 3.

### Example 2: Distortion correction transformation with a 90-degree rotation effect

If you want to implement distortion correction transformation with a 90-degree rotation effect, you can follow similar steps in Example 1 to create a configuration file.

The only difference is that you must record the red points differently, because the first line coordinate data changes after the rotation. All the red points in the orange line become the first line coordinate data after rotation, as shown in Figure 5.

The red point at the left-bottom corner of the checkerboard is the starting point of the first line coordinate data. All the red points in the green line are the second line coordinate data. Record the coordinates of all the red points line by lines similarly as you do in Example 1. Figure 5 Distortion correction transformation with 90-degree rotation

## Calculate the resolution of the output image

The input points are equidistant in the real world. This means that the output image resolution depends on the number of points. You can calculate the resolution of the output i mage by the following formula:

(Size X)/(Size Y)=(Number_of_X_points - 1)/(Number_of_Y_points - 1)

For example, if the width is 1280, you can use the following formula to compute the height, which is 284:

1280/height = (28-1)/(7-1)

## Run test cases

This section shows you how to run the following test cases:

• Case 1: Custom distortion correction transformation.

• Case 2: Custom distortion correction transformation with a 90-degree rotation effect.

### Case 1: Custom distortion correction transformation

Follow these steps to apply a custom distortion correction transformation:

1. Sample all the red points in Figure 2.

2. Click the Config File button to load the configuration file, Custom_transform_28_7.txt.

3. Click Apply.

The following figure shows the output image: Figure 6 Custom distortion correction transformation

### Case 2: Custom distortion correction transformation with a 90-degree rotation effect

Follow these steps to apply a custo m distortion correction transformation with a 90-degree rotation effect:

1. Sample all the red points in Figure 2.

2. Click the Config File button to load the configuration file, Custom_transform_90_rotation.txt.

3. Click Apply.

The following figure shows the output image: Figure 7 Custom distortion correction transformation and 90 degree rotation

N/A

N/A

#### Related Information

• For details about how to use the GDC tool, see the GDC Tool User Interface manual in the product bundle.