//--------------------------------------------------------------------------------------------------------------------- public RealMatrix[] GetCorrectedInterferograms(RealMatrix[] interferograms, double[] gammaValues) { int width = interferograms[0].ColumnCount; int height = interferograms[0].RowCount; RealMatrix[] gammaCorrectedInterferograms = new RealMatrix[interferograms.Length]; for (int index = 0; index < gammaCorrectedInterferograms.Length; index++) { gammaCorrectedInterferograms[index] = new RealMatrix(height, width); } for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { double[] intensities = MatricesManager.GeValuesFromMatrices(y, x, interferograms); int cyclingShiftsCount = 0; double[] intensitiesByCyclingShift = ArrayOperator.GetArrayByCyclingShiftWithMinimumValueInOrigin(intensities, out cyclingShiftsCount); int optimalGammaValueIndex = this.GetOptimalGammaValueIndex(intensitiesByCyclingShift, gammaValues); double gamma = gammaValues[optimalGammaValueIndex]; double[] gammaCorrectedIntensities = ArrayOperator.GetValuesInPower(intensities, gamma); double[] resultValues = ArrayOperator.GetArrayByReverseCyclingShift(gammaCorrectedIntensities, cyclingShiftsCount); MatricesManager.SetValuesInMatrices(gammaCorrectedInterferograms, resultValues, y, x); } } return(gammaCorrectedInterferograms); }
//--------------------------------------------------------------------------------------------- private RealMatrix[] GetNormalizedMatrices(RealMatrix[] matrices) { RealMatrix[] newMatrices = MatricesManager.TransformMatricesValuesToFinishIntervalValues (new Interval <double>(0, 255), matrices); return(newMatrices); }
//-------------------------------------------------------------------------------------------------------------- //Точки в пространстве из интенсивностей для строки интерферограммы public static Point3D[] GetSpatialPointsFromInterferogramsRow( RealMatrix[] interferograms, BitMask2D bitMask, int row ) { if (interferograms.Length != 3) { throw new Exception(); } int width = interferograms[0].ColumnCount; int height = interferograms[0].RowCount; int y = row; List <Point3D> points = new List <Point3D>(); for (int x = 0; x < width; x++) { if (bitMask[y, x]) { double[] intensities = MatricesManager.GeValuesFromMatrices(row, x, interferograms); Point3D point = new Point3D(intensities); points.Add(point); } } return(points.ToArray()); }
//--------------------------------------------------------------------------------------- //Гамма-коррекция интерферограмм public RealMatrix[] GetGammaCorrectedInterferograms( double gamma, RealMatrix[] interferograms ) { double[] gammaCoefficients = new double[] { 1 }; double[] gammaPowers = new double[] { gamma }; RealMatrix[] gammaCorrectedMatrices = MatricesManager.GetGammaCorrectedMatrices (gammaCoefficients, gammaPowers, interferograms); return(gammaCorrectedMatrices); }
//---------------------------------------------------------------------------------- //Значения интенсивностей в конкретоной точке интерферограмм protected double[] CreateIntensitiesAtPoint( int x, //Координата X int y, //Координата Y params RealMatrix[] interferograms ) { double[] intensities = MatricesManager.GeValuesFromMatrices(y, x, interferograms); return(intensities); }
//-------------------------------------------------------------------------------------------------------------- //Точки в пространстве из интенсивностей для области интерферограммы, заданной прямоугольником public static Point3D[] GetSpatialPointsFromInterferograms( RealMatrix[] interferograms, Rectangle rectangle ) { List <Point3D> points = new List <Point3D>(); int maxX = rectangle.X + rectangle.Width; int maxY = rectangle.Y + rectangle.Height; for (int x = rectangle.X; x < maxX; x++) { for (int y = rectangle.Y; y < maxY; y++) { double[] intensities = MatricesManager.GeValuesFromMatrices(y, x, interferograms); Point3D point = new Point3D(intensities); points.Add(point); } } return(points.ToArray()); }
//---------------------------------------------------------------------------------------------------------- public RealMatrix[] GetFilteredInterferograms( int windowSize, params RealMatrix[] interferograms ) { RealMatrix firstInterferogram = interferograms[0]; int width = firstInterferogram.ColumnCount; int height = firstInterferogram.RowCount; int newWidth = width - windowSize + 1; int newHeight = height - windowSize + 1; RealMatrix[] newMatrices = MatricesManager.CreateMatrices(newHeight, newWidth, 3); int halfSize = windowSize / 2; int startX = halfSize; int startY = halfSize; int finishX = width - halfSize - 1; int finishY = height - halfSize - 1; for (int x = startX, newX = 0; x <= finishX; x++, newX++) { for (int y = startY, newY = 0; y <= finishY; y++, newY++) { Rectangle rectangle = new Rectangle(x - halfSize, y - halfSize, windowSize, windowSize); Point3D[] points = InterferometryHelper.GetSpatialPointsFromInterferograms(interferograms, rectangle); Point3D filteredPoint = SpaceManager.GetMidPoint(points); newMatrices[0][newY, newX] = filteredPoint.X; newMatrices[1][newY, newX] = filteredPoint.Y; newMatrices[2][newY, newX] = filteredPoint.Z; } } return(newMatrices); }