From 2cceab98fde5646796b025e365386236444a488c Mon Sep 17 00:00:00 2001
From: Julien Malik <julien.malik@c-s.fr>
Date: Thu, 3 Nov 2011 18:12:41 +0100
Subject: [PATCH] ENH: add MaximumAutocorrelationFactor applciation

---
 Applications/ChangeDetection/CMakeLists.txt   |  7 ++
 .../otbMaximumAutocorrelationFactor.cxx       | 84 +++++++++++++++++++
 .../ChangeDetection/CMakeLists.txt            | 15 ++++
 3 files changed, 106 insertions(+)
 create mode 100644 Applications/ChangeDetection/otbMaximumAutocorrelationFactor.cxx

diff --git a/Applications/ChangeDetection/CMakeLists.txt b/Applications/ChangeDetection/CMakeLists.txt
index 294e63605e..a5d8e3b67e 100644
--- a/Applications/ChangeDetection/CMakeLists.txt
+++ b/Applications/ChangeDetection/CMakeLists.txt
@@ -2,3 +2,10 @@
 OTB_CREATE_APPLICATION(NAME MultivariateAlterationDetector
                        SOURCES otbMultivariateAlterationDetector.cxx
                        LINK_LIBRARIES OTBIO;OTBCommon;OTBBasicFilters)
+
+
+OTB_CREATE_APPLICATION(NAME MaximumAutocorrelationFactor
+                       SOURCES otbMaximumAutocorrelationFactor.cxx
+                       LINK_LIBRARIES OTBIO;OTBCommon;OTBBasicFilters)
+
+
diff --git a/Applications/ChangeDetection/otbMaximumAutocorrelationFactor.cxx b/Applications/ChangeDetection/otbMaximumAutocorrelationFactor.cxx
new file mode 100644
index 0000000000..0b42e40426
--- /dev/null
+++ b/Applications/ChangeDetection/otbMaximumAutocorrelationFactor.cxx
@@ -0,0 +1,84 @@
+/*=========================================================================
+
+  Program:   ORFEO Toolbox
+  Language:  C++
+  Date:      $Date$
+  Version:   $Revision$
+
+
+  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
+  See OTBCopyright.txt for details.
+
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+
+=========================================================================*/
+#include "otbWrapperApplication.h"
+#include "otbWrapperApplicationFactory.h"
+
+#include "otbMaximumAutocorrelationFactorImageFilter.h"
+
+namespace otb
+{
+namespace Wrapper
+{
+
+class MaximumAutocorrelationFactor: public Application
+{
+public:
+  /** Standard class typedefs. */
+  typedef MaximumAutocorrelationFactor          Self;
+  typedef Application                   Superclass;
+  typedef itk::SmartPointer<Self>       Pointer;
+  typedef itk::SmartPointer<const Self> ConstPointer;
+
+  /** Standard macro */
+  itkNewMacro(Self);
+
+  itkTypeMacro(MaximumAutocorrelationFactor, otb::Wrapper::Application);
+
+private:
+  MaximumAutocorrelationFactor()
+  {
+    SetName("MaximumAutocorrelationFactor");
+    SetDescription("Maximum autocorrelation factor");
+  }
+
+  virtual ~MaximumAutocorrelationFactor()
+  {
+  }
+
+  void DoCreateParameters()
+  {
+    AddParameter(ParameterType_InputImage,  "in", "Input Image 1");
+    AddParameter(ParameterType_OutputImage, "out", "Change Map");
+  }
+
+  void DoUpdateParameters()
+  {
+  }
+
+  void DoExecute()
+  {
+    typedef otb::MaximumAutocorrelationFactorImageFilter<
+        FloatVectorImageType,
+        FloatVectorImageType> MAFFilterType;
+
+    MAFFilterType::Pointer changeFilter = MAFFilterType::New();
+
+    changeFilter->SetInput(GetParameterImage("in"));
+    m_Ref = changeFilter;
+
+    SetParameterOutputImage("out", changeFilter->GetOutput());
+  }
+
+  itk::LightObject::Pointer m_Ref;
+
+};
+
+}
+}
+
+OTB_APPLICATION_EXPORT(otb::Wrapper::MaximumAutocorrelationFactor)
diff --git a/Testing/Applications/ChangeDetection/CMakeLists.txt b/Testing/Applications/ChangeDetection/CMakeLists.txt
index cd55b42f23..f32e6708b2 100644
--- a/Testing/Applications/ChangeDetection/CMakeLists.txt
+++ b/Testing/Applications/ChangeDetection/CMakeLists.txt
@@ -12,3 +12,18 @@ add_test(NAME apTvChMultivariateAlterationDetector
                  --in1 ${INPUTDATA}/Spot5-Gloucester-before.tif
                  --in2 ${INPUTDATA}/Spot5-Gloucester-after.tif
                  --out ${TEMP}/apTvChMultivariateAlterationDetectorSameNbBands.tif )
+
+
+#--- MaximumAutocorrelationFactor ---#
+
+add_test(NAME apTvChMaximumAutocorrelationFactor
+         COMMAND otbTestDriver
+               --compare-image 0.025
+                   ${BASELINE}/bfTvMaximumAutocorrelationFactorImageFilterOutput.tif
+                   ${TEMP}/apTvChMaximumAutocorrelationFactor.tif
+                 Execute $<TARGET_FILE:otbApplicationLauncherCommandLine>
+                 MaximumAutocorrelationFactor
+                 $<TARGET_FILE_DIR:otbapp_MaximumAutocorrelationFactor>
+                 --in ${INPUTDATA}/cupriteSubHsi.tif
+                 --out ${TEMP}/apTvChMaximumAutocorrelationFactor.tif )
+
-- 
GitLab