Back to Adaptive Vision Library website

You are here: Start » Function Reference » Region Relations » InscribeRegionInRegion

InscribeRegionInRegion


Header:AVL.h
Namespace:avl

Shifts source region so that it is contained in target region.

Syntax

C++
C#
 
void avl::InscribeRegionInRegion
(
	const avl::Region& inTargetRegion,
	const avl::Region& inSourceRegion,
	avl::ShiftType::Type inPossibleShift,
	avl::FitType::Type inFitType,
	atl::Conditional<int>& outShiftX,
	atl::Conditional<int>& outShiftY,
	atl::Conditional<avl::Region>& outShiftedRegion
)

Parameters

Name Type Default Description
inTargetRegion const Region& Region to contain source region
inSourceRegion const Region& Region to be shifted
inPossibleShift ShiftType::Type Possible directions of shift
inFitType FitType::Type Determines if the common border length should be maximized
outShiftX Conditional<int>& X coordinate of the shift
outShiftY Conditional<int>& Y coordinate of the shift
outShiftedRegion Conditional<Region>& Shifted source region

Description

The filter shifts inSourceRegion so that it is entirely contained in inTargetRegion. When inFitType is FirstFit, the function returns first shift. With inFitType set to BestFit, the function chooses from all possible shifts one that maximizes length of common border of target region and shifted source region. Parameter inPossibleShift defines directions in which source region should be shifted. Possible values are Any, Vertical, Horizontal.

All return values are conditional. In case appropriate shift exists, outShiftX and outShiftY define its coordinates. outShiftedRegion is inSourceRegion translated by vector (outShiftX,outShiftY) and with dimensions of inTargetRegion.

Examples

InscribeRegionInRegion performed on pair of sample regions, shown on the left. Middle image shows inscribed region with inFitType set to FirstFit. Right one corresponds to inFitType equal BestFit.

Remarks

Setting parameter inFitType to BestFit results in much higher computational cost.

Errors

List of possible exceptions:

Error type Description
DomainError Source region cannot be empty in InscribeRegionInRegion.

See Also

  • TranslateRegion – Translates a region by a given number of pixels along each axis.