Skip to content
Snippets Groups Projects
Commit 998761df authored by Aurélien Bricier's avatar Aurélien Bricier
Browse files

ENH: added DBOverlap feature to VectorDataToRoadDescriptionFilter

parent 21ec18fd
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@
#include "otbNDVIDataNodeFeatureFunction.h"
#include "otbSpectralAngleDataNodeFeatureFunction.h"
#include "otbDBOverlapDataNodeFeatureFunction.h"
namespace otb
{
......@@ -39,6 +39,8 @@ namespace otb
* The support is an Optical Image and the descriptor are:
* - (NDVI >= threshold) per cent along the tested lines
* - mean Spectral Angle regarding a reference pixel along the tested lines
* - DB Overlap compute the number of building crossed by the data node in percent
* regarding all the buildings within a data node neighborhood
*
* \ingroup VectorDataFilter
* \sa VectorDataToSpecificDescriptionFilterBase
......@@ -81,6 +83,8 @@ public:
NDVIFeatureFunctionType;
typedef otb::SpectralAngleDataNodeFeatureFunction<OpticalImageType, CoordRepType, PrecisionType>
SpectralAngleFeatureFunctionType;
typedef otb::DBOverlapDataNodeFeatureFunction<CoordRepType, PrecisionType>
DBOverlapFeatureFunctionType;
typedef itk::DataObject::Pointer DataObjectPointer;
typedef itk::DataObject DataObject;
......@@ -107,6 +111,7 @@ private:
typename NDVIFeatureFunctionType::Pointer m_NDVIFeatureFunction;
typename SpectralAngleFeatureFunctionType::Pointer m_SpectralAngleFeatureFunction;
typename DBOverlapFeatureFunctionType::Pointer m_DBOverlapFeatureFunction;
};
......
......@@ -28,9 +28,10 @@ template <class TVectorData, class TOpticalImage>
VectorDataToRoadDescriptionFilter<TVectorData, TOpticalImage>
::VectorDataToRoadDescriptionFilter()
{
this->SetNumberOfRequiredInputs(2);
this->SetNumberOfRequiredInputs(3);
m_NDVIFeatureFunction = NDVIFeatureFunctionType::New();
m_SpectralAngleFeatureFunction = SpectralAngleFeatureFunctionType::New();
m_DBOverlapFeatureFunction = DBOverlapFeatureFunctionType::New();
}
template <class TVectorData, class TOpticalImage>
......@@ -70,7 +71,6 @@ VectorDataToRoadDescriptionFilter<TVectorData, TOpticalImage>
(this->GetSupport(1));
}
template <class TVectorData, class TOpticalImage>
void
VectorDataToRoadDescriptionFilter<TVectorData, TOpticalImage>
......@@ -78,6 +78,7 @@ VectorDataToRoadDescriptionFilter<TVectorData, TOpticalImage>
{
m_NDVIFeatureFunction->SetInputImage(const_cast<OpticalImageType *>(this->GetOpticalImage()));
m_SpectralAngleFeatureFunction->SetInputImage(const_cast<OpticalImageType *>(this->GetOpticalImage()));
m_DBOverlapFeatureFunction->SetInputVectorData(const_cast<VectorDataType *>(this->GetBuildingsDB()));
// Retrieving root node
typename DataNodeType::Pointer root = this->GetOutput(0)->GetDataTree()->GetRoot()->Get();
......@@ -99,8 +100,9 @@ VectorDataToRoadDescriptionFilter<TVectorData, TOpticalImage>
if (!itVector.Get()->IsRoot() && !itVector.Get()->IsDocument() && !itVector.Get()->IsFolder())
{
typename DataNodeType::Pointer currentGeometry = itVector.Get();
currentGeometry->SetFieldAsDouble("NDVI", (double)(m_NDVIFeatureFunction->Evaluate(*(currentGeometry.GetPointer()))[0]));
currentGeometry->SetFieldAsDouble("NDVI", (double)(m_NDVIFeatureFunction->Evaluate(*(currentGeometry.GetPointer()))[0]));
currentGeometry->SetFieldAsDouble("RADIOM", (double)(m_SpectralAngleFeatureFunction->Evaluate(*(currentGeometry.GetPointer()))[0]));
currentGeometry->SetFieldAsDouble("DBOVER", (double)(m_DBOverlapFeatureFunction->Evaluate(*(currentGeometry.GetPointer()))[0]));
//currentGeometry->SetFieldAsInt("LSD", 80);
//currentGeometry->SetFieldAsInt("SHADOW", 80);
......
......@@ -93,6 +93,7 @@ ADD_TEST(fzTvVectorDataToRoadDescriptionFilter ${Fuzzy_TESTS2}
otbVectorDataToRoadDescriptionFilter
${INPUTDATA}/Dempster-Shafer/ROI_QB_TOULOUSE_ROADS.shp
${INPUTDATA}/Dempster-Shafer/ROI_QB_TOULOUSE.TIF
${INPUTDATA}/Dempster-Shafer/ROI_QB_TOULOUSE_BUILDINGS.shp
${TEMP}/fzTvVectorDataToRoadDescriptionFilterOutput.shp
${INPUTDATA}/DEM/srtm_directory
0
......
......@@ -55,9 +55,10 @@ int otbVectorDataToRoadDescriptionFilter(int argc, char* argv[])
{
const char * inputVD = argv[1];
const char * inputImg = argv[2];
const char * outputVD = argv[3];
const char * DEMDirectory = argv[4];
int DisplayWarnings = atoi(argv[5]);
const char * inputDB = argv[3];
const char * outputVD = argv[4];
const char * DEMDirectory = argv[5];
int DisplayWarnings = atoi(argv[6]);
typedef double PrecisionType;
typedef otb::VectorData<PrecisionType, 2> VectorDataType;
......@@ -76,6 +77,7 @@ int otbVectorDataToRoadDescriptionFilter(int argc, char* argv[])
VectorDataReaderType::Pointer vdReader = VectorDataReaderType::New();
VectorDataReaderType::Pointer DBReader = VectorDataReaderType::New();
ImageReaderType::Pointer reader = ImageReaderType::New();
VectorDataWriterType::Pointer vdWriter = VectorDataWriterType::New();
VectorDataReProjFilter::Pointer vdReProjFilter = VectorDataReProjFilter::New();
......@@ -91,6 +93,9 @@ int otbVectorDataToRoadDescriptionFilter(int argc, char* argv[])
reader->SetFileName(inputImg);
reader->UpdateOutputInformation();
DBReader->SetFileName(inputDB);
DBReader->Update();
vdReader->SetFileName(inputVD);
vdReader->Update();
......@@ -102,6 +107,7 @@ int otbVectorDataToRoadDescriptionFilter(int argc, char* argv[])
filter->SetInput(vdReProjFilter->GetOutput());
filter->AddOpticalImage(reader->GetOutput());
filter->AddBuildingsDB(DBReader->GetOutput());
vdWriter->SetFileName(outputVD);
vdWriter->SetInput(filter->GetOutput());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment