Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SpectralResampling"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <param name="parameters">The parameters.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The source is null.
        /// or
        /// The method requires parameters which are not specified.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The parameters do not contain a required parameter value.
        /// or
        /// The type of a parameter does not match the type specified by the method.
        /// or
        /// The parameter value does not satisfy the conditions of the parameter.
        /// or
        /// The specified source and result are the same objects, but the method does not support in-place operations.
        /// or
        /// The source geometry does not contain raster data.
        /// </exception>
        public SpectralResampling(ISpectralGeometry source, ISpectralGeometry target, IDictionary <OperationParameter, Object> parameters)
            : base(source, target, SpectralOperationMethods.SpectralResampling, parameters)
        {
            SourceColumnCount  = IsProvidedParameter(SpectralOperationParameters.SourceColumnCount) ? Convert.ToDouble(ResolveParameter(SpectralOperationParameters.SourceColumnCount)) : Source.Raster.NumberOfColumns;
            SourceColumnOffset = Convert.ToDouble(ResolveParameter(SpectralOperationParameters.SourceColumnOffset));
            SourceRowCount     = IsProvidedParameter(SpectralOperationParameters.SourceRowCount) ? Convert.ToDouble(ResolveParameter(SpectralOperationParameters.SourceRowCount)) : Source.Raster.NumberOfRows;
            SourceRowOffset    = Convert.ToDouble(ResolveParameter(SpectralOperationParameters.SourceRowOffset));

            _targetNumberOfRows    = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.NumberOfRows));
            _targetNumberOfColumns = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.NumberOfColumns));

            // check whether the strategy is provided
            if (IsProvidedParameter(SpectralOperationParameters.RasterResamplingAlgorithm))
            {
                _resamplingAlgorithm = ResolveParameter <RasterResamplingAlgorithm>(SpectralOperationParameters.RasterResamplingAlgorithm);
            }

            // check the strategy type (that has default value)
            if (_resamplingAlgorithm == null)
            {
                try
                {
                    _resamplingAlgorithm = (RasterResamplingAlgorithm)Activator.CreateInstance(ResolveParameter <Type>(SpectralOperationParameters.RasterResamplingAlgorithmType), new Object[] { Source.Raster });
                }
                catch
                {
                    _resamplingAlgorithm = (RasterResamplingAlgorithm)Activator.CreateInstance((Type)SpectralOperationParameters.RasterResamplingAlgorithmType.DefaultValue, new Object[] { Source.Raster });
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CustomFilterOperation" /> class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="target">The target.</param>
 /// <param name="parameters">The parameters.</param>
 /// <exception cref="System.ArgumentNullException">
 /// The source is null.
 /// or
 /// The method requires parameters which are not specified.
 /// </exception>
 /// <exception cref="System.ArgumentException">
 /// The parameters do not contain a required parameter value.
 /// or
 /// The type of a parameter does not match the type specified by the method.
 /// or
 /// The value of a parameter is not within the expected range.
 /// or
 /// The specified source and result are the same objects, but the method does not support in-place operations.
 /// </exception>
 public CustomFilterOperation(ISpectralGeometry source, ISpectralGeometry target, IDictionary <OperationParameter, Object> parameters)
     : base(source, target, SpectralOperationMethods.CustomFilter, parameters)
 {
     AddFilter(new Filter(ResolveParameter <Matrix>(SpectralOperationParameters.FilterKernel),
                          Convert.ToDouble(ResolveParameter(SpectralOperationParameters.FilterFactor)),
                          Convert.ToDouble(ResolveParameter(SpectralOperationParameters.FilterOffset))));
 }
 /// <summary>
 /// Initialize a new instance of <see cref="SauvolaLocalThresholdingClassification" /> class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="target">The target.</param>
 /// <param name="parameters">The parameters.</param>
 /// <exception cref="System.ArgumentNullException">The source is null.</exception>
 /// <exception cref="System.ArgumentException">
 /// The source is invalid.
 /// or
 /// The target is invalid.
 /// or
 /// The specified source and result are the same objects, but the method does not support in-place operations.
 /// or
 /// The parameters do not contain a required parameter value.
 /// or
 /// The type of a parameter does not match the type specified by the method.
 /// or
 /// A parameter value does not satisfy the conditions of the parameter.
 /// </exception>
 public SauvolaLocalThresholdingClassification(ISpectralGeometry source, ISpectralGeometry target, IDictionary <OperationParameter, Object> parameters)
     : base(source, null, SpectralOperationMethods.SauvolaLocalThresholdingClassification, parameters)
 {
     _standardDeviationWeight = Convert.ToDouble(ResolveParameter(SpectralOperationParameters.StandardDeviationWeight));
     _standardDeviatonRange   = Convert.ToDouble(ResolveParameter(SpectralOperationParameters.StandardDeviationRange));
     _windowRadius            = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.ThresholdingWindowRadius));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="UnsharpMaskingOperation" /> class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="target">The target.</param>
 /// <param name="parameters">The parameters.</param>
 /// <exception cref="System.ArgumentNullException">
 /// The source is null.
 /// or
 /// The method requires parameters which are not specified.
 /// </exception>
 /// <exception cref="System.ArgumentException">
 /// The parameters do not contain a required parameter value.
 /// or
 /// The type of a parameter does not match the type specified by the method.
 /// or
 /// The value of a parameter is not within the expected range.
 /// or
 /// The specified source and result are the same objects, but the method does not support in-place operations.
 /// </exception>
 public UnsharpMaskingOperation(ISpectralGeometry source, ISpectralGeometry target, IDictionary <OperationParameter, Object> parameters)
     : base(source, target, SpectralOperationMethods.UnsharpMasking, parameters)
 {
     _amount        = Convert.ToDouble(ResolveParameter(SpectralOperationParameters.SharpeningAmount));
     _threshold     = Convert.ToDouble(ResolveParameter(SpectralOperationParameters.SharpeningThreshold));
     _unsharpFilter = FilterFactory.CreateGaussianFilter(Convert.ToInt32(ResolveParameter(SpectralOperationParameters.SharpeningRadius)));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="VogelmannRedEdgeIndexComputation" /> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="result">The result.</param>
        /// <param name="parameters">The parameters.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The source is null.
        /// or
        /// The method requires parameters which are not specified.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The parameters do not contain a required parameter value.
        /// or
        /// The type of a parameter does not match the type specified by the method.
        /// or
        /// The value of a parameter is not within the expected range.
        /// or
        /// The specified source and result are the same objects, but the method does not support in-place operations.
        /// or
        /// The source does not contain required data.
        /// or
        /// The source contains invalid data.
        /// </exception>
        public VogelmannRedEdgeIndexComputation(ISpectralGeometry source, ISpectralGeometry result, IDictionary <OperationParameter, Object> parameters)
            : base(source, result, SpectralOperationMethods.VogelmannRedEdgeIndexComputation, parameters)
        {
            try
            {
                _indexOf715nmBand = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.IndexOf715nmBand, Source.Imaging.SpectralRanges.IndexOf(range => range.WavelengthMinimum <= 715e-9 && range.WavelengthMaximum >= 715e-9)));
                _indexOf720nmBand = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.IndexOf720nmBand, Source.Imaging.SpectralRanges.IndexOf(range => range.WavelengthMinimum <= 720e-9 && range.WavelengthMaximum >= 720e-9)));
                _indexOf726nmBand = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.IndexOf726nmBand, Source.Imaging.SpectralRanges.IndexOf(range => range.WavelengthMinimum <= 726e-9 && range.WavelengthMaximum >= 726e-9)));
                _indexOf734nmBand = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.IndexOf734nmBand, Source.Imaging.SpectralRanges.IndexOf(range => range.WavelengthMinimum <= 734e-9 && range.WavelengthMaximum >= 734e-9)));
                _indexOf740nmBand = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.IndexOf740nmBand, Source.Imaging.SpectralRanges.IndexOf(range => range.WavelengthMinimum <= 740e-9 && range.WavelengthMaximum >= 740e-9)));
                _indexOf747nmBand = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.IndexOf747nmBand, Source.Imaging.SpectralRanges.IndexOf(range => range.WavelengthMinimum <= 747e-9 && range.WavelengthMaximum >= 747e-9)));
            }
            catch
            {
                throw new ArgumentException("The source does not contain required data.", "source");
            }

            if (_indexOf715nmBand < 0 || _indexOf715nmBand >= Source.Raster.NumberOfBands ||
                _indexOf720nmBand < 0 || _indexOf720nmBand >= Source.Raster.NumberOfBands ||
                _indexOf726nmBand < 0 || _indexOf726nmBand >= Source.Raster.NumberOfBands ||
                _indexOf734nmBand < 0 || _indexOf734nmBand >= Source.Raster.NumberOfBands ||
                _indexOf740nmBand < 0 || _indexOf740nmBand >= Source.Raster.NumberOfBands ||
                _indexOf747nmBand < 0 || _indexOf747nmBand >= Source.Raster.NumberOfBands)
            {
                throw new ArgumentException("The source contains invalid data.", "source");
            }
        }
        public void SauvolaLocalThresholdingClassificationExecuteTest()
        {
            IGeometryFactory factory = new GeometryFactory();

            SauvolaLocalThresholdingClassification operation = new SauvolaLocalThresholdingClassification(factory.CreateSpectralPolygon(_rasterMock.Object), null);

            operation.Execute();

            ISpectralGeometry result = operation.Result;

            Assert.AreEqual(_rasterMock.Object.NumberOfRows, result.Raster.NumberOfRows);
            Assert.AreEqual(_rasterMock.Object.NumberOfColumns, result.Raster.NumberOfColumns);
            Assert.AreEqual(_rasterMock.Object.NumberOfBands, result.Raster.NumberOfBands);
            Assert.AreEqual(_rasterMock.Object.RadiometricResolution, result.Raster.RadiometricResolution);
            Assert.AreEqual(RasterFormat.Integer, result.Raster.Format);

            for (Int32 bandIndex = 0; bandIndex < result.Raster.NumberOfBands; bandIndex++)
            {
                for (Int32 rowIndex = 0; rowIndex < result.Raster.NumberOfRows; rowIndex++)
                {
                    for (Int32 columnIndex = 0; columnIndex < result.Raster.NumberOfColumns; columnIndex++)
                    {
                        Assert.IsTrue(result.Raster.GetValue(rowIndex, columnIndex, bandIndex) == 0 ||
                                      result.Raster.GetValue(rowIndex, columnIndex, bandIndex) == 255);
                    }
                }
            }
        }
        public void ImageMatchingClassificationExecuteTest()
        {
            ISpectralGeometry validationGeometry = new GeometryFactory().CreateSpectralPolygon(_referenceRasterMock.Object);
            IDictionary <OperationParameter, Object> parameters = new Dictionary <OperationParameter, Object>();

            parameters.Add(SpectralOperationParameters.ClassificationValidationGeometry, validationGeometry);

            ClassificationMapValidation operation = new ClassificationMapValidation(new GeometryFactory().CreateSpectralPolygon(_sourceRasterMock.Object), parameters);

            operation.Execute();

            ISpectralGeometry result = operation.Result;

            Assert.AreEqual(_sourceRasterMock.Object.NumberOfRows, result.Raster.NumberOfRows);
            Assert.AreEqual(_sourceRasterMock.Object.NumberOfColumns, result.Raster.NumberOfColumns);
            Assert.AreEqual(_sourceRasterMock.Object.NumberOfBands, result.Raster.NumberOfBands);
            Assert.AreEqual(RasterFormat.Integer, result.Raster.Format);

            for (Int32 i = 0; i < 4; i++)
            {
                for (Int32 j = 0; j < 4; j++)
                {
                    if (i == 0 && j == 0)
                    {
                        Assert.AreEqual(0, result.Raster.GetValue(i, j, 0));
                    }
                    else
                    {
                        Assert.AreEqual(255, result.Raster.GetValue(i, j, 0));
                    }
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SpotTopOfAtmosphereReflectanceComputation" /> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="result">The result.</param>
        /// <param name="parameters">The parameters.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The source is null.
        /// or
        /// The method requires parameters which are not specified.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The parameters do not contain a required parameter value.
        /// or
        /// The type of a parameter does not match the type specified by the method.
        /// or
        /// The value of a parameter is not within the expected range.
        /// or
        /// The specified source and result are the same objects, but the method does not support in-place operations.
        /// or
        /// The source does not contain required data.
        /// or
        /// The source contains invalid data.
        /// </exception>
        public SpotTopOfAtmosphereReflectanceComputation(ISpectralGeometry source, ISpectralGeometry result, IDictionary <OperationParameter, Object> parameters)
            : base(source, result, SpectralOperationMethods.TopOfAtmospehereReflectanceComputation, parameters)
        {
            if (Source.Imaging == null)
            {
                throw new ArgumentException("The source does not contain required data.", "source");
            }
            if (Source.Imaging.Device.Mission != "SPOT")
            {
                throw new ArgumentException("The source does not contain required data.", "source");
            }

            try
            {
                _indexOfGreenBand                   = ResolveParameter(SpectralOperationParameters.IndexOfGreenBand, Source.Imaging.SpectralDomains.IndexOf(SpectralDomain.Green));
                _indexOfRedBand                     = ResolveParameter(SpectralOperationParameters.IndexOfRedBand, Source.Imaging.SpectralDomains.IndexOf(SpectralDomain.Red));
                _indexOfNearInfraredBand            = ResolveParameter(SpectralOperationParameters.IndexOfNearInfraredBand, Source.Imaging.SpectralDomains.IndexOf(SpectralDomain.NearInfrared));
                _indexOfShortWavelengthInfraredBand = ResolveParameter(SpectralOperationParameters.IndexOfShortWavelengthInfraredBand, Source.Imaging.SpectralDomains.IndexOf(SpectralDomain.ShortWavelengthInfrared));
            }
            catch
            {
                throw new ArgumentException("The source does not contain required data.", "source");
            }

            if (_indexOfGreenBand < 0 || _indexOfGreenBand >= Source.Raster.NumberOfBands ||
                _indexOfRedBand < 0 || _indexOfRedBand >= Source.Raster.NumberOfBands ||
                _indexOfNearInfraredBand < 0 || _indexOfNearInfraredBand >= Source.Raster.NumberOfBands ||
                _indexOfShortWavelengthInfraredBand < 0 || _indexOfShortWavelengthInfraredBand >= Source.Raster.NumberOfBands)
            {
                throw new ArgumentException("The source contains invalid data.", "source");
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ClassificationChangeDetection{TResult}" /> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="operationMethod">The method.</param>
        /// <param name="parameters">The parameters.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The source is null.
        /// or
        /// The method is null.
        /// or
        /// The method requires parameters which are not specified.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The source is invalid.
        /// or
        /// The target is invalid.
        /// or
        /// The specified source and result are the same objects, but the method does not support in-place operations.
        /// or
        /// The parameters do not contain a required parameter value.
        /// or
        /// The type of a parameter does not match the type specified by the method.
        /// or
        /// A parameter value does not satisfy the conditions of the parameter.
        /// </exception>
        protected ClassificationChangeDetection(ISpectralGeometry source, OperationMethod operationMethod, IDictionary <OperationParameter, Object> parameters)
            : base(source, default(TResult), operationMethod, parameters)
        {
            ISpectralGeometry reference = ResolveParameter <ISpectralGeometry>(SpectralOperationParameters.ClassificationReferenceGeometry);

            if (source.Raster == null)
            {
                throw new ArgumentException("The source geometry does not contain a raster image.", nameof(source));
            }
            if (source.Raster.NumberOfBands != 1)
            {
                throw new ArgumentException("The source geometry does not contain a single band.", nameof(source));
            }
            if (reference.Raster == null)
            {
                throw new ArgumentException("The reference geometry does not contain a raster image.", nameof(parameters));
            }
            if (reference.Raster.NumberOfBands != 1)
            {
                throw new ArgumentException("The reference geometry does not contain a single band.", nameof(parameters));
            }

            AreMatchingRasters = RasterAlgorithms.IsMatching(source.Raster, reference.Raster);
            Reference          = reference;
        }
Esempio n. 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SplitAndMergeSegmentation"/> class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="parameters">The parameters.</param>
 /// <exception cref="System.ArgumentNullException">
 /// The source is null.
 /// or
 /// The method requires parameters which are not specified.
 /// </exception>
 /// <exception cref="System.ArgumentException">
 /// The parameters do not contain a required parameter value.
 /// or
 /// The type of a parameter does not match the type specified by the method.
 /// or
 /// The value of a parameter is not within the expected range.
 /// or
 /// The source geometry does not contain raster data.
 /// or
 /// The raster format of the source is not supported by the method.
 /// </exception>
 public SplitAndMergeSegmentation(ISpectralGeometry source, IDictionary <OperationParameter, Object> parameters)
     : base(source, null, SpectralOperationMethods.SplitAndMergeSegmentation, parameters)
 {
     _numberOfIterations        = Convert.ToDouble(ResolveParameter(CommonOperationParameters.NumberOfIterations));
     _splitHomogeneityThreshold = Convert.ToDouble(ResolveParameter(SpectralOperationParameters.SegmentSplitThreshold));
     _mergeHomogeneityThreshold = Convert.ToDouble(ResolveParameter(SpectralOperationParameters.SegmentMergeThreshold));
 }
        public void ExponentialTransformationExecuteTest()
        {
            IGeometryFactory factory = new GeometryFactory();

            ExponentialTransformation operation = new ExponentialTransformation(factory.CreateSpectralPolygon(_rasterMock.Object), null);

            operation.Execute();

            ISpectralGeometry result = operation.Result;

            Assert.AreEqual(_rasterMock.Object.NumberOfRows, result.Raster.NumberOfRows);
            Assert.AreEqual(_rasterMock.Object.NumberOfColumns, result.Raster.NumberOfColumns);
            Assert.AreEqual(_rasterMock.Object.NumberOfBands, result.Raster.NumberOfBands);
            Assert.AreEqual(_rasterMock.Object.RadiometricResolution, result.Raster.RadiometricResolution);
            Assert.AreEqual(RasterFormat.Floating, result.Raster.Format);

            for (Int32 bandIndex = 0; bandIndex < result.Raster.NumberOfBands; bandIndex++)
            {
                for (Int32 rowIndex = 0; rowIndex < result.Raster.NumberOfRows; rowIndex++)
                {
                    for (Int32 columnIndex = 0; columnIndex < result.Raster.NumberOfColumns; columnIndex++)
                    {
                        Assert.AreEqual((Single)Math.Exp(_rasterMock.Object.GetFloatValue(rowIndex, columnIndex, bandIndex)), result.Raster.GetFloatValue(rowIndex, columnIndex, bandIndex));
                    }
                }
            }
        }
Esempio n. 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RandomColorClassification"/> class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="target">The target.</param>
 /// <param name="parameters">The parameters.</param>
 /// <exception cref="System.ArgumentNullException">
 /// The source is null.
 /// or
 /// The method requires parameters which are not specified.
 /// </exception>
 /// <exception cref="System.ArgumentException">
 /// The parameters do not contain a required parameter value.
 /// or
 /// The type of a parameter does not match the type specified by the method.
 /// or
 /// The parameter value does not satisfy the conditions of the parameter.
 /// or
 /// The specified source and result are the same objects, but the method does not support in-place operations.
 /// </exception>
 public RandomColorClassification(ISpectralGeometry source, ISpectralGeometry target, IDictionary <OperationParameter, Object> parameters)
     : base(source, target, SpectralOperationMethods.RandomColorClassification, parameters)
 {
     if (source.Raster.NumberOfBands != 1)
     {
         throw new ArgumentException("The number of bands in the source geometry is not equal to 1.", nameof(source));
     }
 }
Esempio n. 13
0
 public void SetUp()
 {
     _source = TestUtils.CreateRasterGeometryMock(new[, ] {
         { 1, 2, 2 }, { 2, 2, 2 }, { 2, 2, 3 }
     });
     _reference = TestUtils.CreateRasterGeometryMock(new[, ] {
         { 1, 1, 2 }, { 1, 2, 3 }, { 2, 3, 3 }
     });
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SequentialCouplingSegmentation" /> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <param name="parameters">The parameters.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The source is null.
        /// or
        /// The method requires parameters which are not specified.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The parameters do not contain a required parameter value.
        /// or
        /// The type of a parameter does not match the type specified by the method.
        /// or
        /// The value of a parameter is not within the expected range.
        /// or
        /// The specified source and result are the same objects, but the method does not support in-place operations.
        /// or
        /// The source geometry does not contain raster data.
        /// or
        /// The raster format of the source is not supported by the method.
        /// </exception>
        public SequentialCouplingSegmentation(ISpectralGeometry source, ISpectralGeometry target, IDictionary <OperationParameter, Object> parameters)
            : base(source, target, SpectralOperationMethods.SequentialCouplingSegmentation, parameters)
        {
            _segmentHomogeneityThreshold  = Convert.ToDouble(parameters[SpectralOperationParameters.SegmentHomogeneityThreshold]);
            _varianceThresholdBeforeMerge = Convert.ToDouble(parameters[SpectralOperationParameters.VarianceThresholdBeforeMerge]);
            _varianceThresholdAfterMerge  = Convert.ToDouble(parameters[SpectralOperationParameters.VarianceThresholdAfterMerge]);

            _varianceThresholdAfterMerge = Calculator.Pow(_varianceThresholdAfterMerge, 2);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ClassificationAreaChangeDetection" /> class.
        /// </summary>
        /// <param name="source">The input.</param>
        /// <param name="parameters">The parameters.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The source is null.
        /// or
        /// The method requires parameters which are not specified.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The source is invalid.
        /// or
        /// The parameters do not contain a required parameter value.
        /// or
        /// The type of a parameter does not match the type specified by the method.
        /// or
        /// A parameter value does not satisfy the conditions of the parameter.
        /// </exception>
        public ClassificationAreaChangeDetection(ISpectralGeometry source, IDictionary <OperationParameter, Object> parameters)
            : base(source, SpectralOperationMethods.ClassificationAreaChangeDetection, parameters)
        {
            _differencialChangeDetection = ResolveParameter <Boolean>(SpectralOperationParameters.DifferentialChangeDetection);
            _differentialAreaComputation = ResolveParameter <Boolean>(SpectralOperationParameters.DifferentialAreaComputation);

            _inputCounts     = new SortedDictionary <UInt32, Int32>();
            _referenceCounts = new SortedDictionary <UInt32, Int32>();
        }
 /// <summary>
 /// Initialize a new instance of Gabor filter.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="target">The target.</param>
 /// <param name="parameters">The parameters.</param>
 /// <exception cref="System.ArgumentNullException">The source is null.</exception>
 /// <exception cref="System.ArgumentException">
 /// The source is invalid.
 /// or
 /// The target is invalid.
 /// or
 /// The specified source and result are the same objects, but the method does not support in-place operations.
 /// or
 /// The parameters do not contain a required parameter value.
 /// or
 /// The type of a parameter does not match the type specified by the method.
 /// or
 /// A parameter value does not satisfy the conditions of the parameter.
 /// </exception>
 public GaborFilterOperation(ISpectralGeometry source, ISpectralGeometry target, IDictionary <OperationParameter, Object> parameters)
     : base(source, target, SpectralOperationMethods.GaborFilter, parameters)
 {
     AddFilter(FilterFactory.CreateGaborFilter(Convert.ToInt32(ResolveParameter(SpectralOperationParameters.FilterRadius)),
                                               Convert.ToDouble(ResolveParameter(SpectralOperationParameters.FilterStandardDeviation)),
                                               Convert.ToDouble(ResolveParameter(SpectralOperationParameters.FilterWavelength)),
                                               Convert.ToDouble(ResolveParameter(SpectralOperationParameters.FilterOrientation)),
                                               Convert.ToDouble(ResolveParameter(SpectralOperationParameters.FilterPhaseOffset)),
                                               Convert.ToDouble(ResolveParameter(SpectralOperationParameters.FilterSpatialAspectRatio))));
 }
Esempio n. 17
0
        public void ConstantBasedThresholdingClassificationExecuteTest()
        {
            IGeometryFactory factory = new GeometryFactory();

            // integer values

            IDictionary <OperationParameter, Object> parameters = new Dictionary <OperationParameter, Object>();

            parameters.Add(SpectralOperationParameters.LowerThresholdBoundary, 100);
            parameters.Add(SpectralOperationParameters.UpperThresholdBoundary, 150);

            ConstantBasedThresholdingClassification operation = new ConstantBasedThresholdingClassification(factory.CreateSpectralPolygon(_rasterMock.Object), parameters);

            operation.Execute();

            ISpectralGeometry result = operation.Result;

            Assert.AreEqual(_rasterMock.Object.NumberOfRows, result.Raster.NumberOfRows);
            Assert.AreEqual(_rasterMock.Object.NumberOfColumns, result.Raster.NumberOfColumns);
            Assert.AreEqual(_rasterMock.Object.NumberOfBands, result.Raster.NumberOfBands);
            Assert.AreEqual(_rasterMock.Object.RadiometricResolution, result.Raster.RadiometricResolution);
            Assert.AreEqual(RasterFormat.Integer, result.Raster.Format);

            for (Int32 bandIndex = 0; bandIndex < result.Raster.NumberOfBands; bandIndex++)
            {
                for (Int32 rowIndex = 0; rowIndex < result.Raster.NumberOfRows; rowIndex++)
                {
                    for (Int32 columnIndex = 0; columnIndex < result.Raster.NumberOfColumns; columnIndex++)
                    {
                        Assert.AreEqual(_rasterMock.Object.GetValue(rowIndex, columnIndex, bandIndex) >= 100 && _rasterMock.Object.GetValue(rowIndex, columnIndex, bandIndex) <= 150 ? 255 : 0, result.Raster.GetValue(rowIndex, columnIndex, bandIndex));
                    }
                }
            }


            // floating point values

            _rasterMock.Setup(raster => raster.Format).Returns(RasterFormat.Floating);

            operation = new ConstantBasedThresholdingClassification(factory.CreateSpectralPolygon(_rasterMock.Object), parameters);
            operation.Execute();

            result = operation.Result;

            for (Int32 bandIndex = 0; bandIndex < result.Raster.NumberOfBands; bandIndex++)
            {
                for (Int32 rowIndex = 0; rowIndex < result.Raster.NumberOfRows; rowIndex++)
                {
                    for (Int32 columnIndex = 0; columnIndex < result.Raster.NumberOfColumns; columnIndex++)
                    {
                        Assert.AreEqual(_rasterMock.Object.GetFloatValue(rowIndex, columnIndex, bandIndex) >= 100 && _rasterMock.Object.GetFloatValue(rowIndex, columnIndex, bandIndex) <= 150 ? 255 : 0, result.Raster.GetFloatValue(rowIndex, columnIndex, bandIndex));
                    }
                }
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IsodataClustering"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <param name="parameters">The parameters.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The source is null.
        /// or
        /// The method requires parameters which are not specified.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The parameters do not contain a required parameter value.
        /// or
        /// The type of a parameter does not match the type specified by the method.
        /// or
        /// The value of a parameter is not within the expected range.
        /// or
        /// The specified source and result are the same objects, but the method does not support in-place operations.
        /// or
        /// The source geometry does not contain raster data.
        /// or
        /// The raster format of the source is not supported by the method.
        /// </exception>
        public IsodataClustering(ISpectralGeometry source, ISpectralGeometry target, IDictionary <OperationParameter, Object> parameters)
            : base(source, target, SpectralOperationMethods.IsodataClustering, parameters)
        {
            _numberOfClusters         = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.NumberOfClusters));
            _clusterDistanceThreshold = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.ClusterDistanceThreshold));
            _clusterSizeThreshold     = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.ClusterSizeThreshold));

            if (_numberOfClusters == 0)
            {
                _numberOfClusters = (Int32)(Math.Sqrt(Source.Raster.NumberOfRows * Source.Raster.NumberOfColumns) * Source.Raster.RadiometricResolution / 8);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LandsatTopOfAtmosphereReflectanceComputation" /> class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="result">The result.</param>
 /// <param name="parameters">The parameters.</param>
 /// <exception cref="System.ArgumentNullException">
 /// The source is null.
 /// or
 /// The method requires parameters which are not specified.
 /// </exception>
 /// <exception cref="System.ArgumentException">
 /// The parameters do not contain a required parameter value.
 /// or
 /// The type of a parameter does not match the type specified by the method.
 /// or
 /// The value of a parameter is not within the expected range.
 /// or
 /// The specified source and result are the same objects, but the method does not support in-place operations.
 /// or
 /// The source does not contain required data.
 /// or
 /// The source contains invalid data.
 /// </exception>
 public LandsatTopOfAtmosphereReflectanceComputation(ISpectralGeometry source, ISpectralGeometry result, IDictionary <OperationParameter, Object> parameters)
     : base(source, result, SpectralOperationMethods.TopOfAtmospehereReflectanceComputation, parameters)
 {
     if (Source.Imaging == null)
     {
         throw new ArgumentException("The source does not contain required data.", nameof(source));
     }
     if (Source.Imaging.Device.Mission != "Landsat")
     {
         throw new ArgumentException("The source does not contain required data.", nameof(source));
     }
 }
Esempio n. 20
0
        /// <summary>
        /// Computes the image file directory of a geometry.
        /// </summary>
        /// <param name="geometry">The geometry.</param>
        /// <param name="compression">The compression.</param>
        /// <param name="format">The sample format.</param>
        /// <param name="startPosition">The starting position of the raster content within the stream.</param>
        /// <param name="endPosition">The ending position of the raster content within the stream.</param>
        /// <returns>The computed image file directory.</returns>
        protected virtual TiffImageFileDirectory ComputeImageFileDirectory(ISpectralGeometry geometry, TiffCompression compression, TiffSampleFormat format)
        {
            TiffImageFileDirectory imageFileDirectory = new TiffImageFileDirectory();

            // compute photometric interpretation
            TiffPhotometricInterpretation photometricInterpretation = ComputePhotometricInterpretation(geometry);

            // add raster properties
            AddImageTag(imageFileDirectory, TiffTag.PhotometricInterpretation, (UInt16)photometricInterpretation);
            AddImageTag(imageFileDirectory, TiffTag.Compression, (UInt16)compression);
            AddImageTag(imageFileDirectory, TiffTag.ImageLength, (UInt32)geometry.Raster.NumberOfRows);
            AddImageTag(imageFileDirectory, TiffTag.ImageWidth, (UInt32)geometry.Raster.NumberOfColumns);
            AddImageTag(imageFileDirectory, TiffTag.ResolutionUnit, (UInt16)2);
            AddImageTag(imageFileDirectory, TiffTag.XResolution, (geometry.Raster.Mapper != null) ? (Rational)geometry.Raster.Mapper.ColumnSize : (Rational)1);
            AddImageTag(imageFileDirectory, TiffTag.YResolution, (geometry.Raster.Mapper != null) ? (Rational)geometry.Raster.Mapper.RowSize : (Rational)1);
            AddImageTag(imageFileDirectory, TiffTag.RowsPerStrip, (UInt32)geometry.Raster.NumberOfRows);
            AddImageTag(imageFileDirectory, TiffTag.StripOffsets, (UInt32)0);
            AddImageTag(imageFileDirectory, TiffTag.StripByteCounts, (UInt32)0);
            AddImageTag(imageFileDirectory, TiffTag.BitsPerSample, Enumerable.Repeat((UInt16)geometry.Raster.RadiometricResolution, geometry.Raster.NumberOfBands).Cast <Object>().ToArray());
            AddImageTag(imageFileDirectory, TiffTag.SamplesPerPixel, (UInt32)geometry.Raster.NumberOfBands);
            AddImageTag(imageFileDirectory, TiffTag.SampleFormat, (UInt16)format);

            // add color palette
            if (photometricInterpretation == TiffPhotometricInterpretation.PaletteColor)
            {
                imageFileDirectory.Add(TiffTag.ColorMap, ComputeColorMap(geometry));
            }

            // add metadata
            AddImageTag(imageFileDirectory, TiffTag.DocumentName, geometry.Metadata, "GeoTIFF::DocumentName");
            AddImageTag(imageFileDirectory, TiffTag.ImageDescription, geometry.Metadata, "GeoTIFF::ImageDescription");
            AddImageTag(imageFileDirectory, TiffTag.DocumentName, geometry.Metadata, "GeoTIFF::Make");
            AddImageTag(imageFileDirectory, TiffTag.Make, geometry.Metadata, "GeoTIFF::DocumentName");
            AddImageTag(imageFileDirectory, TiffTag.Model, geometry.Metadata, "GeoTIFF::Model");
            AddImageTag(imageFileDirectory, TiffTag.PageName, geometry.Metadata, "GeoTIFF::PageName");
            AddImageTag(imageFileDirectory, TiffTag.Artist, geometry.Metadata, "GeoTIFF::Artist");
            AddImageTag(imageFileDirectory, TiffTag.HostComputer, geometry.Metadata, "GeoTIFF::HostComputer");
            AddImageTag(imageFileDirectory, TiffTag.Copyright, geometry.Metadata, "GeoTIFF::Copyright");
            AddImageTag(imageFileDirectory, TiffTag.Software, "AEGIS Geospatial Framework");
            AddImageTag(imageFileDirectory, TiffTag.DateTime, DateTime.Now.ToString(CultureInfo.InvariantCulture.DateTimeFormat));

            Dictionary <String, Object> attributes = geometry.Metadata.Where(attribute => !attribute.Key.Contains("GeoTIFF")).ToDictionary(attribute => attribute.Key, attribute => attribute.Value);

            if (geometry.Metadata.Count(attribute => !attribute.Key.Contains("GeoTIFF")) > 0)
            {
                imageFileDirectory.Add(TiffTag.AegisAttributes, new Object[] { JsonConvert.SerializeObject(attributes, Formatting.None, new JsonSerializerSettings {
                        TypeNameHandling = TypeNameHandling.All
                    }) });
            }

            return(imageFileDirectory);
        }
Esempio n. 21
0
        /// <summary>
        /// Computes the photometric interpretation.
        /// </summary>
        /// <param name="geometry">The geometry.</param>
        /// <returns>The photometric interpretation of the geometry.</returns>
        private TiffPhotometricInterpretation ComputePhotometricInterpretation(ISpectralGeometry geometry)
        {
            if (geometry.Presentation == null)
            {
                if (geometry.Raster.NumberOfBands == 3)
                {
                    return(TiffPhotometricInterpretation.RGB);
                }

                return(TiffPhotometricInterpretation.BlackIsZero);
            }

            switch (geometry.Presentation.Model)
            {
            case RasterPresentationModel.Grayscale:
                return(TiffPhotometricInterpretation.BlackIsZero);

            case RasterPresentationModel.InvertedGrayscale:
                return(TiffPhotometricInterpretation.WhiteIsZero);

            case RasterPresentationModel.Transparency:
                return(TiffPhotometricInterpretation.TransparencyMask);

            case RasterPresentationModel.TrueColor:
            case RasterPresentationModel.FalseColor:
                switch (geometry.Presentation.ColorSpace)
                {
                case RasterColorSpace.RGB:
                    return(TiffPhotometricInterpretation.RGB);

                case RasterColorSpace.CIELab:
                    return(TiffPhotometricInterpretation.CIELab);

                case RasterColorSpace.CMYK:
                    return(TiffPhotometricInterpretation.CMYK);

                case RasterColorSpace.YCbCr:
                    return(TiffPhotometricInterpretation.YCbCr);

                default:
                    throw new InvalidDataException("The specified presentation is not supported.");
                }

            case RasterPresentationModel.PseudoColor:
                return(TiffPhotometricInterpretation.PaletteColor);

            default:
                throw new InvalidDataException("The specified presentation is not supported.");
            }
            // TODO: process other presentations
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="KMeansClustering"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <param name="parameters">The parameters.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The source is null.
        /// or
        /// The method is null.
        /// or
        /// The method requires parameters which are not specified.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The parameters do not contain a required parameter value.
        /// or
        /// The type of a parameter does not match the type specified by the method.
        /// or
        /// The value of a parameter is not within the expected range.
        /// or
        /// The specified source and result are the same objects, but the method does not support in-place operations.
        /// or
        /// The source geometry does not contain raster data.
        /// or
        /// The raster format of the source is not supported by the method.
        /// </exception>
        public KMeansClustering(ISpectralGeometry source, ISpectralGeometry target, IDictionary<OperationParameter, Object> parameters)
            : base(source, target, SpectralOperationMethods.KMeansClustering, parameters)
        {
            _numberOfClusters = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.NumberOfClusters));
            _maximumIterations = Convert.ToInt32(ResolveParameter(CommonOperationParameters.NumberOfIterations));

            if (_numberOfClusters == 0)
                _numberOfClusters = (Int32)(Math.Sqrt(Source.Raster.NumberOfRows * Source.Raster.NumberOfColumns) * Source.Raster.RadiometricResolution / 8);

            if (_maximumIterations == 0)
                _maximumIterations = _numberOfClusters;

            _maximumDifference = RasterAlgorithms.RadiometricResolutionMax(Source.Raster) / Source.Raster.NumberOfRows * Source.Raster.NumberOfColumns;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SpectralClustering" /> class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="target">The target.</param>
 /// <param name="method">The method.</param>
 /// <param name="parameters">The parameters.</param>
 /// <exception cref="System.ArgumentNullException">
 /// The source is null.
 /// or
 /// The method is null.
 /// or
 /// The method requires parameters which are not specified.
 /// </exception>
 /// <exception cref="System.ArgumentException">
 /// The parameters do not contain a required parameter value.
 /// or
 /// The type of a parameter does not match the type specified by the method.
 /// or
 /// The value of a parameter is not within the expected range.
 /// or
 /// The specified source and result are the same objects, but the method does not support in-place operations.
 /// or
 /// The source geometry does not contain raster data.
 /// or
 /// The raster format of the source is not supported by the method.
 /// </exception>
 protected SpectralClustering(ISpectralGeometry source, ISpectralGeometry target, SpectralOperationMethod method, IDictionary <OperationParameter, Object> parameters)
     : base(source, target, method, parameters)
 {
     if (IsProvidedParameter(SpectralOperationParameters.ClusterCenterDistanceAlgorithm))
     {
         _clusterCenterDistance = ResolveParameter <SpectralDistance>(SpectralOperationParameters.ClusterCenterDistanceAlgorithm);
     }
     else if (IsProvidedParameter(SpectralOperationParameters.ClusterCenterDistanceType))
     {
         _clusterCenterDistance = (SpectralDistance)Activator.CreateInstance(ResolveParameter <Type>(SpectralOperationParameters.ClusterCenterDistanceType));
     }
     else
     {
         _clusterCenterDistance = _distance;
     }
 }
Esempio n. 24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConstantBasedThresholdingClassification" /> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <param name="parameters">The parameters.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The source is null.
        /// or
        /// The method requires parameters which are not specified.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The parameters do not contain a required parameter value.
        /// or
        /// The type of a parameter does not match the type specified by the method.
        /// or
        /// The value of a parameter is not within the expected range.
        /// or
        /// The specified source and result are the same objects, but the method does not support in-place operations.
        /// </exception>
        public ConstantBasedThresholdingClassification(ISpectralGeometry source, ISpectralGeometry target, IDictionary <OperationParameter, Object> parameters)
            : base(source, target, SpectralOperationMethods.ConstantBasedThresholdClassification, parameters)
        {
            for (Int32 bandIndex = 0; bandIndex < Source.Raster.NumberOfBands; bandIndex++)
            {
                _lowerThresholdValues[bandIndex] = Convert.ToDouble(ResolveParameter(SpectralOperationParameters.LowerThresholdBoundary));
                _upperThresholdValues[bandIndex] = Convert.ToDouble(ResolveParameter(SpectralOperationParameters.UpperThresholdBoundary));

                if (_lowerThresholdValues[bandIndex] > _upperThresholdValues[bandIndex])
                {
                    Double temp = _upperThresholdValues[bandIndex];
                    _upperThresholdValues[bandIndex] = _lowerThresholdValues[bandIndex];
                    _lowerThresholdValues[bandIndex] = temp;
                }
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LandsatTemperatureExtraction"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="result">The result.</param>
        /// <param name="parameters">The parameters.</param>
        /// <exception cref="System.ArgumentException">
        /// The source does not contain required data.
        /// or
        /// The source does not contain required data.
        /// or
        /// The number of bands in the source is less than required.
        /// </exception>
        public LandsatTemperatureExtraction(ISpectralGeometry source, ISpectralGeometry result, IDictionary <OperationParameter, Object> parameters)
            : base(source, result, SpectralOperationMethods.TemperatureExtraction, parameters)
        {
            if (Source.Imaging == null)
            {
                throw new ArgumentException("The source does not contain required data.", "source");
            }
            if (Source.Imaging.Device.Mission != "Landsat" || (Source.Imaging.Device.MissionNumber != 7 && Source.Imaging.Device.MissionNumber != 8))
            {
                throw new ArgumentException("The source does not contain required data.", "source");
            }

            if (IsProvidedParameter(SpectralOperationParameters.IndexOfLongWavelengthInfraredBand))
            {
                _indexOfThermalBand = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.IndexOfLongWavelengthInfraredBand));
            }
            else
            {
                RasterImagingBand thermalBand = Source.Imaging.Bands.FirstOrDefault(band => band.SpectralDomain == SpectralDomain.LongWavelengthInfrared);
                _indexOfThermalBand = Source.Imaging.Bands.IndexOf(thermalBand);
            }

            if (Source.Raster.NumberOfBands <= _indexOfThermalBand)
            {
                throw new ArgumentException("The number of bands in the source is less than required.", "source");
            }

            switch (Source.Imaging.Device.MissionNumber)
            {
            case 5:
                _calibrationConstant1 = 607.76;
                _calibrationConstant2 = 1260.56;
                break;

            case 7:
                _calibrationConstant1 = 666.09;
                _calibrationConstant2 = 1282.71;
                break;

            case 8:
                _calibrationConstant1 = Convert.ToDouble(Source.Imaging["K1_CONSTANT_BAND_11"], CultureInfo.InvariantCulture);
                _calibrationConstant2 = Convert.ToDouble(Source.Imaging["K2_CONSTANT_BAND_11"], CultureInfo.InvariantCulture);
                break;
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CarotenoidReflectanceIndex2Computation" /> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="result">The result.</param>
        /// <param name="parameters">The parameters.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The source is null.
        /// or
        /// The method requires parameters which are not specified.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The parameters do not contain a required parameter value.
        /// or
        /// The type of a parameter does not match the type specified by the method.
        /// or
        /// The value of a parameter is not within the expected range.
        /// or
        /// The specified source and result are the same objects, but the method does not support in-place operations.
        /// or
        /// The source does not contain required data.
        /// or
        /// The source contains invalid data.
        /// </exception>
        public CarotenoidReflectanceIndex2Computation(ISpectralGeometry source, ISpectralGeometry result, IDictionary <OperationParameter, Object> parameters)
            : base(source, result, SpectralOperationMethods.CarotenoidReflectanceIndex2Computation, parameters)
        {
            try
            {
                _indexOf510nmBand = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.IndexOf510nmBand, Source.Imaging.SpectralRanges.IndexOf(range => range.WavelengthMinimum <= 510e-9 && range.WavelengthMaximum >= 510e-9)));
                _indexOf700nmBand = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.IndexOf700nmBand, Source.Imaging.SpectralRanges.IndexOf(range => range.WavelengthMinimum <= 700e-9 && range.WavelengthMaximum >= 700e-9)));
            }
            catch
            {
                throw new ArgumentException("The source does not contain required data.", "source");
            }

            if (_indexOf510nmBand < 0 || _indexOf510nmBand >= Source.Raster.NumberOfBands ||
                _indexOf700nmBand < 0 || _indexOf700nmBand >= Source.Raster.NumberOfBands)
            {
                throw new ArgumentException("The source contains invalid data.", "source");
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VogelmannRedEdgeIndex1Computation" /> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="result">The result.</param>
        /// <param name="parameters">The parameters.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The source is null.
        /// or
        /// The method requires parameters which are not specified.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The parameters do not contain a required parameter value.
        /// or
        /// The type of a parameter does not match the type specified by the method.
        /// or
        /// The value of a parameter is not within the expected range.
        /// or
        /// The specified source and result are the same objects, but the method does not support in-place operations.
        /// or
        /// The source does not contain required data.
        /// or
        /// The source contains invalid data.
        /// </exception>
        public SoilAdjustedVegetationIndexComputation(ISpectralGeometry source, ISpectralGeometry result, IDictionary <OperationParameter, Object> parameters)
            : base(source, result, SpectralOperationMethods.SoilAdjustedVegetationIndexComputation, parameters)
        {
            try
            {
                _indexOfNearInfraredBand = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.IndexOfNearInfraredBand, Source.Imaging.SpectralDomains.IndexOf(SpectralDomain.NearInfrared)));
                _indexOfRedBand          = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.IndexOfRedBand, Source.Imaging.SpectralDomains.IndexOf(SpectralDomain.Red)));
            }
            catch
            {
                throw new ArgumentException("The source does not contain required data.", "source");
            }

            if (_indexOfNearInfraredBand < 0 || _indexOfNearInfraredBand >= Source.Raster.NumberOfBands ||
                _indexOfRedBand < 0 || _indexOfRedBand >= Source.Raster.NumberOfBands)
            {
                throw new ArgumentException("The source contains invalid data.", "source");
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NormalizedDifferenceInfraredIndexComputation" /> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="result">The result.</param>
        /// <param name="parameters">The parameters.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The source is null.
        /// or
        /// The method requires parameters which are not specified.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The parameters do not contain a required parameter value.
        /// or
        /// The type of a parameter does not match the type specified by the method.
        /// or
        /// The value of a parameter is not within the expected range.
        /// or
        /// The specified source and result are the same objects, but the method does not support in-place operations.
        /// or
        /// The source does not contain required data.
        /// or
        /// The source contains invalid data.
        /// </exception>
        public NormalizedDifferenceInfraredIndexComputation(ISpectralGeometry source, ISpectralGeometry result, IDictionary <OperationParameter, Object> parameters)
            : base(source, result, SpectralOperationMethods.NormalizedDifferenceInfraredIndexComputation, parameters)
        {
            try
            {
                _indexOf819nmBand  = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.IndexOf819nmBand, Source.Imaging.SpectralRanges.IndexOf(range => range.WavelengthMinimum <= 819e-9 && range.WavelengthMaximum >= 819e-9)));
                _indexOf1649nmBand = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.IndexOf1649nmBand, Source.Imaging.SpectralRanges.IndexOf(range => range.WavelengthMinimum <= 1649e-9 && range.WavelengthMaximum >= 1649e-9)));
            }
            catch
            {
                throw new ArgumentException("The source does not contain required data.", "source");
            }

            if (_indexOf819nmBand < 0 || _indexOf819nmBand >= Source.Raster.NumberOfBands ||
                _indexOf1649nmBand < 0 || _indexOf1649nmBand >= Source.Raster.NumberOfBands)
            {
                throw new ArgumentException("The source contains invalid data.", "source");
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Computes the color map.
        /// </summary>
        /// <param name="geometry">The geometry.</param>
        /// <returns>The computed color map.</returns>
        private Object[] ComputeColorMap(ISpectralGeometry geometry)
        {
            if (geometry.Presentation.ColorPalette == null)
            {
                return(null);
            }

            Int32 valueCount = (Int32)Math.Pow(2, geometry.Raster.RadiometricResolution);

            Object[] colorMap = Enumerable.Repeat((UInt16)0, 3 * valueCount).Cast <Object>().ToArray();

            foreach (Int32 entryIndex in geometry.Presentation.ColorPalette.Keys)
            {
                colorMap[entryIndex] = (UInt16)geometry.Presentation.ColorPalette[entryIndex][0];
                colorMap[valueCount + entryIndex]     = (UInt16)geometry.Presentation.ColorPalette[entryIndex][1];
                colorMap[2 * valueCount + entryIndex] = (UInt16)geometry.Presentation.ColorPalette[entryIndex][2];
            }

            return(colorMap);
        }
Esempio n. 30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StructureInsensitivePigmentIndexComputation" /> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="result">The result.</param>
        /// <param name="parameters">The parameters.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The source is null.
        /// or
        /// The method requires parameters which are not specified.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The parameters do not contain a required parameter value.
        /// or
        /// The type of a parameter does not match the type specified by the method.
        /// or
        /// The value of a parameter is not within the expected range.
        /// or
        /// The specified source and result are the same objects, but the method does not support in-place operations.
        /// or
        /// The source does not contain required data.
        /// or
        /// The source contains invalid data.
        /// </exception>
        public StructureInsensitivePigmentIndexComputation(ISpectralGeometry source, ISpectralGeometry result, IDictionary <OperationParameter, Object> parameters)
            : base(source, result, SpectralOperationMethods.StructureInsensitivePigmentIndexComputation, parameters)
        {
            try
            {
                _indexOf445nmBand = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.IndexOf445nmBand, Source.Imaging.SpectralRanges.IndexOf(range => range.WavelengthMinimum <= 445e-9 && range.WavelengthMaximum >= 445e-9)));
                _indexOf680nmBand = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.IndexOf680nmBand, Source.Imaging.SpectralRanges.IndexOf(range => range.WavelengthMinimum <= 680e-9 && range.WavelengthMaximum >= 680e-9)));
                _indexOf800nmBand = Convert.ToInt32(ResolveParameter(SpectralOperationParameters.IndexOf800nmBand, Source.Imaging.SpectralRanges.IndexOf(range => range.WavelengthMinimum <= 800e-9 && range.WavelengthMaximum >= 800e-9)));
            }
            catch
            {
                throw new ArgumentException("The source does not contain required data.", "source");
            }

            if (_indexOf445nmBand < 0 || _indexOf445nmBand >= Source.Raster.NumberOfBands ||
                _indexOf680nmBand < 0 || _indexOf680nmBand >= Source.Raster.NumberOfBands ||
                _indexOf800nmBand < 0 || _indexOf800nmBand >= Source.Raster.NumberOfBands)
            {
                throw new ArgumentException("The source contains invalid data.", "source");
            }
        }