Back to Adaptive Vision Library website

You are here: Start » Function Reference » Image Spatial Transforms » CropImageToRectangle


Creates an image from a rectangular fragment of another image (with black margins if requested).



void avl::CropImageToRectangle
	const avl::Image& inImage,
	const avl::Rectangle2D& inRectangle,
	atl::Optional<const avl::CoordinateSystem2D&> inRectangleAlignment,
	avl::CropScaleMode::Type inScaleMode,
	avl::InterpolationMethod::Type inInterpolationMethod,
	float inMargin,
	avl::Image& outImage,
	atl::Optional<avl::Rectangle2D&> outAlignedRectangle = atl::NIL,
	atl::Optional<avl::CoordinateSystem2D&> outOutputAlignment = atl::NIL


Name Type Range Default Description
inImage const Image& Input image
inRectangle const Rectangle2D& Rectangle defining a rotated subimage
inRectangleAlignment Optional<const CoordinateSystem2D&> NIL Adjusts the rectangle to the position of the inspected object
inScaleMode CropScaleMode::Type InputScale InputScale keeps the input scale unchanged, AlignedScale rescales according to the input alignment scale
inInterpolationMethod InterpolationMethod::Type Bilinear
inMargin float 0.0 - Width of an additional margin for the output image
outImage Image& Output image
outAlignedRectangle Optional<Rectangle2D&> NIL Input rectangle after transformation (in the image coordinates)
outOutputAlignment Optional<CoordinateSystem2D&> NIL Alignment of the output image


  • It is usually recommended to use Local Coordinate Systems rather than image cropping.
  • To obtain output images with constant dimensions regardless of inRectangleAlignment set inScaleMode to AlignedScale. The output image size will be equal to inRectangle size optionally modified by inMargin.


CropImageToRectangle used to extract an image of an object.