Back to FabImage Library website
You are here: Start » Function Reference » Image » Image Spatial Transforms » CropImageToRectangle
Header: | FIL.h |
---|---|
Namespace: | fil |
Module: | FoundationLite |
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++
C#
void fil::CropImageToRectangle ( const fil::Image& inImage, const fil::Rectangle2D& inRectangle, ftl::Optional<const fil::CoordinateSystem2D&> inRectangleAlignment, fil::CropScaleMode::Type inScaleMode, fil::InterpolationMethod::Type inInterpolationMethod, float inMargin, const fil::Pixel& inBorderColor, fil::Image& outImage, ftl::Optional<fil::Rectangle2D&> outAlignedRectangle = ftl::NIL, ftl::Optional<fil::CoordinateSystem2D&> outOutputAlignment = ftl::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 ftl::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.