Object implementing the non linear polynomially approximated transform implemented in the CVB Foundation package. More...
Inherits object.
Public Member Functions | |
cvb.foundation.NonLinearTransformation | from_calibration_pattern (cvb.ImagePlane plane, int style, int contrast, int grid_spacing, int min_contrast, float max_ratio, int order, Optional[cvb.Area2D] aoi) |
Create a new transformation object by automatically extracting the pixel lists required for creating a NonLinearTransformation object. More... | |
cvb.foundation.NonLinearTransformation | from_position_lists (List[cvb.Point2D] original_pixels, List[cvb.Point2D] transformed_pixels, int order) |
Create a non linear transformation that - approximately - matches the set of original_pixels to the set of transformed_pixels. More... | |
cvb.Image | inverse_transform_image (self, cvb.Image image, cvb.Size2D target_size, cvb.Point2D target_offset) |
Back transform an image with this nonlinear transformation. More... | |
Union[cvb.Point2D, List[cvb.Point2D]] | inverse_transform_points (self, Union[cvb.Point2D, List[cvb.Point2D]] points) |
Back transform a point or a sequence of points with this nonlinear transformation. More... | |
None | save (self, str file_name) |
Write the transformation to a file. More... | |
cvb.Image | transform_image (self, cvb.Image image, cvb.Size2D target_size, cvb.Point2D target_offset) |
Transform an image with this nonlinear transformation. More... | |
Union[cvb.Point2D, List[cvb.Point2D]] | transform_points (self, Union[cvb.Point2D, List[cvb.Point2D]] points) |
Transform a point or a sequence of points with this nonlinear transformation. More... | |
cvb.Rect | transform_rect (self, cvb.Rect rect) |
Transform a rectangle with this nonlinear transformation. More... | |
Object implementing the non linear polynomially approximated transform implemented in the CVB Foundation package.
Load a saved transformation from a file.
file_name : str Name of the file to load.
cvb.foundation.NonLinearTransformation from_calibration_pattern | ( | cvb.ImagePlane | plane, |
int | style, | ||
int | contrast, | ||
int | grid_spacing, | ||
int | min_contrast, | ||
float | max_ratio, | ||
int | order, | ||
Optional[cvb.Area2D] | aoi | ||
) |
Create a new transformation object by automatically extracting the pixel lists required for creating a NonLinearTransformation object.
The image plane given to this method needs to contain a calibration pattern as generated by the method cvb.foundation.create_calibration_pattern(): A regularly spaced matrix of dots, the distance between the dots in x- and y-direction should be 2.5 times the diameter of the dots, if an asymmetric pattern was used, the bigger dots should have 2.5 times the area of the smaller dots (meaning that their radius is sqrt(2.5) times the radius of the small dots). Note that, although the area of interest is given as a cvb.Area2D here (and in the processing of the cvb.Area2D the image's coordinate system will be respected), the actual output of this method uses CoordinateSystemType.PixelCoordinates! This seemingly inconsistent mix in this case is in fact useful, because a cvb.Area2D will better capture the actual location of a calibration pattern, especially if the image has been rotated, than a cvb.Rect style area of interest. But the calibration functions working on the output of cvb.foundation.extract_calibration_lists() usually assume that the pixel lists are given in pixel coordinates. To avoid misunderstandings and complications in the interpretation of the image content, it is recommended to use a default coordinate system on the input image.The minimum contrast (min_contrast) value to be set depends on the quality of the image taken from the pattern, but in a typical situation this contrast should not drop below 64 gray values, otherwise it might become difficult to extract the calibration points. The maximum ration (max_ratio) value will be used to identify outliers when looking for calibration dots. It should be set high enough to allow for the area variations to be expected due to perspective distortions and small enough to eliminate the candidates that are either too big or too small to be valid calibration pattern dots. Typically, values of about 3.0 to 5.0 are big enough - even if there is notable perspective distortion visible in the images. If an asymmetric calibration pattern has been selected, the ratio used for calculation will be adapted accordingly.
plane : cvb.ImagePlane Image plane to work on.
style : int Calibration pattern style visible in the image (see cvb.foundation.CalibrationPatternStyle).
contrast : int Selects whether the image shows cvb.foundation.CalibrationPatternContrast.BlackOnWhite or cvb.foundation.CalibrationPatternContrast.WhiteOnBlack dots.
grid_spacing : int Spacing of the calibration dot grid in the target image. Defines the distance of the points that will end up in the transformed pixels.
min_contrast : int Minimum gray value contrast between the object and the background of the calibration target pattern.
max_ratio : float Maximum ratio between the biggest and the smallest calibration dot.
order : int Polynomial order of the transformation to be generated.
aoi : Optional[cvb.Area2D] Area of interest in which to look for the calibration pattern's dots (default entire image).
cvb.foundation.NonLinearTransformation The computed transformation.
cvb.foundation.NonLinearTransformation from_position_lists | ( | List[cvb.Point2D] | original_pixels, |
List[cvb.Point2D] | transformed_pixels, | ||
int | order | ||
) |
Create a non linear transformation that - approximately - matches the set of original_pixels to the set of transformed_pixels.
original_pixels : List[cvb.Point2D] Originial pixel locations. The pixels as measured from an image.
transformed_pixels : List[cvb.Point2D] Transformed pixels. The locations the corresponding pixels from originalPixels should ideally have.
order : int Polynomial order of the transformation to generate.
cvb.foundation.NonLinearTransformation The computed transformation.
cvb.Image inverse_transform_image | ( | self, | |
cvb.Image | image, | ||
cvb.Size2D | target_size, | ||
cvb.Point2D | target_offset | ||
) |
Back transform an image with this nonlinear transformation.
image : cvb.Image Image to transform.
target_size : cvb.Size2D Target size of the transformed image.
target_offset : cvb.Point2D Origin offset of the transformed image.
cvb.Image The transformed image.
Union[cvb.Point2D, List[cvb.Point2D]] inverse_transform_points | ( | self, | |
Union[cvb.Point2D, List[cvb.Point2D]] | points | ||
) |
Back transform a point or a sequence of points with this nonlinear transformation.
points : Union[cvb.Point2D, List[cvb.Point2D]] Point(s) to transform.
Union[cvb.Point2D, List[cvb.Point2D]] The transformed point(s).
None save | ( | self, | |
str | file_name | ||
) |
Write the transformation to a file.
file_name : str Path to save to.
cvb.Image transform_image | ( | self, | |
cvb.Image | image, | ||
cvb.Size2D | target_size, | ||
cvb.Point2D | target_offset | ||
) |
Transform an image with this nonlinear transformation.
image : cvb.Image Image to transform.
target_size : cvb.Size2D Target size of the transformed image.
target_offset : cvb.Point2D Origin offset of the transformed image.
cvb.Image The transformed image.
Union[cvb.Point2D, List[cvb.Point2D]] transform_points | ( | self, | |
Union[cvb.Point2D, List[cvb.Point2D]] | points | ||
) |
Transform a point or a sequence of points with this nonlinear transformation.
points : Union[cvb.Point2D, List[cvb.Point2D]] Point(s) to transform.
Union[cvb.Point2D, List[cvb.Point2D]] The transformed point(s).
Transform a rectangle with this nonlinear transformation.
The transformed rect is an estimate of the target dimensions needed for a transformed image. Due to the non linearity of the transformation it may not be correct. Consider it a best guess.
rect : cvb.Rect Rectangle to transform.
cvb.Rect The transformed rectangle.