regionMoment

[ XITE Reference Manual | XITE home ]

Contents


Name

regionMoment, regionCMoment, regionPMoment - the moment of one or more regions

Syntax

 #include <xite/region.h>
 #include <xite/region.h>

 int regionMoment( IBAND band, region* reg,
    int p, int q, int loop, double* moment );

 int regionCMoment( IBAND band, region* reg,
    int p, int q, int loop, double* moment );

 int regionPMoment( IBAND band, region* reg,
    int p, int q, double xc, double yc,
    int loop, double* moment );

Description

If the band argument is nil, regionMoment calculates the moment of order p+q around origo of one or several regions.

 moment  =  SUM SUM (x**p * y**q)
          (x,y)in reg

regionCMoment calculates the central moment of order p+q of one or several regions.

 moment  =  SUM SUM ((x-xmean)**p * (y-ymean)**q)
          (x,y)in reg

regionPMoment calculates the moment of order p+q around a given point (xc, yc) of one or several regions.

 moment  =  SUM SUM ((x-xc)**p (y-yc)**q)
          (x,y)in reg

If "loop" is false, the moment of "reg" is measured. If true, the next pointer in reg is followed until nil, and the moment of the whole region set is calculated.

If the band argument specifies a band, then the pixel values are used to calculate the moments:

 moment  =  SUM SUM (x**p * y**q * band[x,y])
          (x,y)in reg

 moment  =  SUM SUM ((x-xmean)**p * (y-ymean)**q
                    * band[x,y])
          (x,y)in reg

 moment  =  SUM SUM ((x-xc)**p (y-yc)**q * band[x,y])
          (x,y)in reg

The result is returned through the moment parameter.

Return value

 0 => ok
 1 => bad pixel type in band, accepts only unsigned byte
 2 => "reg" points to nil. Area is set to 0.
 3 => p or q is negative.

See also

regionAnalyse(1), regionArea(3), regionConvexHull(3), regionCreate(3), regionDraw(3), regionFree(3), regionHisto(3), regionHistoUpdate(3), regionImoment(3), regionInsertYline(3), regionDeleteYline(3) regionEndInsert(3), regionXmean(3), regionYmean(3), regionMean(3), regionXmin(3), regionXmax(3), regionYmin(3), regionYmax(3), regionMinMax(3), regionPerform(3), regionPerimeter(3), regionIsPoint(3), regionPoint(3), regionSearch(3), regionSort(3), regionCopy(3), regionUnion(3), regionOverlap(3), regionNeighbor(3), regionVolume(3), regionYline(3)

Author

Tor L|nnestad, BLAB, ifi, UiO

Example

 #include <xite/biff.h>
 #include <xite/region.h>
 region* reg;
 double moment;
 ...
 regionMoment(0, reg, 1, 2, FALSE, &moment);

Id

$Id: regionMoment.c,v 1.20 1997/01/29 10:45:13 svein Exp $