Skip to content
Snippets Groups Projects
Commit 2a642ac0 authored by Otmane Lahlou's avatar Otmane Lahlou
Browse files

ADD : Add validation test for PointSetToDensityImageFilter

parent 2700e817
Branches
Tags
No related merge requests found
......@@ -23,29 +23,11 @@ PURPOSE. See the above copyright notices for more information.
#include "itkProcessObject.h"
#include "itkPointSet.h"
#include "itkPointSetToImageFilter.h"
#include "otbPointSetDensityFunction.h"
#include "itkPoint.h"
/** \class PointSetToDensityImageFilter
* \brief This class extracts key points from an image through a pyramidal gaussian based decomposition
*
* This class implements the SURF Key point detector proposed by Tuytelaars and Vangool from the university
* of Leuven, 2005
*
* \li Gaussian Second order derivative Hessian images are computed in each
* level and each octave for the input image.
* \li For each octave, an extremum search is launched on each 3 adjacent scales.
* \li The Key points detected are the ones extremum in the current , previous and
* next scale of reserach. 3 scales are needed for the computation (NumberOfScales >=3).
* \li Orientation and descriptors are computed for each key point detected.
*
* Selected Key Points are stored in an itk::PointSet structure.
* Points contains the coordinate of the detected point.
* DataPoints contain the values of the 64 element descriptor for each key point
* detected through the pyramidal analysis.
*
* Orientation is expressed in degree in the range of [0,360]
*
* \sa otb::ImageToDeterminantHessianImage
*/
namespace otb
......@@ -59,7 +41,7 @@ namespace otb
/** Standard class typedefs. */
typedef PointSetToDensityImageFilter Self;
typedef itk::PointSetToImageFilter<TInputPointSet, TOutputImage> Superclass;
typedef itk::PointSetToImageFilter<TInputPointSet, TOutputImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
......@@ -68,12 +50,31 @@ namespace otb
/** Run-time type information (and related methods). */
itkTypeMacro(PointSetToDensityImageFilter,itk::PointSetToImageFilter);
/** Template parameters typedefs*/
/** typedefs parameters support */
typedef TInputPointSet PointSetType;
typedef TOutputImage OutputImageType;
typedef typename OutputImageType::PixelType PixelType;
typedef typename OutputImageType::IndexType IndexType;
/** typedef filter support*/
typedef otb::PointSetDensityFunction<PointSetType , PixelType> PointSetDensityFunctionType;
typedef typename PointSetDensityFunctionType::InputType InputType;
typedef typename PointSetDensityFunctionType::Pointer PointSetDensityFunctionPointerType;
/** Set/Get Radius*/
itkGetMacro(Radius, unsigned int);
itkSetMacro(Radius, unsigned int);
/** PointSet Set/Get*/
// itkSetObjectMacro(PointSet,PointSetType);
//itkGetObjectMacro(PointSet,PointSetType);
protected:
/**
......@@ -92,12 +93,19 @@ namespace otb
* Main computation method.
*/
virtual void GenerateData();
/**
* Main computation method.
*/
virtual void GenerateOutputInformation();
private:
PointSetToDensityImageFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
unsigned int m_Radius;
typename PointSetType::Pointer m_PointSet;
};
}
#ifndef OTB_MANUAL_INSTANTIATION
......
......@@ -19,6 +19,7 @@ PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbPointSetToDensityImageFilter.h"
#include "itkImageRegionIterator.h"
namespace otb
......@@ -30,6 +31,7 @@ namespace otb
PointSetToDensityImageFilter< TInputPointSet , TOutputImage >
::PointSetToDensityImageFilter()
{
m_Radius = 1;
}
......@@ -49,10 +51,62 @@ namespace otb
PointSetToDensityImageFilter< TInputPointSet , TOutputImage>
::GenerateData(void)
{
this->AllocateOutputs();
PointSetDensityFunctionPointerType densityComputeFunction = PointSetDensityFunctionType::New();
densityComputeFunction->SetPointSet(const_cast<PointSetType*>(this->GetInput()));
densityComputeFunction->SetRadius(m_Radius);
/** Point*/
InputType pCenter;
IndexType index;
itk::ImageRegionIterator<OutputImageType> itOut(this->GetOutput(),
this->GetOutput()->GetLargestPossibleRegion());
itOut.GoToBegin();
while(!itOut.IsAtEnd())
{
index = itOut.GetIndex();
pCenter[0] = index[0];
pCenter[1] = index[1];
itOut.Set(densityComputeFunction->Evaluate(pCenter));
++itOut;
}
}/** End of GenerateData()*/
/*-------------------------------------------------------
* Generate Data
--------------------------------------------------------*/
template <class TInputPointSet , class TOutputImage >
void
PointSetToDensityImageFilter< TInputPointSet , TOutputImage>
::GenerateOutputInformation(void)
{
//Superclass::GenerateOutputInformation();
typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
if ( !outputPtr )
{
return;
}
typename OutputImageType::RegionType region;
IndexType start ;
start.Fill(0);
region.SetSize(this->GetSize());
region.SetIndex(start);
outputPtr->SetOrigin(this->GetOrigin());
outputPtr->SetSpacing(this->GetSpacing());
outputPtr->SetRegions( region );
}/** End of GenerateoutputInformation*/
/*----------------------------------------------------------------
PrintSelf
-----------------------------------------------------------------*/
......
......@@ -1144,6 +1144,16 @@ ADD_TEST(bfTuPointSetToDensityImageFilterNew ${BASICFILTERS_TESTS11}
ADD_TEST(bfTvPointSetToDensityImageFilterTest ${BASICFILTERS_TESTS11}
--compare-image ${TOL}
${BASELINE_FILES}/bfTvPointSetToDensityImageFilterOutputImage.tif
${TEMP}/bfTvPointSetToDensityImageFilterOutputImage.tif
otbPointSetToDensityImageFilterTest
${INPUTDATA}/QB_Suburb.png
${TEMP}/bfTvPointSetToDensityImageFilterOutputImage.tif
5 2
)
# ------- otbPCAShapeModelEstimatorTest ----------------------------
ADD_TEST(bfTvImagePCAShapeModelEstimatorTest ${BASICFILTERS_TESTS11}
otbImagePCAShapeModelEstimatorTest
......@@ -1343,6 +1353,7 @@ otbPointSetFunctionNew.cxx
otbPointSetDensityFunctionNew.cxx
otbPointSetDensityFunctionTest.cxx
otbPointSetToDensityImageFilterNew.cxx
otbPointSetToDensityImageFilterTest.cxx
#otbCountImageFunctionTest.cxx
#otbCountImageFilterNew.cxx
#otbCountImageFilterTest.cxx
......
......@@ -31,7 +31,8 @@ REGISTER_TEST(otbExtractROIResample);
REGISTER_TEST(otbPointSetFunctionNew);
REGISTER_TEST(otbPointSetDensityFunctionNew);
REGISTER_TEST(otbPointSetDensityFunctionTest);
REGISTER_TEST(otbPointSetToDensityImageFilterNew);
REGISTER_TEST(otbPointSetToDensityImageFilterNew);
REGISTER_TEST(otbPointSetToDensityImageFilterTest);
//REGISTER_TEST(otbCountImageFunctionTest);
//REGISTER_TEST(otbCountImageFilterNew);
//REGISTER_TEST(otbCountImageFilterTest);
......
/*=========================================================================
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.
=========================================================================*/
#include <stdio.h>
#include "itkPointSet.h"
#include "otbImage.h"
#include "otbPointSetToDensityImageFilter.h"
#include "itkVariableLengthVector.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "otbSiftFastImageFilter.h"
int otbPointSetToDensityImageFilterTest(int argc, char* argv[] )
{
const char * infname = argv[1];
const char * outfname = argv[2];
const unsigned int scales = atoi(argv[3]);
const unsigned int radius = atoi(argv[4]);
const unsigned int Dimension = 2;
typedef float PixelType;
typedef otb::Image<PixelType , Dimension> ImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::ImageFileWriter<ImageType> WriterType;
typedef itk::VariableLengthVector<PixelType> RealVectorType;
typedef itk::PointSet<RealVectorType,Dimension> PointSetType;
typedef otb::SiftFastImageFilter<ImageType,PointSetType> DetectorType;
typedef otb::PointSetToDensityImageFilter <PointSetType,ImageType> FunctionType;
/**Instancitation of an object*/
FunctionType::Pointer filter = FunctionType::New();
DetectorType::Pointer detector = DetectorType::New();
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(infname);
reader->GenerateOutputInformation();
detector->SetInput(reader->GetOutput());
detector->SetNumberOfScales(scales);
/** PointSetImageToDensity ImageFilter*/
filter->SetInput(detector->GetOutput());
filter->SetRadius(radius);
filter->SetSpacing(reader->GetOutput()->GetSpacing());
filter->SetSize(reader->GetOutput()->GetLargestPossibleRegion().GetSize());
filter->SetOrigin(reader->GetOutput()->GetOrigin());
/** Writing the densty Image*/
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(outfname);
writer->SetInput(filter->GetOutput());
writer->Update();
return EXIT_SUCCESS;
}
......@@ -18,7 +18,6 @@ PURPOSE. See the above copyright notices for more information.
#include "otbSiftFastImageFilter.h"
#include "otbImage.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "itkPointSet.h"
#include "itkVariableLengthVector.h"
#include "otbRationalQuotientResampleImageFilter.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment