Skip to content

shape_transShapeTransShapeTransshape_transshape_trans🔗

Short description🔗

shape_transShapeTransShapeTransshape_transshape_trans — Transform the shape of a region.

Signature🔗

shape_trans( region Region, out region RegionTrans, string Type )void ShapeTrans( const HObject& Region, HObject* RegionTrans, const HTuple& Type )static void HOperatorSet.ShapeTrans( HObject region, out HObject regionTrans, HTuple type )def shape_trans( region: HObject, type: str ) -> HObject

Herror shape_trans( const Hobject Region, Hobject* RegionTrans, const char* Type )

Herror T_shape_trans( const Hobject Region, Hobject* RegionTrans, const Htuple Type )

HRegion HRegion::ShapeTrans( const HString& Type ) const

HRegion HRegion::ShapeTrans( const char* Type ) const

HRegion HRegion::ShapeTrans( const wchar_t* Type ) const (Windows only)

HRegion HRegion.ShapeTrans( string type )

Description🔗

shape_transShapeTrans transforms the shape of the input regions depending on the parameter Typetypetype:

  • 'convex'"convex" Convex hull.

  • 'ellipse'"ellipse" Ellipse with the same moments and area as the input region.

  • 'outer_circle'"outer_circle" Smallest enclosing circle.

  • 'inner_circle'"inner_circle" Largest circle fitting into the region.

  • 'rectangle1'"rectangle1" Smallest enclosing rectangle parallel to the coordinate axes.

  • 'rectangle2'"rectangle2" Smallest enclosing rectangle.

  • 'inner_rectangle1'"inner_rectangle1" Largest axis-parallel rectangle fitting into the region.

  • 'inner_center'"inner_center" The point on the skeleton of the input region having the smallest distance to the center of gravity of the input region.

Attention🔗

If Typetypetype = 'outer_circle'"outer_circle" is selected it might happen that the resulting circular region does not completely cover the input region. This is because internally the operators smallest_circleSmallestCircle and gen_circleGenCircle are used to compute the outer circle. As described in the documentation of smallest_circleSmallestCircle, the calculated radius can be too small by up to \(1/\sqrt{2}-0.5\) pixels. Additionally, the circle that is generated by gen_circleGenCircle is translated by up to 0.5 pixels in both directions, i.e., by up to \(1/\sqrt{2}\) pixels. Consequently, when adding up both effects, the original region might protrude beyond the returned circular region by at most 1 pixel.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on tuple level.

Parameters🔗

Regionregionregion (input_object) region(-array) → objectHObjectHRegionHObjectHobject

Regions to be transformed.

RegionTransregionTransregion_trans (output_object) region(-array) → objectHObjectHRegionHObjectHobject *

Transformed regions.

Typetypetype (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Type of transformation.

Default: 'convex'"convex"
List of values: 'convex', 'ellipse', 'inner_center', 'inner_circle', 'inner_rectangle1', 'outer_circle', 'rectangle1', 'rectangle2'"convex", "ellipse", "inner_center", "inner_circle", "inner_rectangle1", "outer_circle", "rectangle1", "rectangle2"

Complexity🔗

Let \(F\) be the area of the input region. Then the runtime complexity is \(O(F)\).

Result🔗

shape_transShapeTrans returns 2 (H_MSG_TRUE) if all parameters are correct. The behavior in case of empty input (no regions given) can be set via set_system('no_object_result',<Result>). If necessary, an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

connectionConnection, regiongrowingRegiongrowing

Possible successors

disp_regionDispRegion, regiongrowing_meanRegiongrowingMean, area_centerAreaCenter

See also

convexityConvexity, elliptic_axisEllipticAxis, area_centerAreaCenter, smallest_rectangle1SmallestRectangle1, smallest_rectangle2SmallestRectangle2, inner_rectangle1InnerRectangle1, set_shapeSetShape, select_shapeSelectShape, inner_circleInnerCircle

Module🔗

Foundation