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

Filtre d'affectation d'une valeur au path.

parent 46ce74b1
No related branches found
No related tags found
No related merge requests found
......@@ -25,10 +25,11 @@ PURPOSE. See the above copyright notices for more information.
namespace otb
{
/** \class PolyLineParametricPathWithValue
* \brief
*
* \ingroup
* \ingroup
* \brief This class implement a PolyLineParametricPath for which a value can be set.
* The value is stored in the itk::MetaDataDictionary.
* The precision of the value can be set.
*
* \sa itk::PolyLineParametricPath.
*/
template < class TValue,unsigned int VDimension=2>
class ITK_EXPORT PolyLineParametricPathWithValue
......@@ -60,16 +61,17 @@ class ITK_EXPORT PolyLineParametricPathWithValue
ValueType GetValue(void)
{
ValueType resp;
itk::MetaDataDictionary & dict = this->GetMetaDataDictionary();
if(dict.HasKey(m_Key))
{
ValueType resp;
itk::ExposeMetaData<ValueType>(dict,m_Key,resp);
}
else
{
itkGenericExceptionMacro(<<"Key "<<m_Key<<" not found in metadata dictionary !");
}
return resp;
}
protected:
......
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef _otbLinkPathFilter_h
#define _otbLinkPathFilter_h
#include "otbPathListToPathListFilter.h"
#include "otbMacro.h"
namespace otb
{
/** \class LikehoodPathFilter
* \brief
*/
template <class TPath, class TImage>
class ITK_EXPORT LikehoodPathFilter
: public PathListToPathListFilter<TPath>
{
public:
/** Standard typedefs */
typedef LikehoodPathFilter Self;
typedef PathListToPathListFilter<TPath> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Type macro */
itkNewMacro(Self);
/** Creation through object factory macro */
itkTypeMacro(LikehoodPathFilter, PathListToPathListFilter);
/** Template parameters typedefs */
typedef typename Superclass::PathType PathType;
typedef typename Superclass::PathListType PathListType;
typedef typename Superclass::PathPointerType PathPointerType;
typedef typename PathListType::Pointer PathListPointerType;
typedef typename PathListType::ConstIterator IteratorType;
typedef typename PathType::VertexType VertexType;
typedef typename PathType::VertexListType VertexListType;
typedef typename VertexListType::ConstIterator VertexIteratorType;
typedef double RealType;
typedef TImage ImageType;
typedef typename ImageType::Pointer ImagePointerType;
typedef typename ImageType::ConstPointer ImageConstPointerType;
/**
* Set the input likehood image.
* \param image The likehood image.
*/
void SetInputImage(const ImageType * image);
/**
* Get the input likehood image.
* \return The input likehood image.
*/
const ImageType * GetInputImage(void);
protected:
/** Constructor */
LikehoodPathFilter();
/** Destructor */
virtual ~LikehoodPathFilter() {};
/** GenerateData method */
virtual void GenerateData();
/** PrintSelf method */
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
LikehoodPathFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
std::string m_Key;
};
}// End namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbLikehoodPathFilter.txx"
#endif
#endif
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef _otbLikehoodPathFilter_txx
#define _otbLikehoodPathFilter_txx
#include "otbLikehoodPathFilter.h"
#include "otbPolyLineImageConstIterator.h"
#include "itkMetaDataObject.h"
#include "otbMacro.h"
namespace otb
{
/**
* Constructor
*/
template <class TPath, class TImage>
LikehoodPathFilter<TPath, TImage>
::LikehoodPathFilter()
{
m_Key = "Value";
this->SetNumberOfRequiredInputs(2);
this->SetNumberOfInputs(2);
}
template <class TPath, class TImage>
void
LikehoodPathFilter<TPath, TImage>
::SetInputImage(const ImageType * image)
{
this->itk::ProcessObject::SetNthInput(1,const_cast<ImageType *>(image));
}
template <class TPath, class TImage>
const typename LikehoodPathFilter<TPath, TImage>
::ImageType *
LikehoodPathFilter<TPath, TImage>
::GetInputImage(void)
{
if(this->GetNumberOfInputs()<1)
{
return 0;
}
return static_cast<const ImageType *>(this->itk::ProcessObject::GetInput(1));
}
template <class TPath, class TImage>
void
LikehoodPathFilter<TPath, TImage>
::GenerateData()
{
// I/O wiring
ImageConstPointerType inputImagePtr = this->GetInputImage();
const PathListType * inputPtr = this->GetInput();
PathListType * outputPtr = this->GetOutput();
typedef otb::PolyLineImageConstIterator<ImageType,PathType> ImageIteratorType;
for(IteratorType it = inputPtr->Begin(); it != inputPtr->End(); ++it)
{
PathPointerType path = it.Get();
ImageIteratorType imageIt(inputImagePtr,path);
double cumulatedValues = 0.0;
double nbPoints = 0.0;
for(imageIt.GoToBegin();!imageIt.IsAtEnd();++imageIt,++nbPoints)
{
cumulatedValues+=static_cast<double>(imageIt.Get());
}
itk::MetaDataDictionary & dict = path->GetMetaDataDictionary();
itk::EncapsulateMetaData<double>(dict,m_Key,cumulatedValues/nbPoints);
outputPtr->PushBack(path);
}
}
/**
* PrintSelf Method
*/
template <class TPath, class TImage>
void
LikehoodPathFilter<TPath, TImage>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
} // End namespace otb
#endif
......@@ -576,9 +576,6 @@ ADD_TEST(feTvSimplifyPathFilter ${FEATUREEXTRACTION_TESTS}
1 1 5 1 7 1 11 1 21 11 31 11 41 11 58 11 70 11
)
# ------- otb::BreakAngularPathListFilter -------------
ADD_TEST(feTuBreakAngularPathListFilterNew ${FEATUREEXTRACTION_TESTS}
......@@ -644,6 +641,24 @@ ADD_TEST(feTvLinkPathFilter ${FEATUREEXTRACTION_TESTS}
11 171 11 141
)
# ------- otb::LikehoodPathFilter -------------
ADD_TEST(feTuLikehoodPathFilterNew ${FEATUREEXTRACTION_TESTS}
otbLikehoodPathFilterNew)
ADD_TEST(feTvLikehoodPathFilter ${FEATUREEXTRACTION_TESTS}
--compare-ascii ${EPS}
${BASELINE_FILES}/feTvLikehoodPathOutput.txt
${TEMP}/feTvLikehoodPathOutput.txt
otbLikehoodPathFilter
${INPUTDATA}/InputForRoadDetection_NonMaxRem.hdr
${TEMP}/feTvLikehoodPathOutput.txt
157 335 204 376 |
21 305 35 308 77 354 85 358 |
73 160 126 173
)
# ------- otb::RoadExtractionFilter -------------
ADD_TEST(feTuRoadExtractionFilterNew ${FEATUREEXTRACTION_TESTS}
......@@ -733,6 +748,8 @@ otbRemoveTortuousPathFilterNew.cxx
otbRemoveTortuousPathFilter.cxx
otbLinkPathFilterNew.cxx
otbLinkPathFilter.cxx
otbLikehoodPathFilterNew.cxx
otbLikehoodPathFilter.cxx
otbRoadExtractionFilterNew.cxx
otbRoadExtractionFilter.cxx
)
......
......@@ -96,6 +96,8 @@ REGISTER_TEST(otbRemoveTortuousPathFilterNew);
REGISTER_TEST(otbRemoveTortuousPathFilter);
REGISTER_TEST(otbLinkPathFilterNew);
REGISTER_TEST(otbLinkPathFilter);
REGISTER_TEST(otbLikehoodPathFilterNew);
REGISTER_TEST(otbLikehoodPathFilter);
REGISTER_TEST(otbRoadExtractionFilterNew);
REGISTER_TEST(otbRoadExtractionFilter);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment