Skip to content
Snippets Groups Projects
Commit 96a83ac6 authored by Julien Michel's avatar Julien Michel
Browse files

Modifs pour prendre l'extérieur de la forme (décalage de 0.5 par rapport au centre du pixel)

parent cb57b955
Branches
Tags
No related merge requests found
...@@ -70,7 +70,8 @@ public: ...@@ -70,7 +70,8 @@ public:
typedef typename Superclass::InputImagePointerType InputImagePointerType; typedef typename Superclass::InputImagePointerType InputImagePointerType;
typedef typename Superclass::OutputPathType OutputPathType; typedef typename Superclass::OutputPathType OutputPathType;
typedef typename Superclass::OutputPathPointerType OutputPathPointerType; typedef typename Superclass::OutputPathPointerType OutputPathPointerType;
typedef typename OutputPathType::ContinuousIndexType ContinuousIndexType;
typedef typename InputImageType::PixelType PixelType; typedef typename InputImageType::PixelType PixelType;
/** Set and Get foreground value */ /** Set and Get foreground value */
......
...@@ -83,7 +83,7 @@ ImageToEdgePathFilter<TInputImage, TOutputPath> ...@@ -83,7 +83,7 @@ ImageToEdgePathFilter<TInputImage, TOutputPath>
} }
} }
typename InputImageType::IndexType start = linIter.GetIndex(); typename InputImageType::IndexType start = linIter.GetIndex();
outputPath->AddVertex(start); // outputPath->AddVertex(start);
// Neighborhood definition // Neighborhood definition
typename IteratorType::RadiusType radius; typename IteratorType::RadiusType radius;
...@@ -120,6 +120,20 @@ ImageToEdgePathFilter<TInputImage, TOutputPath> ...@@ -120,6 +120,20 @@ ImageToEdgePathFilter<TInputImage, TOutputPath>
rotation.push_back(RIGHTUP); rotation.push_back(RIGHTUP);
// Set up the iterator // Set up the iterator
it.SetLocation(start); 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); otbMsgDebugMacro(<<"START: "<<start);
// stopping flag // stopping flag
flag = true; flag = true;
...@@ -157,8 +171,17 @@ ImageToEdgePathFilter<TInputImage, TOutputPath> ...@@ -157,8 +171,17 @@ ImageToEdgePathFilter<TInputImage, TOutputPath>
// Update the output path // Update the output path
it+=rotation[move%8]; it+=rotation[move%8];
nextStart=(move+5)%8; nextStart=(move+5)%8;
outputPath->AddVertex(it.GetIndex(CENTER)); newVertex = it.GetIndex(CENTER);
otbMsgDebugMacro(<<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 we came back to our start point after a sufficient number of moves
if((it.GetIndex(CENTER)==start)&&(nbMove>=2)) if((it.GetIndex(CENTER)==start)&&(nbMove>=2))
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment