Beispiel #1
0
        public static double[,] FilterProject(double[,] z, int expendMethod, double filterProject)
        {
            int row = z.GetLength(0);
            int col = z.GetLength(1);

            int expendRow = EdgeDetection.GetExpanNum(row);
            int expendCol = EdgeDetection.GetExpanNum(col);
            int row1      = (expendRow - row) / 2;
            int row2      = expendRow - row1 - row;
            int col1      = (expendCol - col) / 2;
            int col2      = expendCol - col1 - col;

            var expend   = Expend(z, expendMethod, row1, row2, col1, col2);
            var frqData  = FFT.fft_2D(new Complex2D(expend));
            var zdrfData = ExpandRestore(FFT.idft_2D(EdgeDetection.Zdrf(frqData)).GetRe(), row, col, row1, col1);

            var project = GetProject(zdrfData);

            for (int i = 0; i < row; i++)
            {
                for (int j = 0; j < col; j++)
                {
                    if (project[i, j] < filterProject)
                    {
                        project[i, j] = 1.70141e38;
                    }
                }
            }

            return(project);
        }
Beispiel #2
0
        private void SaveFile(FileStream fileStream, double[,] data)
        {
            int rows = data.GetLength(0);
            int cols = data.GetLength(1);

            using (var sw = new StreamWriter(fileStream))
            {
                sw.WriteLine("DSAA");
                sw.WriteLine(rows.ToString() + " " + cols.ToString());
                sw.WriteLine(xmin.ToString() + " " + xmax.ToString());
                sw.WriteLine(ymin.ToString() + " " + ymax.ToString());
                var zmin = EdgeDetection.GetDataMin(data);
                var zmax = EdgeDetection.GetDataMax(data);
                sw.WriteLine(zmin.ToString() + " " + zmax.ToString());

                var line = new StringBuilder();
                for (int i = 0; i < rows; i++)
                {
                    for (int j = 0; j < cols; j++)
                    {
                        line.Append(data[i, j]);
                        line.Append(" ");
                    }

                    sw.WriteLine(line.ToString());
                    line.Clear();
                }
            }
        }
Beispiel #3
0
        private void FillRestore(object parameter)
        {
            int rows = anomalyData.GetLength(0);
            int cols = anomalyData.GetLength(1);

            resultData = new double[rows, cols];
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < cols; j++)
                {
                    if (secondData[i, j] == 1.70141e38)
                    {
                        resultData[i, j] = 1.70141e38;
                    }
                    else
                    {
                        resultData[i, j] = anomalyData[i, j];
                    }
                }
            }

            var zmin = EdgeDetection.GetDataMin(resultData);
            var zmax = EdgeDetection.GetDataMax(resultData);

            ResultMin = zmin;
            ResultMax = zmax;
            ResultMap = GetMap(resultData, zmin, zmax);
        }
Beispiel #4
0
        public static double[,] Filter(double[,] z, int expendMethod, double filterProject, int length)
        {
            int row = z.GetLength(0);
            int col = z.GetLength(1);

            int expendRow = EdgeDetection.GetExpanNum(row);
            int expendCol = EdgeDetection.GetExpanNum(col);
            int row1      = (expendRow - row) / 2;
            int row2      = expendRow - row1 - row;
            int col1      = (expendCol - col) / 2;
            int col2      = expendCol - col1 - col;

            var expend   = Expend(z, expendMethod, row1, row2, col1, col2);
            var frqData  = FFT.fft_2D(new Complex2D(expend));
            var zdrfData = ExpandRestore(FFT.idft_2D(EdgeDetection.Zdrf(frqData)).GetRe(), row, col, row1, col1);

            return(Filter(z, zdrfData, filterProject, length));
        }
