diff --git a/Code/FeatureExtraction/otbImageToEdgePathFilter.h b/Code/FeatureExtraction/otbImageToEdgePathFilter.h index 357e5f661735d630d5a3ffdada248d57123b73d0..75432fc35d7f3325d0cd560e21cffd27c22e9361 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 4f0e335c2bc10ac31c2fa60e073b898da7b739ba..62071e8bad8f77bd7c8fdb7e778bd3f5ae02beff 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)) {