Back to Aurora Vision Library Lite website

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

CropImageToRectangle


Header: AVL.h
Namespace: avl

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

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,
	const avl::Pixel& inBorderColor,
	avl::Image& outImage,
	atl::Optional<avl::Rectangle2D&> outAlignedRectangle = atl::NIL,
	atl::Optional<avl::CoordinateSystem2D&> outOutputAlignment = atl::NIL
)

Parameters

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

Optional Outputs

The computation of following outputs can be switched off by passing value atl::NIL to these parameters: outAlignedRectangle, outOutputAlignment.

Read more about Optional Outputs.

Hints

  • 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.

Examples

CropImageToRectangle used to extract an image of an object.