The moments() function allows for finding different properties of image regions.
More...
The moments() function allows for finding different properties of image regions.
Currently, ArrayFire calculates all first order moments. The moments are defined within the af_moment_type enum.
As the enum details, each moment can be returned individually or all first-order moments can be calculated at once. This can be done as follows:
Here is an example of how the shorthand versions might be used to find the area(or gray level sum) and center of mass of an image:
double m00, m01, m10;
double area = m00;
double x_center = m10 / m00;
double y_center = m01 / m00;
§ af_moments()
C Interface for finding image moments.
- Parameters
-
[out] | out | is an array containing the calculated moments |
[in] | in | is an array of image(s) |
[in] | moment | is moment(s) to calculate |
- Returns
- ref AF_SUCCESS if the moment calculation is successful, otherwise an appropriate error code is returned.
§ af_moments_all()
C Interface for calculating image moment(s) of a single image.
- Parameters
-
[out] | out | is a pointer to a pre-allocated array where the calculated moment(s) will be placed. User is responsible for ensuring enough space to hold all requested moments |
[in] | in | is the input image |
[in] | moment | is moment(s) to calculate |
- Returns
- ref AF_SUCCESS if the moment calculation is successful, otherwise an appropriate error code is returned.
§ moments() [1/2]
C++ Interface for calculating an image moment.
- Parameters
-
[out] | out | is a pointer to a pre-allocated array where the calculated moment(s) will be placed. User is responsible for ensuring enough space to hold all requested moments |
[in] | in | is the input image |
[in] | moment | is moment(s) to calculate |
§ moments() [2/2]
C++ Interface for calculating image moments.
- Parameters
-
[in] | in | contains the input image(s) |
[in] | moment | is moment(s) to calculate |
- Returns
- array containing the requested moment of each image