//---------------------------------------------------------------------------------------------
        //---------------------------------------------------------------------------------------------
        public InterferogramDecodingResult DecodeInterferogram(
            BitMask2D bitMask, params RealMatrix[] interferograms
            )
        {
            //Выбранные точки изображения
            Point[] selectedImagePoints = bitMask.GetTruePoints();

            double[] phaseShifts = this.GetRandomPhaseShifts(interferograms.Length);
            GenericInterferogramDecoder genericInterferogramDecoder = new GenericInterferogramDecoder();

            double[] numerators = genericInterferogramDecoder.GetDecodingFormulaNumerators
                                      (interferograms, phaseShifts, bitMask);
            double[] denominators = genericInterferogramDecoder.GetDecodingFormulaDenominators
                                        (interferograms, phaseShifts, bitMask);

            Point2D[] points2D = PlaneManager.CreatePoints2D(numerators, denominators);

            if (this.ExecutePointsCorrecting)
            {
                points2D = this.GetTransformedPoints(points2D);
            }
            int        sizeX        = interferograms[0].ColumnCount;
            int        sizeY        = interferograms[0].RowCount;
            RealMatrix resultMatrix =
                this.CalculatePhaseMatrix(points2D, selectedImagePoints, sizeX, sizeY);
            InterferogramDecodingResult decodingResult = new InterferogramDecodingResult(resultMatrix);

            return(decodingResult);
        }
        //---------------------------------------------------------------------------------------------
        public InterferogramDecodingResult DecodeInterferogram(
            BitMask2D bitMask, params RealMatrix[] interferograms
            )
        {
            //Выбранные точки изображения
            Point[] selectedImagePoints = bitMask.GetTruePoints();

            //3D точки в плоскости, параллельной плоскости XY
            Point3D[] points3D =
                this.GetParallelToCoordinatePlanePoints3D(interferograms, selectedImagePoints);

            Point2D[] points2D = SpaceManager.GetProjectionXY(points3D);
            this.ProjectionPoints = points2D;
            points2D = PlaneManager.DisplacePointsToFirstQuadrant(points2D);

            Point2D[] transformedPoints = this.GetTransformedPoints(points2D);
            int       sizeX             = interferograms[0].ColumnCount;
            int       sizeY             = interferograms[0].RowCount;

            RealMatrix phaseMatrix =
                this.CalculatePhaseMatrix(transformedPoints, selectedImagePoints, sizeX, sizeY);

            InterferogramDecodingResult decodingResult = new InterferogramDecodingResult(phaseMatrix);

            return(decodingResult);
        }
        //---------------------------------------------------------------------------------------------
        public InterferogramDecodingResult DecodeInterferogram(RealMatrix[] interferograms, BitMask2D bitMask)
        {
            //double gamma = 2;
            //interferograms = MatricesManager.GetGammaCorrectedMatrices( gamma, interferograms );
            //interferograms = GetNormalizedMatrices( interferograms );

            //Выбранные точки изображения
            Point[]   selectedImagePoints = bitMask.GetTruePoints();
            Point3D[] points3D            =
                this.GetParallelToCoordinatePlanePoints3D(interferograms, selectedImagePoints);
            this.TrajectoryPoints = points3D;

            Point2D[] points2D = SpaceManager.GetProjectionXY(points3D);
            this.ProjectionPoints = points2D;

            EllipseDescriptor ellipseDescriptor = this.GetEllipseDescriptor(points2D);
            Point2D           ellipseCentre     = ellipseDescriptor.GetCentre();
            Point3D           pointsCentre      = new Point3D(ellipseCentre.X, ellipseCentre.Y, points3D[0].Z);

            RealVector cylinderGuidLine           = this.GetCylinderGuidLine(ellipseDescriptor);
            RealVector normalizedCylinderGuidLine = cylinderGuidLine.GetNormalizedVector();

            /*
             * this.CalculateCirclePointsDispersion( cylinderGuidLine, points3D, pointsCentre );
             * double cylinderGuidLineOptimalAngle = this.GetCylinderGuidLineOptimalAngle();
             * cylinderGuidLine = this.GetRotatedInPlaneCylinderGuidLine
             *  ( cylinderGuidLine, cylinderGuidLineOptimalAngle );
             */

            Point3D[] circlePoints = this.GetCirclePoints(points3D, normalizedCylinderGuidLine);
            this.CirclePoints = circlePoints;
            Point3D circlePointsCentre =
                this.GetCorrectedCirclePoint(pointsCentre, normalizedCylinderGuidLine);

            //Поворот точек
            RealMatrix rotationMatrix = this.GetRotationMatrix(circlePoints);

            //rotationMatrix.WriteToTextFile( @"d:\!!\RotationMatrix.txt" ); // debug

            Point3D[] rotatedCirclePoints = this.RotatePoints(circlePoints, rotationMatrix);
            this.RotatedCirclePoints = rotatedCirclePoints;

            Point3D rotatedCirclePointsCentre = PlaneManager.RotateVector
                                                    (new RealVector(circlePointsCentre), rotationMatrix).ToPoint3D();

            Point3D[] correctedPoints =
                this.DisplacePoints(rotatedCirclePoints, rotatedCirclePointsCentre);

            int sizeX = interferograms[0].ColumnCount;
            int sizeY = interferograms[0].RowCount;

            RealMatrix phaseMatrix = this.CalculatePhaseMatrixByCirclePoints
                                         (correctedPoints, selectedImagePoints, sizeX, sizeY);

            InterferogramDecodingResult decodingResult = new InterferogramDecodingResult(phaseMatrix);

            return(decodingResult);
        }