Beispiel #5
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 #6
0
        private void GridSimplify(object parameter)
        {
            int rows = anomalyData.GetLength(0);
            int cols = anomalyData.GetLength(1);

            resultData = new double[51, 51];
            for (int i = 0; i < rows; i += 4)
            {
                for (int j = 0; j < cols; j += 4)
                {
                    resultData[i / 4, j / 4] = anomalyData[i, j];
                }
            }
            var zmin = EdgeDetection.GetDataMin(resultData);
            var zmax = EdgeDetection.GetDataMax(resultData);

            ResultMin = zmin;
            ResultMax = zmax;
            ResultMap = GetMap(resultData, zmin, zmax);
        }
Beispiel #7
0
        private void Separate(object parameter)
        {
            int rows  = anomalyData.GetLength(0);
            int cols  = anomalyData.GetLength(1);
            int index = Convert.ToInt32(parameter);

            if (index == 0)
            {
                resultData = Separation.TrendAnalysis(anomalyData, power);
            }
            else if (index == 1)
            {
                resultData = Separation.FilterTrendAnalysis(anomalyData, FiltData, power);
            }
            else if (index == 2)
            {
                resultData = Separation.InterpolateCut(anomalyData, expendMethod, radius, times);
            }
            else if (index == 3)
            {
                resultData = Separation.MoveAverage(anomalyData, secondData, expendMethod, radiusMin, radiusMax, radiusTick, out int bestRadius);
                Radius     = bestRadius;
            }
            else if (index == 4)
            {
                resultData = Separation.MoveAverage(anomalyData, expendMethod, radius);
            }
            else if (index == 5)
            {
                resultData = Separation.FilterMoveAverage(anomalyData, FiltData, expendMethod, radius);
            }
            else if (index == 6)
            {
                resultData = FiltData;
            }
            else if (index == 7)
            {
                resultData = Separation.FilterProject(anomalyData, expendMethod, project);
            }
            else if (index == 8)
            {
                resultData = EdgeDetection.ExpandRestore(FFT.idft_2D(EdgeDetection.延拓(FrqData, 延拓高度)).GetRe());
            }

            var zmin = EdgeDetection.GetDataMin(resultData);
            var zmax = EdgeDetection.GetDataMax(resultData);

            ResultMin = zmin;
            ResultMax = zmax;
            ResultMap = GetMap(resultData, zmin, zmax);

            if (index != 6)
            {
                secondResultData = new double[rows, cols];
                for (int i = 0; i < rows; i++)
                {
                    for (int j = 0; j < cols; j++)
                    {
                        secondResultData[i, j] = anomalyData[i, j] - resultData[i, j];
                    }
                }
            }
            else
            {
                secondResultData = Separation.AverageFill(resultData);
            }

            zmin            = EdgeDetection.GetDataMin(secondResultData);
            zmax            = EdgeDetection.GetDataMax(secondResultData);
            SecondResultMin = zmin;
            SecondResultMax = zmax;
            SecondResultMap = GetMap(secondResultData, zmin, zmax);
        }
