public static Complex[,] GetFilter(double[,] arr)
        {
            int xLength     = arr.GetLength(0) - 2 * arr.GetLength(0) / 2 == 0 ? arr.GetLength(0) + 1 : arr.GetLength(0);
            int yLength     = arr.GetLength(1) - 2 * arr.GetLength(1) / 2 == 0 ? arr.GetLength(1) + 1 : arr.GetLength(1);
            int upperBoundX = (int)(xLength / 2);
            int lowerBoundX = -1 * upperBoundX;
            int upperBoundY = (int)(yLength / 2);
            int lowerBoundY = -1 * upperBoundY;

            Complex[,] filter = new Complex[xLength, yLength];
            double x_, y_ = 0;

            for (int x = lowerBoundX; x < upperBoundX; x++)
            {
                for (int y = lowerBoundY; y < upperBoundY; y++)
                {
                    if (y < 0)
                    {
                        filter[upperBoundX + x, upperBoundY + y] = 0;
                        continue;
                    }

                    x_ = XY_WithLine.GetX_WithLine(upperBoundX + x, upperBoundY + y);
                    y_ = XY_WithLine.GetY_WithLine(upperBoundX + x, upperBoundY + y);
                    filter[upperBoundX + x, upperBoundY + y] =
                        (2 * x_ * y_ + Complex.ImaginaryOne * (x_ * x_ - y_ * y_)) * Gaussian.CalculateGaussian(x_, y_);
                }
            }

            return(filter);
        }
        internal static bool CalculateFunction(int u, int v, double[,] orientationField)
        {
            int    upperBound = (int)(Constants.W / 2);
            int    lowerBound = -1 * upperBound;
            int    maxValueX = orientationField.GetLength(0);
            int    maxValueY = orientationField.GetLength(1);
            double gaussian, xWithLine, yWithLine, arg, sin, cos = 0;
            double sum_X = 0;
            double sum_Y = 0;

            for (int x = lowerBound; x < upperBound; x++)
            {
                for (int y = lowerBound; y < upperBound; y++)
                {
                    if (u + y < 0 || v + x < 0 || u + y >= maxValueX || v + x >= maxValueY)
                    {
                        continue;
                    }

                    gaussian  = Gaussian.CalculateGaussian(x, y);
                    xWithLine = XY_WithLine.GetX_WithLine(x, y);
                    yWithLine = XY_WithLine.GetY_WithLine(x, y);
                    arg       = 2 * orientationField[u + y, v + x];
                    sin       = Math.Sin(arg);
                    cos       = Math.Cos(arg);

                    sum_X += gaussian * (xWithLine * cos - yWithLine * sin);
                    sum_Y += gaussian * (yWithLine * cos + xWithLine * sin);
                }

                result_X += sum_X;
                result_Y += sum_Y;
                sum_X     = 0;
                sum_Y     = 0;
            }

            return(true);
        }