Beispiel #1
0
        public static Complex2D idft_2D(Complex2D src)
        {
            int width  = src.Width;
            int height = src.Height;

            return(fft_2D_core(src, ref width, ref height, -1));
        }
Beispiel #2
0
        // 2维快速傅里叶变换
        // 作者:死猫
        // int width, int height:欲变换数据的长度和宽度,函数调用后此值更改为实际变换长度
        // int flag:区分fft或dtft,为1为fft,为-1为idft
        private static Complex2D fft_2D_core(Complex2D src, ref int width, ref int height, int flag)
        {
            //补零后长度
            int width_Log2N  = ReLog2N(width);
            int height_Log2N = ReLog2N(height);
            int Relog2N      = Math.Max(width_Log2N, height_Log2N);
            int ReWidth      = 0x01 << Relog2N;
            int ReHeight     = 0x01 << Relog2N;

            //重新复制数据,清零
            Complex2D ReList2D = new Complex2D(ReWidth, ReHeight);

            ReList2D.Clear();
            int width_temp  = Math.Min(src.Width, width);
            int height_temp = Math.Min(src.Height, height);

            for (int i = 0; i < height_temp; i++)
            {
                for (int j = 0; j < width_temp; j++)
                {
                    ReList2D[i, j] = new Complex(src[i, j].Re, src[i, j].Im);
                }
            }

            ComplexList Xn;
            ComplexList Xk;
            int         Lenght_temp;

            //第1遍fft
            for (int i = 0; i < ReHeight; i++)
            {
                Xn          = ReList2D.GetRow(i);
                Lenght_temp = Xn.Lenght;
                Xk          = fft_core(Xn, ref Lenght_temp, flag);
                ReList2D.SetRow(i, Xk);
            }

            //第2遍fft
            for (int i = 0; i < ReWidth; i++)
            {
                Xn          = ReList2D.GetColumn(i);
                Lenght_temp = Xn.Lenght;
                Xk          = fft_core(Xn, ref Lenght_temp, flag);
                ReList2D.SetColumn(i, Xk);
            }

            //赋值
            width  = ReWidth;
            height = ReHeight;

            //清理内存
            //Xn = null;
            //Xk = null;
            //GC.Collect();

            //返回
            return(ReList2D);
        }
Beispiel #3
0
        public Complex2D GetAmplitude()
        {
            Complex2D ret = new Complex2D(Width, Height);

            for (int i = 0; i < Height; i++)
            {
                for (int j = 0; j < Width; j++)
                {
                    ret[i, j] = new Complex(this[i, j].Modulus());
                }
            }
            return(ret);
        }
Beispiel #4
0
        public static Complex2D 延拓(Complex2D frqData, double 延拓高度)
        {
            int height = frqData.Height;
            int whith  = frqData.Width;
            var 延拓结果   = new Complex2D(height, whith);
            var coex   = Coeff(whith, xtick);
            var coey   = Coeff(height, ytick);

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < whith; j++)
                {
                    var a = Math.Sqrt(coey[i] * coey[i] + coex[j] * coex[j]) * 延拓高度;
                    延拓结果[i, j] = frqData[i, j] * Math.Exp(a);
                }
            }
            return(延拓结果);
        }
Beispiel #5
0
        public static Complex2D Zdrf(Complex2D frqData)
        {
            int height   = frqData.Height;
            int whith    = frqData.Width;
            var zdrfData = new Complex2D(height, whith);
            var coex     = Coeff(whith, xtick);
            var coey     = Coeff(height, ytick);

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < whith; j++)
                {
                    var a = Math.Sqrt(coey[i] * coey[i] + coex[j] * coex[j]);
                    zdrfData[i, j] = a * frqData[i, j];
                }
            }
            return(zdrfData);
        }
Beispiel #6
0
        public static Complex2D Ydrf(Complex2D frqData)
        {
            int height   = frqData.Height;
            int whith    = frqData.Width;
            var ydrfData = new Complex2D(height, whith);
            //var coex = Coeff(whith, xtick);
            var coey = Coeff(height, ytick);
            var im   = new Complex(0, 1);

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < whith; j++)
                {
                    //var a = 2.0 * Math.PI * Math.Sqrt(coey[i] * coey[i] + coex[j] * coex[j]);
                    ydrfData[i, j] = coey[i] * frqData[i, j] * im;
                }
            }
            return(ydrfData);
        }
Beispiel #7
0
        private void OpenFile(object parameter)
        {
            var ofd = new OpenFileDialog
            {
                Filter = "Grid|*.grd"
            };

            if (ofd.ShowDialog() == true)
            {
                int    rows, cols;
                double xtick, ytick, zmin, zmax;
                var    para = Convert.ToString(parameter);
                if (para == "Anomaly")
                {
                    anomalyData = OpenFile(ofd.OpenFile(), out rows, out cols, out xtick, out ytick, out zmin, out zmax);

                    AnomalyMin = zmin;
                    AnomalyMax = zmax;
                    AnomalyMap = GetMap(anomalyData, zmin, zmax);

                    EdgeDetection.Initialize(cols, rows, xtick, ytick, anomalyData);

                    frqData  = null;
                    xdrData  = null;
                    ydrData  = null;
                    zdrData  = null;
                    xdrfData = null;
                    ydrfData = null;
                    zdrfData = null;
                    vxxData  = null;
                    vyyData  = null;
                    vxyData  = null;
                }
                else if (para == "Local")
                {
                    secondData = OpenFile(ofd.OpenFile(), out rows, out cols, out xtick, out ytick, out zmin, out zmax);

                    SecondMin = zmin;
                    SecondMax = zmax;
                    SedondMap = GetMap(secondData, zmin, zmax);
                }
            }
        }
Beispiel #8
0
        public static Complex2D Vxy(Complex2D frqData)
        {
            int height  = frqData.Height;
            int whith   = frqData.Width;
            var VxyData = new Complex2D(height, whith);
            var coex    = Coeff(whith, xtick);
            var coey    = Coeff(height, ytick);

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < whith; j++)
                {
                    VxyData[i, j] = -coey[i] * coex[j] * frqData[i, j] / Math.Sqrt(coey[i] * coey[i] + coex[j] * coex[j]);
                }
            }
            VxyData[0, 0]                  = new Complex(0, 0);
            VxyData[height / 2, 0]         = new Complex(0, 0);
            VxyData[0, whith / 2]          = new Complex(0, 0);
            VxyData[height / 2, whith / 2] = new Complex(0, 0);
            return(VxyData);
        }