From d6f9e6b350e10cb5a848113a2a33f69aefa210d9 Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@c-s.fr>
Date: Thu, 7 Dec 2006 17:06:53 +0000
Subject: [PATCH] =?UTF-8?q?-=20Modification=20de=20la=20classe=20ImageToIm?=
 =?UTF-8?q?ageRCC8Calculator=20pour=20int=C3=A9grer=20le=20support=20de=20?=
 =?UTF-8?q?2=20m=5FInsideValue=20diff=C3=A9rents=20(1=20pour=20chaque=20im?=
 =?UTF-8?q?age=20en=20entr=C3=A9e).?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../otbImageToImageRCC8Calculator.h           | 23 ++++++++++---------
 .../otbImageToImageRCC8Calculator.txx         | 19 +++++++--------
 2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/Code/SpatialReasoning/otbImageToImageRCC8Calculator.h b/Code/SpatialReasoning/otbImageToImageRCC8Calculator.h
index f264c273b0..bed884b771 100644
--- a/Code/SpatialReasoning/otbImageToImageRCC8Calculator.h
+++ b/Code/SpatialReasoning/otbImageToImageRCC8Calculator.h
@@ -98,12 +98,12 @@ public:
    * \return The second input image.
    */
   ImageType * GetInput2(void);
-  /** Set/Get the inside value of the regions */
-  itkSetMacro(InsideValue,PixelType);
-  itkGetMacro(InsideValue,PixelType);
-  /** Set/Get the outside value of the regions */
-  itkSetMacro(OutsideValue,PixelType);
-  itkGetMacro(OutsideValue,PixelType);
+  /** Set/Get the inside value of the region of image 1*/
+  itkSetMacro(InsideValue1,PixelType);
+  itkGetMacro(InsideValue1,PixelType);
+  /** Set/Get the inside value of the region of image 2*/
+  itkSetMacro(InsideValue2,PixelType);
+  itkGetMacro(InsideValue2,PixelType);
 
  protected:
   /** Constructor */
@@ -164,9 +164,10 @@ public:
    * Compute a bool image of minimal ROI size, surrounded by a false padding, and corresponding
    * to the input image.
    * \param image The image to convert.
+   * \param insideValue The inside value.
    * \return The converted image
    */
-  BoolImagePointerType ConvertToBoolImage(ImagePointerType image); 
+  BoolImagePointerType ConvertToBoolImage(ImagePointerType image, PixelType insideValue); 
   /** Main computation method */
   void GenerateData(void);
   /** PrintSelf method */
@@ -181,10 +182,10 @@ public:
   bool m_Level1APrioriKnowledge;
   /**  Decision tree Level 3 A priori knowledge */
   bool m_Level3APrioriKnowledge;
-  /** Inside value */
-  PixelType m_InsideValue;
-  /** Outside value */
-  PixelType m_OutsideValue;
+  /** Inside value 1 */
+  PixelType m_InsideValue1;
+  /** Inside value 2 */
+  PixelType m_InsideValue2;
   /** Internal bool image representation*/
   BoolImagePointerType m_BoolImage1;
   BoolImagePointerType m_BoolImage2;
diff --git a/Code/SpatialReasoning/otbImageToImageRCC8Calculator.txx b/Code/SpatialReasoning/otbImageToImageRCC8Calculator.txx
index 1abe83089c..3fcb6deade 100644
--- a/Code/SpatialReasoning/otbImageToImageRCC8Calculator.txx
+++ b/Code/SpatialReasoning/otbImageToImageRCC8Calculator.txx
@@ -39,8 +39,8 @@ namespace otb
   ::ImageToImageRCC8Calculator()
   {
     m_Value        = OTB_RCC8_DC;
-    m_InsideValue  = static_cast<PixelType>(255);
-    m_OutsideValue = static_cast<PixelType>(0);
+    m_InsideValue1  = static_cast<PixelType>(255);
+    m_InsideValue2  = static_cast<PixelType>(255);
     m_Level1APrioriKnowledge=false;
     m_Level3APrioriKnowledge=false;
     this->SetNumberOfRequiredInputs(2);
@@ -121,13 +121,13 @@ namespace otb
     typename RegionCalculator::Pointer rc =RegionCalculator::New();
     rc->SetInput(image1);
     rc->SetPad(2);
-    rc->SetInsideValue(this->GetInsideValue());
+    rc->SetInsideValue(this->GetInsideValue1());
     rc->Update();
     region1=rc->GetRegion();
     rc=RegionCalculator::New();
     rc->SetInput(image2);
     rc->SetPad(2);
-    rc->SetInsideValue(this->GetInsideValue());
+    rc->SetInsideValue(this->GetInsideValue2());
     rc->Update();
     region2=rc->GetRegion();
     typename ImageType::SizeType size;
@@ -149,13 +149,14 @@ namespace otb
  * Compute a bool image of minimal ROI size, surrounded by a false padding, and corresponding
  * to the input image.
  * \param image The image to convert.
+ * \param insideValue The inside value.
  * \return The converted image
  */
- template<class TInputImage>
+template<class TInputImage>
 typename ImageToImageRCC8Calculator<TInputImage>
 ::BoolImagePointerType 
 ImageToImageRCC8Calculator<TInputImage>
-::ConvertToBoolImage(ImagePointerType image)
+::ConvertToBoolImage(ImagePointerType image, PixelType insideValue)
 {
   typedef itk::ImageRegionConstIterator<ImageType> ConstIterator;
   typedef itk::ImageRegionIterator<BoolImageType> Iterator;
@@ -179,7 +180,7 @@ ImageToImageRCC8Calculator<TInputImage>
   outputIt.GoToBegin();
   while(!inputIt.IsAtEnd()&&!outputIt.IsAtEnd())
     {
-      outputIt.Set(inputIt.Get()==m_InsideValue);
+      outputIt.Set(inputIt.Get()==insideValue);
       ++inputIt;
       ++outputIt;
     }
@@ -399,8 +400,8 @@ ImageToImageRCC8Calculator<TInputImage>
       {
 	/// else each input images is cast to boolean type and reduced to
 	// the minimal region
-	m_BoolImage1=ConvertToBoolImage(this->GetInput1());
-	m_BoolImage2=ConvertToBoolImage(this->GetInput2());
+	m_BoolImage1=ConvertToBoolImage(this->GetInput1(),m_InsideValue1);
+	m_BoolImage2=ConvertToBoolImage(this->GetInput2(),m_InsideValue2);
 	// otbMsgDebugMacro(<<"RCC8Calculator->GenerateData(): Bool images computed: "<<m_BoolImage1->GetLargestPossibleRegion().GetSize());
 	/// Then the boolean which will be used to determine the relation
 	/// are declared
-- 
GitLab