Accord.Imaging.Moments.CentralMoments.Compute C# (CSharp) Méthode

Compute() public méthode

Computes the center moments from the specified raw moments.
public Compute ( RawMoments moments ) : void
moments RawMoments The raw moments to use as base of calculations.
Résultat void
        public void Compute(RawMoments moments)
        {
            float x = moments.CenterX;
            float y = moments.CenterY;

            Mu00 = moments.M00;

            Mu01 = Mu10 = 0;
            Mu11 = moments.M11 - moments.M01 * x;

            Mu20 = moments.M20 - moments.M10 * x;
            Mu02 = moments.M02 - moments.M01 * y;

            Mu21 = moments.M21 - 2 * x * moments.M11 - y * moments.M20 + 2 * x * x * moments.M01;
            Mu12 = moments.M12 - 2 * y * moments.M11 - x * moments.M02 + 2 * y * y * moments.M10;

            Mu30 = moments.M30 - 3 * x * moments.M20 + 2 * x * x * moments.M10;
            Mu03 = moments.M03 - 3 * y * moments.M02 + 2 * y * y * moments.M01;

            invM00 = moments.InvM00;
        }

Same methods

CentralMoments::Compute ( UnmanagedImage image, Rectangle area ) : void
CentralMoments::Compute ( float image, Rectangle area ) : void

Usage Example

Exemple #1
0
        /// <summary>
        /// Process a new video frame.
        /// </summary>
        public void ProcessFrame(UnmanagedImage frame)
        {
            filterImage = filter.Apply(frame);

            Blob blob = extractBlob();

            if (blob == null)
            {
                trackingObject.Reset();
                return;
            }


            trackingObject.Rectangle = blob.Rectangle;
            trackingObject.Center = (IntPoint)blob.CenterOfGravity;

            if (rotation)
            {
                // Locate moments
                CentralMoments moments = new CentralMoments();
                moments.Compute(filterImage, blob.Rectangle);
                trackingObject.Angle = moments.GetOrientation();
            }


            if (extract)
            {
                blobCounter.ExtractBlobsImage(filterImage, blob, false);
                trackingObject.Image = blob.Image;
            }
        }