Compute the mapping between the distorted image and the rectified image based upon the points of a regular grid.
gen_grid_rectification_map calculates the mapping between the grid points (Row,Col), which have been actually detected in the distorted image Image (typically using saddle_points_sub_pix), and the corresponding grid points of the ideal regular point grid. First, all paths that lead from their initial point via exactly four different connecting lines back to the initial point are assembled from the grid points (Row,Col) and the connecting lines ConnectingLines (detected by connect_grid_points). In case that the input of grid points (Row,Col) and of connecting lines ConnectingLines was meaningful, one such 'mesh' corresponds to exactly one grid cell in the rectification grid. Afterwards, the meshes are combined to the point grid. According to the value of Rotation, the point grid is rotated by 0, 90, 180 or 270 degrees. Note that the point grid does not necessarily have the correct orientation. When passing 'auto' in Rotation, the point grid is rotated such that the black circular mark in the rectification grid is positioned to the left of the white one (see also create_rectification_grid). Finally, the mapping Map between the distorted image and the rectified image is calculated by interpolation between the grid points. Each grid cell, for which the coordinates (Row,Col) of all four corner points are known, is projected onto a square of GridSpacing x GridSpacing pixels.
Map consists of one image containing five channels. In the first channel for each pixel in the resulting image, the linearized coordinates of the pixel in the input image that is in the upper left position relative to the transformed coordinates are stored. The four other channels contain the weights of the four neighboring pixels of the transformed coordinates, which are used for the bilinear interpolation, in the following order:
+---+---+ | 2 | 3 | +---+---+ | 4 | 5 | +---+---+The second channel, for example, contains the weights of the pixels that lie to the upper left relative to the transformed coordinates.
gen_grid_rectification_map additionally returns the calculated meshes as XLD contours in Meshes.
In contrary to gen_arbitrary_distortion_map, gen_grid_rectification_map and its predecessors are used when the coordinates (Row,Col) of the grid points in the distorted image are neither known nor can be derived from the image contents.
Each input XLD contour ConnectingLines must own the global attribute 'bright_dark', as it is described with connect_grid_points!
|
Image (input_object) |
singlechannelimage -> object : byte / uint2 |
| Input image. | |
|
ConnectingLines (input_object) |
xld-array -> object |
| Input contours. | |
|
Map (output_object) |
multichannel-image -> object : int4 / uint2 |
| Image containing the mapping data. | |
|
Meshes (output_object) |
xld-array -> object |
| Output contours. | |
|
GridSpacing (input_control) |
integer -> integer |
| Distance of the grid points in the rectified image. | |
| Restriction: GridSpacing > 0 | |
|
Rotation (input_control) |
string -> string / integer |
| Rotation to be applied to the point grid. | |
| Default value: ''auto'' | |
| List of values: ''auto'', 0, 90, 180, 270 | |
|
Row (input_control) |
point.y-array -> real |
| Row coordinates of the grid points. | |
|
Col (input_control) |
point.x-array -> real |
| Column coordinates of the grid points. | |
| Restriction: number(Col) == number(Row) | |
gen_grid_rectification_map returns 2 (H_MSG_TRUE) if all parameter values are correct. If necessary, an exception handling is raised.
gen_grid_rectification_map is processed completely exclusively without parallelization.
Calibration