From 96a83ac6a6ab9e5d5d192bc5b4e3a24eb72ea70d Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@c-s.fr> Date: Tue, 23 Oct 2007 11:57:16 +0000 Subject: [PATCH] =?UTF-8?q?Modifs=20pour=20prendre=20l'ext=C3=A9rieur=20de?= =?UTF-8?q?=20la=20forme=20(d=C3=A9calage=20de=200.5=20par=20rapport=20au?= =?UTF-8?q?=20centre=20du=20pixel)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../otbImageToEdgePathFilter.h | 3 +- .../otbImageToEdgePathFilter.txx | 29 +++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Code/FeatureExtraction/otbImageToEdgePathFilter.h b/Code/FeatureExtraction/otbImageToEdgePathFilter.h index 357e5f6617..75432fc35d 100755 --- a/Code/FeatureExtraction/otbImageToEdgePathFilter.h +++ b/Code/FeatureExtraction/otbImageToEdgePathFilter.h @@ -70,7 +70,8 @@ public: typedef typename Superclass::InputImagePointerType InputImagePointerType; typedef typename Superclass::OutputPathType OutputPathType; typedef typename Superclass::OutputPathPointerType OutputPathPointerType; - + typedef typename OutputPathType::ContinuousIndexType ContinuousIndexType; + typedef typename InputImageType::PixelType PixelType; /** Set and Get foreground value */ diff --git a/Code/FeatureExtraction/otbImageToEdgePathFilter.txx b/Code/FeatureExtraction/otbImageToEdgePathFilter.txx index 4f0e335c2b..62071e8bad 100755 --- a/Code/FeatureExtraction/otbImageToEdgePathFilter.txx +++ b/Code/FeatureExtraction/otbImageToEdgePathFilter.txx @@ -83,7 +83,7 @@ ImageToEdgePathFilter<TInputImage, TOutputPath> } } typename InputImageType::IndexType start = linIter.GetIndex(); - outputPath->AddVertex(start); + // outputPath->AddVertex(start); // Neighborhood definition typename IteratorType::RadiusType radius; @@ -120,6 +120,20 @@ ImageToEdgePathFilter<TInputImage, TOutputPath> rotation.push_back(RIGHTUP); // Set up the iterator it.SetLocation(start); + + + ContinuousIndexType newVertex = it.GetIndex(CENTER); + if(it.GetPixel(RIGHT)==m_ForegroundValue) + newVertex[0]-=0.5; + if(it.GetPixel(LEFT)==m_ForegroundValue) + newVertex[0]+=0.5; + if(it.GetPixel(UP)==m_ForegroundValue) + newVertex[1]+=0.5; + if(it.GetPixel(DOWN)==m_ForegroundValue) + newVertex[1]-=0.5; + outputPath->AddVertex(newVertex); + + otbMsgDebugMacro(<<"START: "<<start); // stopping flag flag = true; @@ -157,8 +171,17 @@ ImageToEdgePathFilter<TInputImage, TOutputPath> // Update the output path it+=rotation[move%8]; nextStart=(move+5)%8; - outputPath->AddVertex(it.GetIndex(CENTER)); - otbMsgDebugMacro(<<it.GetIndex(CENTER)); + newVertex = it.GetIndex(CENTER); + if(it.GetPixel(RIGHT)==m_ForegroundValue) + newVertex[0]-=0.5; + if(it.GetPixel(LEFT)==m_ForegroundValue) + newVertex[0]+=0.5; + if(it.GetPixel(UP)==m_ForegroundValue) + newVertex[1]+=0.5; + if(it.GetPixel(DOWN)==m_ForegroundValue) + newVertex[1]-=0.5; + outputPath->AddVertex(newVertex); + otbMsgDebugMacro(<<newVertex); // If we came back to our start point after a sufficient number of moves if((it.GetIndex(CENTER)==start)&&(nbMove>=2)) { -- GitLab