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

MAJ DrawPathListFilter pour utiliser les otb::PolyLineImageIterator.

parent 6636c909
Branches
Tags
No related merge requests found
......@@ -28,7 +28,7 @@ namespace otb
* \brief This class can be used to draw a list of path on an image.
*
* This filter first copy the input image to the output, with default casting operators.
* It then uses itk::LineIterator to draw each segment of each PolyLine. This iterator uses
* It then uses the otb::PolyLineImageIterator to draw each polyline. This iterator uses
* the general Bresenham algorithm known to be efficient in segment drawing.
*
* If the UsePathInternalValue is toggled, the filter check if the metadata dictionnary of the input path has a "Value" key.
......
......@@ -23,7 +23,7 @@
#include "itkImageRegionIterator.h"
#include "itkImageRegionConstIterator.h"
#include "itkLineIterator.h"
#include "otbPolyLineImageIterator.h"
#include "itkMetaDataObject.h"
namespace otb
......@@ -80,9 +80,7 @@ DrawPathListFilter<TInputImage,TInputPath,TOutputImage>
typedef itk::ImageRegionIterator<OutputImageType> OutputIteratorType;
typedef itk::ImageRegionConstIterator<InputImageType> InputIteratorType;
typedef typename InputPathListType::ConstIterator PathListIteratorType;
typedef itk::LineIterator<OutputImageType> LineIteratorType;
typedef typename InputPathType::VertexListType VertexListType;
typedef typename VertexListType::ConstIterator VertexIteratorType;
typedef PolyLineImageIterator<OutputImageType,InputPathType> PolyLineIteratorType;
OutputIteratorType outIt(outputPtr,outputPtr->GetLargestPossibleRegion());
InputIteratorType inIt(inputPtr,inputPtr->GetLargestPossibleRegion());
......@@ -94,12 +92,11 @@ DrawPathListFilter<TInputImage,TInputPath,TOutputImage>
outIt.Set(static_cast<OutputImagePixelType>(inIt.Get()));
}
// Then we use itk::LineIterator to draw polylines
OutputImageIndexType source, target;
VertexIteratorType vertexIt;
OutputImagePixelType value;
// Then we use otb::PolyLineImageIterator to draw polylines
for(PathListIteratorType plIt = pathListPtr->Begin(); plIt!=pathListPtr->End();++plIt)
{
OutputImagePixelType value;
if(m_UseInternalPathValue && plIt.Get()->GetMetaDataDictionary().HasKey("Value"))
{
itk::ExposeMetaData<OutputImagePixelType>(plIt.Get()->GetMetaDataDictionary(),"Value",value);
......@@ -108,23 +105,11 @@ DrawPathListFilter<TInputImage,TInputPath,TOutputImage>
{
value = static_cast<OutputImagePixelType>(m_PathValue);
}
vertexIt = plIt.Get()->GetVertexList()->Begin();
source[0] = static_cast<unsigned int>( (vertexIt.Value())[0]);
source[1] = static_cast<unsigned int>( (vertexIt.Value())[1]);
++vertexIt;
while(vertexIt!=plIt.Get()->GetVertexList()->End())
PolyLineIteratorType imageIt(outputPtr,plIt.Get());
for(imageIt.GoToBegin();!imageIt.IsAtEnd();++imageIt)
{
target[0]=static_cast<unsigned int>((vertexIt.Value())[0]);
target[1]=static_cast<unsigned int>((vertexIt.Value())[1]);
LineIteratorType lineIt(outputPtr,source,target);
lineIt.GoToBegin();
while(!lineIt.IsAtEnd())
{
lineIt.Set(value);
++lineIt;
}
source=target;
++vertexIt;
imageIt.Set(value);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment