HALCON Reference Manual 10.0.2
Table of Contents / Regions / Features ClassesClassesClasses | | | Operators

elliptic_axiselliptic_axiselliptic_axisEllipticAxisEllipticAxis (Operator)

Name

elliptic_axiselliptic_axiselliptic_axisEllipticAxisEllipticAxis — Parameters of the equivalent ellipse.

Signature

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)

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

Herror elliptic_axis(Hobject Regions, HTuple* Ra, HTuple* Rb, HTuple* Phi)

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

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

void HOperatorSetX.EllipticAxis(
[in] IHUntypedObjectX* Regions, [out] VARIANT* Ra, [out] VARIANT* Rb, [out] VARIANT* Phi)

VARIANT HRegionX.EllipticAxis(
[out] VARIANT* Rb, [out] VARIANT* Phi)

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)

Description

The operator elliptic_axiselliptic_axiselliptic_axisEllipticAxisEllipticAxis calculates the radii and the orientation of the ellipse having the “same orientation” and the “same side relation” as the input region. Several input regions can be passed in RegionsRegionsRegionsRegionsregions as tuples. The length of the main radius RaRaRaRara and the secondary radius RbRbRbRbrb as well as the orientation of the main axis with regard to the horizontal (PhiPhiPhiPhiphi) are determined. The angle is indicated in arc measure.

Calculation:

        If the moments M20, M02 and M11 are
        normalized to the area (see moments_region_2ndmoments_region_2ndmoments_region_2ndMomentsRegion2ndMomentsRegion2nd),
        the radii RaRaRaRara and RbRbRbRbrb are calculated as:

        RaRaRaRara = sqrt(8.0*(M20+M02+sqrt((M20-M02)^2+4.0*M11^2)))/2.0
        RbRbRbRbrb = sqrt(8.0*(M20+M02-sqrt((M20-M02)^2+4.0*M11^2)))/2.0

        The orientation Phi is defined by:

        PhiPhiPhiPhiphi = -0.5 * atan2(2.0 * M11,M02 - M20)

If more than one region is passed the results are stored in tuples, the index of a value in the tuple corresponding to the index of a region in the input.

In case of empty region 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>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)).

Attention

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 RaRaRaRara and RbRbRbRbrb can assume the value 0. In particular, for an empty region and a region containing a single point RaRaRaRara = RbRbRbRbrb = 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), RbRbRbRbrb = 0 is returned.

Parallelization

Parameters

RegionsRegionsRegionsRegionsregions (input_object)  region(-array) objectHRegionHRegionHRegionXHobject

Region(s) to be examined.

RaRaRaRara (output_control)  real(-array) HTupleHTupleVARIANTHtuple (real) (double) (double) (double) (double)

Main radius (normalized to the area).

Assertion: Ra >= 0.0

RbRbRbRbrb (output_control)  real(-array) HTupleHTupleVARIANTHtuple (real) (double) (double) (double) (double)

Secondary radius (normalized to the area).

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

PhiPhiPhiPhiphi (output_control)  real(-array) HTupleHTupleVARIANTHtuple (real) (double) (double) (double) (double)

Angle between main radius and x axis (arc measure).

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

Example (HDevelop)

read_image(Image,'fabrik')
open_window(0,0,-1,-1,'root','visible','',WindowHandle)
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)
set_draw(WindowHandle,'margin')
disp_region(Ellipses,WindowHandle)

Example (C)

read_image(&Image,"fabrik");
open_window(0,0,-1,-1,0,"visible","",&WindowHandle);
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);
set_draw(WindowHandle,"margin");
disp_region(Ellipses,WindowHandle);

Example (HDevelop)

read_image(Image,'fabrik')
open_window(0,0,-1,-1,'root','visible','',WindowHandle)
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)
set_draw(WindowHandle,'margin')
disp_region(Ellipses,WindowHandle)

Example (HDevelop)

read_image(Image,'fabrik')
open_window(0,0,-1,-1,'root','visible','',WindowHandle)
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)
set_draw(WindowHandle,'margin')
disp_region(Ellipses,WindowHandle)

Example (HDevelop)

read_image(Image,'fabrik')
open_window(0,0,-1,-1,'root','visible','',WindowHandle)
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)
set_draw(WindowHandle,'margin')
disp_region(Ellipses,WindowHandle)

Complexity

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

Result

The operator elliptic_axiselliptic_axiselliptic_axisEllipticAxisEllipticAxis returns the value 2 (H_MSG_TRUE) if the input is not empty. The behavior in case of empty input (no input regions available) is set via the operator set_system('no_object_result',<Result>)set_system("no_object_result",<Result>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>). The behavior in case of empty region (the region is the empty set) is set via set_system('empty_region_result',<Result>)set_system("empty_region_result",<Result>)set_system("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>). If necessary an exception is raised.

Possible Predecessors

thresholdthresholdthresholdThresholdThreshold, regiongrowingregiongrowingregiongrowingRegiongrowingRegiongrowing, connectionconnectionconnectionConnectionConnection

Possible Successors

gen_ellipsegen_ellipsegen_ellipseGenEllipseGenEllipse

Alternatives

smallest_rectangle2smallest_rectangle2smallest_rectangle2SmallestRectangle2SmallestRectangle2, orientation_regionorientation_regionorientation_regionOrientationRegionOrientationRegion

See also

moments_region_2ndmoments_region_2ndmoments_region_2ndMomentsRegion2ndMomentsRegion2nd, select_shapeselect_shapeselect_shapeSelectShapeSelectShape, set_shapeset_shapeset_shapeSetShapeSetShape

References

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

Module

Foundation


Table of Contents / Regions / Features ClassesClassesClasses | | | Operators
HALCON Reference Manual 10.0.2 Copyright © 1996-2011 MVTec Software GmbH