gen_grid_rectification_map — 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,Column), 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,Column) and the connecting lines ConnectingLines (detected by connect_grid_points). In case that the input of grid points (Row,Column) 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,Column) of all four corner points are known, is projected onto a square of GridSpacing x GridSpacing pixels.
MapType is used to specify the type of the output Map. If 'bilinear' interpolation is chosen, 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 is stored that is in the upper left position relative to the transformed coordinates. 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:
The second channel, for example, contains the weights of the pixels that lie to the upper left relative to the transformed coordinates. If 'coord_map_sub_pix' is chosen, Map consists of one vector field image, in which for each pixel of the resulting image the subpixel precise coordinates in the input image are stored.
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,Column) of the grid points in the distorted image are neither known nor can be derived from the image contents.
If you want to re-use the created map in another program, you can save it as a multi-channel image with the operator write_image, using the format 'tiff'.
Each input XLD contour ConnectingLines must own the global attribute 'bright_dark', as it is described with connect_grid_points!
Image containing the mapping data.
Distance of the grid points in the rectified image.
Restriction: GridSpacing > 0
Rotation to be applied to the point grid.
Default value: 'auto'
List of values: 0, 90, 180, 270, 'auto'
Row coordinates of the grid points.
Column coordinates of the grid points.
Restriction: number(Column) == number(Row)
Type of mapping.
Default value: 'bilinear'
List of values: 'bilinear', 'coord_map_sub_pix'
gen_grid_rectification_map returns 2 (H_MSG_TRUE) if all parameter values are correct. If necessary, an exception is raised.