コード例 #1
0
        public static double getCovarianceXY(int p, int q, double[,] image)
        {
            double mc00 = Moments.getCentralMoment(0, 0, image);
            double mc11 = Moments.getCentralMoment(1, 1, image);

            return(mc11 / mc00);
        }
コード例 #2
0
        public static double getVarianceY(int p, int q, double[,] image)
        {
            double mc00 = Moments.getCentralMoment(0, 0, image);
            double mc02 = Moments.getCentralMoment(0, 2, image);

            return(mc02 / mc00);
        }
コード例 #3
0
        public static double getNormalizedCentralMoment(int p, int q, double[,] image)
        {
            double gama    = ((p + q) / 2) + 1;
            double mpq     = Moments.getCentralMoment(p, q, image);
            double m00gama = Math.Pow(Moments.getCentralMoment(0, 0, image), gama);

            return(mpq / m00gama);
        }
コード例 #4
0
        public static double getHuMoment(double[,] image, int n)
        {
            double result = 0.0;

            double
                n20 = Moments.getNormalizedCentralMoment(2, 0, image),
                n02 = Moments.getNormalizedCentralMoment(0, 2, image),
                n30 = Moments.getNormalizedCentralMoment(3, 0, image),
                n12 = Moments.getNormalizedCentralMoment(1, 2, image),
                n21 = Moments.getNormalizedCentralMoment(2, 1, image),
                n03 = Moments.getNormalizedCentralMoment(0, 3, image),
                n11 = Moments.getNormalizedCentralMoment(1, 1, image);

            switch (n)
            {
            case 1:
                result = n20 + n02;
                break;

            case 2:
                result = Math.Pow((n20 - 02), 2) + Math.Pow(2 * n11, 2);
                break;

            case 3:
                result = Math.Pow(n30 - (3 * (n12)), 2)
                         + Math.Pow((3 * n21 - n03), 2);
                break;

            case 4:
                result = Math.Pow((n30 + n12), 2) + Math.Pow((n12 + n03), 2);
                break;

            case 5:
                result = (n30 - 3 * n12) * (n30 + n12)
                         * (Math.Pow((n30 + n12), 2) - 3 * Math.Pow((n21 + n03), 2))
                         + (3 * n21 - n03) * (n21 + n03)
                         * (3 * Math.Pow((n30 + n12), 2) - Math.Pow((n21 + n03), 2));
                break;

            case 6:
                result = (n20 - n02)
                         * (Math.Pow((n30 + n12), 2) - Math.Pow((n21 + n03), 2))
                         + 4 * n11 * (n30 + n12) * (n21 + n03);
                break;

            case 7:
                result = (3 * n21 - n03) * (n30 + n12)
                         * (Math.Pow((n30 + n12), 2) - 3 * Math.Pow((n21 + n03), 2))
                         + (n30 - 3 * n12) * (n21 + n03)
                         * (3 * Math.Pow((n30 + n12), 2) - Math.Pow((n21 + n03), 2));
                break;

            default:
                result = 0;
                break;
            }
            return(result);
        }
コード例 #5
0
        public static double getCentralMoment(int p, int q, double[,] image)
        {
            double mc  = 0;
            double m00 = Moments.getBasicMoment(0, 0, image);
            double m10 = Moments.getBasicMoment(1, 0, image);
            double m01 = Moments.getBasicMoment(0, 1, image);
            double x0  = m10 / m00;
            double y0  = m01 / m00;

            for (int i = 0, k = image.GetLength(0); i < k; i++)
            {
                for (int j = 0, l = image.GetLength(1); j < l; j++)
                {
                    mc += Math.Pow((i - x0), p) * Math.Pow((j - y0), q) * image[i, j];
                }
            }
            return(mc);
        }