Пример #1
0
        public static Bitmap IfftTransform(Complex[][] complex)
        {
            Complex[][] resultComplex = FourierUtil.CopyComplexArray(complex);
            FourierUtil.SwapQuadrants(resultComplex);
            float[,] afterInverseResult = FourierUtil.IfftDit2d(resultComplex);
            Bitmap resultBitmap = FourierUtil.TransformResultToBitmap(afterInverseResult);

            return(resultBitmap);
        }
Пример #2
0
        public static Bitmap GetSpectrumBitmap(Complex[][] complexImage, string spectrum)
        {
            float[,] pixelValues;
            int        size             = complexImage.Length;
            Bitmap     resultBitmap     = new Bitmap(size, size);
            LockBitmap resultBitmapLock = new LockBitmap(resultBitmap);

            resultBitmapLock.LockBits(ImageLockMode.WriteOnly);

            switch (spectrum)
            {
            case "none":
            {
                pixelValues = FourierUtil.IfftDit2d(complexImage);
                break;
            }

            case "magnitude":
            {
                pixelValues = FourierUtil.Magnitude(complexImage);
                break;
            }

            case "phase":
            {
                pixelValues = FourierUtil.Phase(complexImage);
                break;
            }

            default:
            {
                pixelValues = FourierUtil.IfftDit2d(complexImage);
                break;
            }
            }

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    if (pixelValues[i, j] < Colors.MIN_PIXEL_VALUE)
                    {
                        pixelValues[i, j] = Colors.MIN_PIXEL_VALUE;
                    }

                    if (!float.IsNaN(pixelValues[i, j]))
                    {
                        int pixelColor = (int)pixelValues[i, j];
                        resultBitmapLock.SetPixel(i, j, Color.FromArgb(pixelColor, pixelColor, pixelColor));
                    }
                }
            }

            resultBitmapLock.UnlockBits();
            return(resultBitmap);
        }
Пример #3
0
        public static Complex[][] FftTransform(Bitmap original)
        {
            LockBitmap originalBitmapLock = new LockBitmap(original);

            originalBitmapLock.LockBits(ImageLockMode.ReadOnly);

            Complex[][] pixelsData          = FourierUtil.BitmapToComplex(originalBitmapLock);
            Complex[][] afterForwardComplex = FourierUtil.FftDit2d(pixelsData);
            FourierUtil.SwapQuadrants(afterForwardComplex);

            originalBitmapLock.UnlockBits();
            return(afterForwardComplex);
        }