Ejemplo n.º 1
0
        private static ComplexF[,] prepareImage(Gray <float>[,] image, int biggestKernelWidth, int biggestKernelHeight,
                                                ConvolutionBorder options,
                                                out int fillX, out int fillY)
        {
            int FFTNumOfCols = (int)System.Math.Pow(2.0, System.Math.Ceiling(System.Math.Log(biggestKernelWidth + image.Width(), 2.0)));
            int FFTNumOfRows = (int)System.Math.Pow(2.0, System.Math.Ceiling(System.Math.Log(biggestKernelHeight + image.Height(), 2.0)));

            fillX = System.Math.Min(image.Width(), biggestKernelWidth / 2);
            fillY = System.Math.Min(image.Height(), biggestKernelHeight / 2);

            var paddedImage = new Gray <float> [FFTNumOfRows, FFTNumOfCols];

            //center
            image.CopyTo(paddedImage, new Point(fillX, fillY));

            if (options == ConvolutionBorder.BorderMirror)
            {
                mirrorBorders(image, paddedImage, fillX, fillY);
            }

            var paddedImageCmplx = paddedImage.ToComplex();

            paddedImageCmplx.FFT(FourierTransform.Direction.Forward, true);
            return(paddedImageCmplx);
        }