elliptic_axiselliptic_axisEllipticAxisEllipticAxiselliptic_axis(算子)

名称

elliptic_axiselliptic_axisEllipticAxisEllipticAxiselliptic_axis — 计算等效椭圆的参数。

签名

elliptic_axis(Regions : : : Ra, Rb, Phi)

Herror elliptic_axis(const Hobject Regions, double* Ra, double* Rb, double* Phi)

Herror T_elliptic_axis(const Hobject Regions, Htuple* Ra, Htuple* Rb, Htuple* Phi)

void EllipticAxis(const HObject& Regions, HTuple* Ra, HTuple* Rb, HTuple* Phi)

HTuple HRegion::EllipticAxis(HTuple* Rb, HTuple* Phi) const

double HRegion::EllipticAxis(double* Rb, double* Phi) const

static void HOperatorSet.EllipticAxis(HObject regions, out HTuple ra, out HTuple rb, out HTuple phi)

HTuple HRegion.EllipticAxis(out HTuple rb, out HTuple phi)

double HRegion.EllipticAxis(out double rb, out double phi)

def elliptic_axis(regions: HObject) -> Tuple[Sequence[float], Sequence[float], Sequence[float]]

def elliptic_axis_s(regions: HObject) -> Tuple[float, float, float]

描述

算子 elliptic_axiselliptic_axisEllipticAxisEllipticAxisEllipticAxiselliptic_axis calculates the radii RaRaRaRarara and RbRbRbRbrbrb and the orientation PhiPhiPhiPhiphiphi of the ellipse having the same orientation and the same aspect ratio as the input region in RegionsRegionsRegionsRegionsregionsregions. Several input regions can be passed as tuples. RaRaRaRarara represents the main radius of the ellipse whereas the radius RbRbRbRbrbrb represents the secondary radius of the ellipse. The orientation of the main axis with regard to the x-axis is returned in PhiPhiPhiPhiphiphi which is represented in radians. The principle axis of the ellipse is equivalent to the principle axis of the inertia moment of the input region.

In the documentation of this chapter (Regions / Features), you can find an image illustrating regions which vary in their Phi, Ra and Rb.

Calculation:

If the moments , and are normalized and passed to the area (see moments_region_2ndmoments_region_2ndMomentsRegion2ndMomentsRegion2ndMomentsRegion2ndmoments_region_2nd), the radii RaRaRaRarara and RbRbRbRbrbrb are calculated as:

The orientation PhiPhiPhiPhiphiphi is defined by:

If more than one region is passed, the results are stored in tuples. The index of an resulting tuple element corresponds to the index of the respective input region.

If an empty region is passed, all parameters have the value 0.0 if no other behavior was set (see set_system('no_object_result',<Result>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)set_system("no_object_result",<Result>)).

注意

It should be noted that, like for all region-moments-based operators, the region's pixels are regarded as mathematical, infinitely small points that are represented by the center of the pixels. This means that RaRaRaRarara and RbRbRbRbrbrb can assume the value 0. In particular, for an empty region and a region containing a single point RaRaRaRarara = RbRbRbRbrbrb = 0 is returned. Furthermore, for regions whose points lie exactly on a straight line (e.g., one pixel high horizontal regions or one pixel wide vertical regions), RbRbRbRbrbrb = 0 is returned.

执行信息

参数

RegionsRegionsRegionsRegionsregionsregions (输入对象)  region(-array) objectHRegionHObjectHRegionHobject

输入区域。

RaRaRaRarara (输出控制)  real(-array) HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

Main radius (normalized to the area).

Assertion: Ra >= 0.0

RbRbRbRbrbrb (输出控制)  real(-array) HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

Secondary radius (normalized to the area).

Assertion: Rb >= 0.0 && Rb <= Ra

PhiPhiPhiPhiphiphi (输出控制)  angle.rad(-array) HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

Angle between main radius and x-axis in radians.

Assertion: - pi / 2 < Phi && Phi <= pi / 2

示例(HDevelop)

read_image(Image,'fabrik')
regiongrowing(Image,Seg,5,5,6,100)
elliptic_axis(Seg,Ra,Rb,Phi)
area_center(Seg,_,Row,Column)
gen_ellipse(Ellipses,Row,Column,Phi,Ra,Rb)
dev_set_draw('margin')
dev_display(Ellipses)

示例(C)

read_image(&Image,"fabrik");
regiongrowing(Image,&Seg,5,5,6.0,100);
T_elliptic_axis(Seg,&Ra,&Rb,&Phi);
T_area_center(Seg,NULL,&Row,&Column);
T_gen_ellipse(&Ellipses,Row,Column,Phi,Ra,Rb);

示例(HDevelop)

read_image(Image,'fabrik')
regiongrowing(Image,Seg,5,5,6,100)
elliptic_axis(Seg,Ra,Rb,Phi)
area_center(Seg,_,Row,Column)
gen_ellipse(Ellipses,Row,Column,Phi,Ra,Rb)
dev_set_draw('margin')
dev_display(Ellipses)

示例(HDevelop)

read_image(Image,'fabrik')
regiongrowing(Image,Seg,5,5,6,100)
elliptic_axis(Seg,Ra,Rb,Phi)
area_center(Seg,_,Row,Column)
gen_ellipse(Ellipses,Row,Column,Phi,Ra,Rb)
dev_set_draw('margin')
dev_display(Ellipses)

示例(HDevelop)

read_image(Image,'fabrik')
regiongrowing(Image,Seg,5,5,6,100)
elliptic_axis(Seg,Ra,Rb,Phi)
area_center(Seg,_,Row,Column)
gen_ellipse(Ellipses,Row,Column,Phi,Ra,Rb)
dev_set_draw('margin')
dev_display(Ellipses)

复杂度

If F is the area of a region the mean runtime complexity is O(sqrt(F)).

结果

算子 elliptic_axiselliptic_axisEllipticAxisEllipticAxisEllipticAxiselliptic_axis 在输入不为空时返回值 2 ( H_MSG_TRUE )。当输入为空(无可用输入区域)时,可设置行为通过算子 set_system('no_object_result',<Result>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)set_system("no_object_result",<Result>)。空区域(区域是空集)的情况下的可设置行为通过 set_system('empty_region_result',<Result>)set_system("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)set_system("empty_region_result",<Result>)。如有必要,则抛出异常。

可能的前趋

thresholdthresholdThresholdThresholdThresholdthreshold, regiongrowingregiongrowingRegiongrowingRegiongrowingRegiongrowingregiongrowing, connectionconnectionConnectionConnectionConnectionconnection

可能的后继

gen_ellipsegen_ellipseGenEllipseGenEllipseGenEllipsegen_ellipse

替代

smallest_rectangle2smallest_rectangle2SmallestRectangle2SmallestRectangle2SmallestRectangle2smallest_rectangle2, orientation_regionorientation_regionOrientationRegionOrientationRegionOrientationRegionorientation_region

另见

moments_region_2ndmoments_region_2ndMomentsRegion2ndMomentsRegion2ndMomentsRegion2ndmoments_region_2nd, select_shapeselect_shapeSelectShapeSelectShapeSelectShapeselect_shape, set_shapeset_shapeSetShapeSetShapeSetShapeset_shape

参考文献

R. Haralick, L. Shapiro “Computer and Robot Vision” Addison-Wesley, 1992, pp. 73-75

模块

基础