CropImageToRectangle
Creates an image from a rectangular fragment of another image (with black margins if requested).
Applications:Usually used for creating images of individual objects, e.g. after Template Matching.
Syntax
C++
Python
def CropImageToRectangle( inImage: Image, inRectangle: Rectangle2D, inMargin: float, outImage: Image, /, *, inRectangleAlignment: CoordinateSystem2D | None = None, inScaleMode: CropScaleMode = CropScaleMode.InputScale, inInterpolationMethod: InterpolationMethod = InterpolationMethod.Bilinear, inBorderColor: Pixel = Pixel(0, 0, 0, 0), outAlignedRectangle: Rectangle2D | None = None, outOutputAlignment: CoordinateSystem2D | None = None ) -> None
Parameters
| Name | Type | Range | Default | Description | |
|---|---|---|---|---|---|
![]() |
inImage | Image | Input image | ||
![]() |
inRectangle | Rectangle2D | Rectangle defining a rotated subimage | ||
![]() |
inRectangleAlignment | CoordinateSystem2D | None | None | Adjusts the rectangle to the position of the inspected object | |
![]() |
inScaleMode | CropScaleMode | CropScaleMode.InputScale | InputScale keeps the input scale unchanged, AlignedScale rescales according to the input alignment scale | |
![]() |
inInterpolationMethod | InterpolationMethod | InterpolationMethod.Bilinear | ||
![]() |
inMargin | float | 0.0 - ![]() |
Width of an additional margin for the output image | |
![]() |
inBorderColor | Pixel | Pixel(0, 0, 0, 0) | Color used for locations outside the rectangle | |
![]() |
outImage | Image | Output image | ||
![]() |
outAlignedRectangle | Rectangle2D | None | None | Input rectangle after transformation (in the image coordinates) | |
![]() |
outOutputAlignment | CoordinateSystem2D | None | None | Alignment of the output image |