Beispiel #8
0
        private void EdgeDetect(object parameter)
        {
            int index = Convert.ToInt32(parameter);

            if (index == 0)
            {
                resultData = Tempxdrdata;
            }
            else if (index == 1)
            {
                resultData = Tempydrdata;
            }
            else if (index == 2)
            {
                resultData = Tempzdrdata;
            }
            else if (index == 3)
            {
                resultData = EdgeDetection.Thdr(Tempxdrdata, Tempydrdata);
            }
            else if (index == 4)
            {
                resultData = EdgeDetection.Asm(Tempxdrdata, Tempydrdata, Tempzdrdata);
            }
            else if (index == 5)
            {
                resultData = EdgeDetection.Tilt(Tempzdrdata, EdgeDetection.Thdr(Tempxdrdata, Tempydrdata));
            }
            else if (index == 6)
            {
                resultData = EdgeDetection.Theta(EdgeDetection.Thdr(Tempxdrdata, Tempydrdata), EdgeDetection.Asm(Tempxdrdata, Tempydrdata, Tempzdrdata));
            }
            else if (index == 7)
            {
                resultData = EdgeDetection.Nstd(Tempxdrdata, Tempydrdata, Tempzdrdata, winSize);
            }
            else if (index == 8)
            {
                resultData = EdgeDetection.Gdo(Tempxdrdata, Tempydrdata, Tempzdrdata, alpha, theta);
            }
            else if (index == 9)
            {
                resultData = EdgeDetection.Ita2(Tempxdrdata, Tempydrdata, Tempzdrdata);
            }
            else if (index == 10)
            {
                resultData = EdgeDetection.ETA1(Tempxdrdata, Tempydrdata, Tempzdrdata);
            }
            else if (index == 11)
            {
                resultData = EdgeDetection.HFTilt(Tempxdrdata, Tempydrdata, VxxData, VyyData, VxyData);
            }
            else if (index == 12)
            {
                resultData = EdgeDetection.HFTheta(Tempxdrdata, Tempydrdata, VxxData, VyyData, VxyData);
            }
            else if (index == 13)
            {
                var asmData = EdgeDetection.Asm(Tempxdrdata, Tempydrdata, Tempzdrdata);
                double[,] asmZdrData, asmXdrData, asmYdrData;
                if (isFrqDomain)
                {
                    var asmFrqData = FFT.fft_2D(new Complex2D(EdgeDetection.MinCurveExpand(asmData)));
                    asmZdrData = EdgeDetection.ExpandRestore(FFT.idft_2D(EdgeDetection.Zdrf(asmFrqData)).GetRe());
                    asmYdrData = EdgeDetection.ExpandRestore(FFT.idft_2D(EdgeDetection.Ydrf(asmFrqData)).GetRe());
                    asmXdrData = EdgeDetection.ExpandRestore(FFT.idft_2D(EdgeDetection.Xdrf(asmFrqData)).GetRe());
                }
                else
                {
                    asmZdrData = EdgeDetection.Zdr(asmData);
                    asmYdrData = EdgeDetection.Ydr(asmData);
                    asmXdrData = EdgeDetection.Xdr(asmData);
                }
                var asmThdrData = EdgeDetection.Thdr(asmXdrData, asmYdrData);
                resultData = EdgeDetection.Tilt(asmZdrData, asmThdrData);
            }
            else if (index == 14)
            {
                var tiltData = EdgeDetection.Tilt(Tempzdrdata, EdgeDetection.Thdr(Tempxdrdata, Tempydrdata));
                double[,] tiltXdrData, tiltYdrData;
                if (isFrqDomain)
                {
                    var tiltFrqData = FFT.fft_2D(new Complex2D(EdgeDetection.MinCurveExpand(tiltData)));
                    tiltYdrData = EdgeDetection.ExpandRestore(FFT.idft_2D(EdgeDetection.Ydrf(tiltFrqData)).GetRe());
                    tiltXdrData = EdgeDetection.ExpandRestore(FFT.idft_2D(EdgeDetection.Xdrf(tiltFrqData)).GetRe());
                }
                else
                {
                    tiltYdrData = EdgeDetection.Ydr(tiltData);
                    tiltXdrData = EdgeDetection.Xdr(tiltData);
                }

                resultData = EdgeDetection.Thdr(tiltXdrData, tiltYdrData);
            }
            else if (index == 15)
            {
                resultData = EdgeDetection.GuassNoise(anomalyData);
            }
            else if (index == 16)
            {
                resultData = EdgeDetection.Idct(EdgeDetection.Zdrf(EdgeDetection.Dct(anomalyData, false)));
            }

            var zmin = EdgeDetection.GetDataMin(resultData);
            var zmax = EdgeDetection.GetDataMax(resultData);

            ResultMin = zmin;
            ResultMax = zmax;
            ResultMap = GetMap(resultData, zmin, zmax);
        }