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 | |
---|---|---|---|---|---|
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 | ||
inBorderColor | const Pixel& | Color used for locations outside the rectangle | |||
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 |
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.