示例#4
0
        //---------------------------------------------------------------------------------------------
        public InterferogramDecodingResult DecodeInterferogram(RealMatrix[] interferograms, BitMask2D bitMask)
        {
            //Выбранные точки изображения
            Point[] selectedImagePoints = bitMask.GetTruePoints();

            //Ортогональные векторы
            RealVector[] orthogonalVectors = this.GetOrthogonalVectors(interferograms, selectedImagePoints);

            RandomNumberGenerator randomNumberGenerator = new RandomNumberGenerator();

            int indexVector1 = randomNumberGenerator.GetNextInteger(orthogonalVectors.Length - 1);
            int indexVector2 = randomNumberGenerator.GetNextInteger(orthogonalVectors.Length - 1);

            RealVector vector1 = orthogonalVectors[indexVector1];
            RealVector vector2 = orthogonalVectors[indexVector2];

            RealVector normalY;
            RealVector normalX;

            RealMatrix rotMatrixY;
            RealMatrix rotMatrixX;
            RealMatrix rotMatrix;

            double alfa;
            double beta;

            normalY    = SpaceManager.GetVectorsCrossProduct(vector1, vector2);
            alfa       = Math.Atan(-(normalY[0] / normalY[2]));
            rotMatrixY = SpaceManager.GetRotationMatrixAroundAxisY(alfa);

            normalX    = SpaceManager.RotateVector(normalY, rotMatrixY);
            beta       = Math.Atan(-(normalX[1] / normalX[2]));
            rotMatrixX = SpaceManager.GetRotationMatrixAroundAxisX(beta);

            rotMatrix = rotMatrixX * rotMatrixY;

            RealVector[] rotVectors = SpaceManager.RotateVectors(orthogonalVectors, rotMatrix);
            Point3D[]    points3D   = this.GetPoints3D(rotVectors);

            //this.OrthogonalVectorsPoints = points3D;

            Point2D[] points2D = SpaceManager.GetProjectionXY(points3D);
            this.PlaneXYPoints = points2D;

            RealMatrix covariationMatrix = Statistician.GetCovariationMatrix(points2D);
            double     a11 = covariationMatrix[0, 0];
            double     a22 = covariationMatrix[1, 1];
            double     a12 = covariationMatrix[0, 1];

            double[] eigenValues   = MathHelper.GetEigenValuesMatrix2x2(covariationMatrix);
            double   minEigenValue = eigenValues.Min();
            double   maxEigenValue = eigenValues.Max();

            RealVector eigenVector1 = new RealVector
                                      (
                1, -((a11 + a12 - minEigenValue) / (a12 + a22 - minEigenValue))
                                      );

            RealVector eigenVector2 = new RealVector
                                      (
                1, -((a11 + a12 - maxEigenValue) / (a12 + a22 - maxEigenValue))
                                      );

            Complex complex = new Complex(eigenVector1[0], eigenVector1[1]);
            double  omega   = complex.Phase;

            double     a  = Math.Sqrt(minEigenValue);
            double     b  = Math.Sqrt(maxEigenValue);
            double     h  = a / Math.Sqrt(b * b - a * a);
            RealVector Nc = new RealVector(Math.Cos(omega), -Math.Sin(omega), h);

            Point3D[] circlePoints = this.GetCirclePoints(points3D, Nc);
            //this.OrthogonalVectorsPoints = circlePoints;

            RealVector[] circlePointsVectors = new RealVector[circlePoints.Length];
            for (int index = 0; index < circlePoints.Length; index++)
            {
                circlePointsVectors[index] = new RealVector(circlePoints[index]);
            }

            indexVector1 = randomNumberGenerator.GetNextInteger(circlePointsVectors.Length - 1);
            indexVector2 = randomNumberGenerator.GetNextInteger(circlePointsVectors.Length - 1);

            vector1 = circlePointsVectors[indexVector1];
            vector2 = circlePointsVectors[indexVector2];

            normalY    = SpaceManager.GetVectorsCrossProduct(vector1, vector2);
            alfa       = Math.Atan(-(normalY[0] / normalY[2]));
            rotMatrixY = SpaceManager.GetRotationMatrixAroundAxisY(alfa);

            normalX    = SpaceManager.RotateVector(normalY, rotMatrixY);
            beta       = Math.Atan(-(normalX[1] / normalX[2]));
            rotMatrixX = SpaceManager.GetRotationMatrixAroundAxisX(beta);

            rotMatrix = rotMatrixX * rotMatrixY;

            rotVectors = SpaceManager.RotateVectors(circlePointsVectors, rotMatrix);
            points3D   = this.GetPoints3D(rotVectors);
            points2D   = SpaceManager.GetProjectionXY(points3D);

            this.OrthogonalVectorsPoints = points3D;

            RealMatrix phaseMatrix = new RealMatrix(interferograms[0].RowCount, interferograms[0].ColumnCount);

            for (int index = 0; index < selectedImagePoints.Length; index++)
            {
                Point2D circlePoint = points2D[index];
                int     x           = selectedImagePoints[index].X;
                int     y           = selectedImagePoints[index].Y;

                phaseMatrix[y, x] = Math.PI + Math.Atan2(circlePoint.Y, circlePoint.X);
            }


            this.EigenVector1 =
                new RealVector(eigenVector1[0] / eigenVector1.Length, eigenVector1[1] / eigenVector1.Length);

            this.EigenVector2 =
                new RealVector(eigenVector2[0] / eigenVector2.Length, eigenVector2[1] / eigenVector2.Length);



            InterferogramDecodingResult decodingResult = new InterferogramDecodingResult(phaseMatrix);

            return(decodingResult);
        }