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
Input value inImage Image Input image
Input value inRectangle Rectangle2D Rectangle defining a rotated subimage
Input value inRectangleAlignment CoordinateSystem2D | None None Adjusts the rectangle to the position of the inspected object
Input value inScaleMode CropScaleMode CropScaleMode.InputScale InputScale keeps the input scale unchanged, AlignedScale rescales according to the input alignment scale
Input value inInterpolationMethod InterpolationMethod InterpolationMethod.Bilinear
Input value inMargin float 0.0 - Width of an additional margin for the output image
Input value inBorderColor Pixel Pixel(0, 0, 0, 0) Color used for locations outside the rectangle
Output value outImage Image Output image
Output value outAlignedRectangle Rectangle2D | None None Input rectangle after transformation (in the image coordinates)
Output value outOutputAlignment CoordinateSystem2D | None None Alignment of the output image