Commit 1d0ab360 authored by Otmane Lahlou's avatar Otmane Lahlou
Browse files

ADD : Class SIFT Fast & Tests

parent af3194b3
......@@ -4,7 +4,7 @@
FILE(GLOB OTBFeatureExtraction_SRCS "*.cxx" )
ADD_LIBRARY(OTBFeatureExtraction ${OTBFeatureExtraction_SRCS})
TARGET_LINK_LIBRARIES (OTBFeatureExtraction OTBCommon)
TARGET_LINK_LIBRARIES (OTBFeatureExtraction OTBCommon otbsiftfast)
INSTALL(TARGETS OTBFeatureExtraction
RUNTIME DESTINATION ${OTB_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries
......
......@@ -56,9 +56,9 @@ namespace otb
*/
inline TOutput operator()(const TInput& input)
{
return static_cast<TOutput>(input[0]*input[1] - input[2]*input[2]);
return static_cast<TOutput>(input[0]*input[1] - input[2]*input[2]);
}
bool operator !=(const HessianDeterminant) const
{
......
/*=========================================================================
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 __otbSiftFastImageFilter_h
#define __otbSiftFastImageFilter_h
#include "otbImageToPointSetFilter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "otbImage.h"
namespace otb
{
/** \class SiftFastImageFilter
* \brief
*
*/
template <class TInputImage, class TOutputPointSet>
class ITK_EXPORT SiftFastImageFilter
: public ImageToPointSetFilter<TInputImage,TOutputPointSet>
{
public:
/** Standard typedefs */
typedef SiftFastImageFilter Self;
typedef ImageToPointSetFilter<TInputImage,TOutputPointSet> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Creation through object factory macro */
itkNewMacro(Self);
/** Type macro */
itkTypeMacro(SiftFastImageFilter,ImageToPointSetFilter);
/** Template parameters typedefs */
typedef TInputImage InputImageType;
typedef typename TInputImage::Pointer InputImagePointerType;
typedef typename TInputImage::PixelType PixelType;
typedef TOutputPointSet OutputPointSetType;
typedef typename TOutputPointSet::Pointer OutputPointSetPointerType;
typedef typename TOutputPointSet::PixelType OutputPixelType;
typedef typename TOutputPointSet::PointType OutputPointType;
typedef typename TOutputPointSet::PointIdentifier OutputPointIdentifierType;
typedef otb::Image<float,2> FloatImageType;
// Used to rescale data in the [0,1] range
typedef itk::RescaleIntensityImageFilter<InputImageType,FloatImageType> RescalerType;
itkSetMacro(NumberOfScales,unsigned int);
itkGetMacro(NumberOfScales,unsigned int);
protected:
/** Actually process the input */
virtual void GenerateData();
/** Constructor */
SiftFastImageFilter();
/** Destructor */
virtual ~SiftFastImageFilter() {}
/** PrintSelf method */
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
/** The number of scales */
unsigned int m_NumberOfScales;
};
}// End namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbSiftFastImageFilter.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.
=========================================================================*/
#include "otbSiftFastImageFilter.h"
#include "siftfast.h"
#include "itkContinuousIndex.h"
#include "itkImageRegionIterator.h"
#include "otbImageFileWriter.h"
namespace otb
{
/**
* Constructor
*/
template <class TInputImage, class TOutputPointSet>
SiftFastImageFilter<TInputImage,TOutputPointSet>
::SiftFastImageFilter()
{ }
template <class TInputImage, class TOutputPointSet>
void
SiftFastImageFilter<TInputImage,TOutputPointSet>
::GenerateData()
{
// Get the input image pointer
const InputImageType * inputPtr = this->GetInput(0);
OutputPointSetPointerType outputPointSet = this->GetOutput();
typename InputImageType::SizeType size = inputPtr->GetLargestPossibleRegion().GetSize();
// Rescale data in the [0,1] range
typename RescalerType::Pointer rescaler = RescalerType::New();
rescaler->SetInput(inputPtr);
rescaler->SetOutputMinimum(0);
rescaler->SetOutputMaximum(1);
rescaler->Update();
typedef otb::ImageFileWriter<FloatImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetInput(rescaler->GetOutput());
writer->SetFileName("qb_RoadExtract.tif");
writer->Update();
SiftFastImage siftInputImage = CreateImage(size[1],size[0]);
itk::ImageRegionIterator<FloatImageType> inIt(rescaler->GetOutput(),rescaler->GetOutput()->GetLargestPossibleRegion());
unsigned int index =0;
for(inIt.GoToBegin();!inIt.IsAtEnd();++inIt)
{
siftInputImage->pixels[index]=inIt.Get();
++index;
}
Keypoint keypts = GetKeypoints(siftInputImage,m_NumberOfScales);
Keypoint key = keypts;
unsigned int numkeys = 0;
while(key)
{
// Get the key location
itk::ContinuousIndex<float,2> keyContIndex;
keyContIndex[0]=key->col;
keyContIndex[1]=key->row;
OutputPointType point;
inputPtr->TransformContinuousIndexToPhysicalPoint(keyContIndex,point);
// Get the key descriptor
OutputPixelType data;
data.SetSize(128);
for(int i = 0; i < 128; ++i)
{
data[i]=key->descrip[i];
}
outputPointSet->SetPoint(numkeys,point);
outputPointSet->SetPointData(numkeys,data);
// go to next key
numkeys++;
key = key->next;
}
FreeKeypoints(keypts);
DestroyAllResources();
}
/*
* PrintSelf Method
*/
template <class TInputImage, class TOutputPointSet>
void
SiftFastImageFilter<TInputImage,TOutputPointSet>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
} // End namespace otb
......@@ -880,6 +880,11 @@ ADD_TEST(feTvImageFittingPolygonListFilter ${FEATUREEXTRACTION_TESTS9}
5 10
)
# ------- otb::ImageToSIFTKeyPointSetFilter -------------
ADD_TEST(feTuImageToFastSIFTKeyPointSetFilterNew ${FEATUREEXTRACTION_TESTS9}
otbImageToFastSIFTKeyPointSetFilterNew)
......@@ -992,6 +997,10 @@ otbImageFittingPolygonListFilterNew.cxx
otbImageToSURFKeyPointSetFilterNew.cxx
otbImageToSURFKeyPointSetFilterOutputImage.cxx
otbImageToSURFKeyPointSetFilterOutputAscii.cxx
otbImageToFastSIFTKeyPointSetFilterNew.cxx
#otbImageToFastSIFTKeyPointSetFilterOutputAscii.cxx
#otbImageToFastSIFTKeyPointSetFilterOutputImage.cx
)
INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}")
......
......@@ -40,4 +40,5 @@ REGISTER_TEST(otbImageFittingPolygonListFilterNew);
REGISTER_TEST(otbImageToSURFKeyPointSetFilterNew);
REGISTER_TEST(otbImageToSURFKeyPointSetFilterOutputImage);
REGISTER_TEST(otbImageToSURFKeyPointSetFilterOutputAscii);
REGISTER_TEST(otbImageToFastSIFTKeyPointSetFilterNew);
}
/*=========================================================================
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 "otbSiftFastImageFilter.h"
#include "otbImage.h"
#include "itkPointSet.h"
#include "itkVariableLengthVector.h"
int otbImageToFastSIFTKeyPointSetFilterNew(int argc, char * argv[])
{
typedef float RealType;
const unsigned int Dimension =2;
typedef otb::Image<RealType,Dimension> ImageType;
typedef itk::VariableLengthVector<RealType> RealVectorType;
typedef itk::PointSet<RealVectorType,Dimension> PointSetType;
typedef otb::SiftFastImageFilter<ImageType,PointSetType> ImageToFastSIFTKeyPointSetFilterType;
// Instantiating object
ImageToFastSIFTKeyPointSetFilterType::Pointer object = ImageToFastSIFTKeyPointSetFilterType::New();
return EXIT_SUCCESS;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment