Commit 7da549e5 authored by Julien Michel's avatar Julien Michel
Browse files

MRG

parents 7eea9550 08fd2a1c
......@@ -88,7 +88,7 @@ class ITK_EXPORT BinaryImageDensityFunction :
{
IndexType index;
this->ConvertContinuousIndexToNearestIndex( cindex, index );
return this->EvaluateAtIndex( index ) ;
return this->EvaluateAtIndex( index );
}
/** Get/Set the radius of the neighborhood over which the
......
......@@ -94,9 +94,9 @@ BinaryImageDensityFunction<TInputImage,TCoordRep>
}
const RealType num = static_cast<RealType>( size );
var = sum/num ;
var = sum/num ;
return var ;
return var;
}
......
......@@ -70,7 +70,7 @@ BinaryImageMinimalBoundingRegionCalculator<TInputImage>
fit.SetFirstDirection( !axis );
fit.SetSecondDirection( axis );
fit.GoToBegin();
;
;
// Walk through the two images line by line
while (!fit.IsAtEnd())
{
......
......@@ -73,7 +73,7 @@ public:
/** Main computation method */
virtual void ThreadedGenerateData( const InputImageRegionType &outputRegionForThread, int threadId ) ;
virtual void ThreadedGenerateData( const InputImageRegionType &outputRegionForThread, int threadId );
virtual void BeforeThreadedGenerateData();
virtual void GenerateInputRequestedRegion();
......
......@@ -51,6 +51,7 @@ void
BinaryImageToDensityImageFilter<TInputImage, TOutputImage, TCountFunction>
::GenerateInputRequestedRegion()
{
std::cout<<"GenerateInputRequestedRegion"<<std::endl;
// call the superclass' implementation of this method
Superclass::GenerateInputRequestedRegion();
......@@ -143,18 +144,18 @@ BinaryImageToDensityImageFilter<TInputImage, TOutputImage, TCountFunction>
it.GoToBegin();
while(!itOut.IsAtEnd())
{
index = it.GetIndex();
if(outputRegionForThread.IsInside(index))
{
itOut.Set(m_CountFunction->EvaluateAtIndex(index));
}
++itOut;
++it;
progress.CompletedPixel(); // potential exception thrown here
}
{
index = it.GetIndex();
if(outputRegionForThread.IsInside(index))
{
itOut.Set(m_CountFunction->EvaluateAtIndex(index));
}
++itOut;
++it;
progress.CompletedPixel(); // potential exception thrown here
}
}
}
......
......@@ -22,9 +22,7 @@ PURPOSE. See the above copyright notices for more information.
#include "itkImageToImageFilter.h"
#include "otbBinaryImageToDensityImageFilter.h"
#include "itkProcessObject.h"
#include "itkNumericTraits.h"
......@@ -45,7 +43,7 @@ public:
/** Standard class typedefs. */
typedef EdgeDensityImageFilter Self;
typedef itk::ImageToImageFilter<TInputImage,TOutputImage> Superclass ;
typedef itk::ImageToImageFilter<TInputImage,TOutputImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
......@@ -59,6 +57,8 @@ public:
/** Template parameters typedefs*/
typedef TInputImage InputImageType;
typedef typename InputImageType::Pointer InputImagePointerType;
typedef typename InputImageType::PixelType InputImagePixelType;
typedef typename InputImageType::SizeType InputImageSizeType;
/** OutputImageType typedef support*/
typedef TOutputImage OutputImageType;
......@@ -71,7 +71,6 @@ public:
/** Count Density Function typedef support*/
typedef TDensityCount DensityCountFunctionType;
/** PointSetToDensityImageFilter support*/
typedef otb::BinaryImageToDensityImageFilter<InputImageType,
......@@ -82,15 +81,19 @@ public:
/** Get/Set the radius of the neighborhood over which the
statistics are evaluated */
itkSetMacro( NeighborhoodRadius, unsigned int );
itkGetConstReferenceMacro( NeighborhoodRadius, unsigned int );
itkSetMacro( NeighborhoodRadius, InputImageSizeType );
itkGetConstReferenceMacro( NeighborhoodRadius, InputImageSizeType );
void SetNeighborhoodRadius( unsigned int rad)
{
m_NeighborhoodRadius.Fill(rad);
this->Modified();
}
/**Set/Get detector */
itkSetObjectMacro(Detector, DetectorType);
itkGetObjectMacro(Detector, DetectorType);
itkGetObjectMacro(DensityImageFilter, DensityImageType);
protected:
/**
......@@ -115,9 +118,9 @@ private:
EdgeDensityImageFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
DetectorPointerType m_Detector;
DensityImagePointerType m_DensityImageFilter;
unsigned int m_NeighborhoodRadius;
DetectorPointerType m_Detector;
DensityImagePointerType m_DensityImageFilter;
InputImageSizeType m_NeighborhoodRadius;
};
}
#ifndef OTB_MANUAL_INSTANTIATION
......
......@@ -19,7 +19,7 @@ PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbEdgeDensityImageFilter.h"
#include "otbImageFileWriter.h"
namespace otb
{
......@@ -32,7 +32,7 @@ EdgeDensityImageFilter<TInputImage, TOutputImage, TEdgeDetector, TDensityCount>
{
this->SetNumberOfRequiredInputs( 1 );
m_NeighborhoodRadius = 1;
m_NeighborhoodRadius.Fill( 1 );
m_Detector = DetectorType::New();
m_DensityImageFilter = DensityImageType::New();
}
......@@ -55,19 +55,11 @@ void
EdgeDensityImageFilter<TInputImage, TOutputImage, TEdgeDetector, TDensityCount>
::GenerateData()
{
typename ImageFileWriter<TInputImage>::Pointer writer = ImageFileWriter<TInputImage>::New();
m_Detector->SetInput( this->GetInput() );
std::cout<<"###"<<this->GetInput()->GetLargestPossibleRegion()<<std::endl;
m_Detector->Update();
m_Detector->UpdateOutputInformation();
//m_Detector->SetRequestedRegionToLargestPossibleRegion();
std::cout<<"~~~"<<m_Detector->GetOutput()->GetLargestPossibleRegion()<<std::endl;
m_DensityImageFilter->SetNeighborhoodRadius(m_NeighborhoodRadius);
m_DensityImageFilter->SetInput(m_Detector->GetOutput());
m_DensityImageFilter->UpdateOutputInformation();
std::cout<<"***"<<m_DensityImageFilter->GetOutput()->GetLargestPossibleRegion()<<std::endl;
m_DensityImageFilter->SetInput( m_Detector->GetOutput() );
m_DensityImageFilter->GraftOutput(this->GetOutput());
m_DensityImageFilter->Update();
......
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
Copyright (c) CS Systemes d'information. All rights reserved.
See CSCopyright.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 __otbEdgeDetectorImageFilter_h
#define __otbEdgeDetectorImageFilter_h
#include "itkImageToImageFilter.h"
#include "itkBinaryThresholdImageFilter.h"
/** \class EdgeDetectorImageFilter
* \brief This composite filter binaries a edge detection image output.
* The used edge detection filter is given as template of the class.
* The class only supports Image.
*
*/
namespace otb
{
template <class TInputImage, class TOutputImage , class TEdgeDetection>
class ITK_EXPORT EdgeDetectorImageFilter
: public itk::ImageToImageFilter<TInputImage, TOutputImage>
{
public:
/** Standard class typedefs. */
typedef EdgeDetectorImageFilter Self;
typedef itk::ImageToImageFilter<TInputImage,TOutputImage> Superclass ;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(EdgeDetectorImageFilter,itk::ImageToImageFilter);
/** Template parameters typedefs*/
typedef TInputImage InputImageType;
typedef TOutputImage OutputImageType;
typedef typename InputImageType::Pointer InputImagePointerType;
typedef typename InputImageType::PixelType InputImagePixelType;
typedef typename InputImageType::SizeType InputImageSizeType;
typedef typename OutputImageType::RegionType OutputImageRegionType;
typedef typename OutputImageType::Pointer OutputImagePointerType;
typedef typename OutputImageType::PixelType OutputImagePixelType;
/** Edge Detection */
typedef TEdgeDetection DetectionType;
typedef typename DetectionType::Pointer DetectionPointerType;
/** Thresholder filter : Otsu */
typedef itk::BinaryThresholdImageFilter<InputImageType, InputImageType> BinaryFilterType;
typedef typename BinaryFilterType::Pointer BinaryFilterPointerType;
/**Set/Get detector */
itkSetObjectMacro(Detector, DetectionType);
itkGetObjectMacro(Detector, DetectionType);
itkGetConstObjectMacro(Detector, DetectionType);
/**Set/Get binary filter */
itkSetObjectMacro(BinaryFilter, BinaryFilterType);
itkGetObjectMacro(BinaryFilter, BinaryFilterType);
//itkGetObjectMacro(DetectorImageFilter, DetectorImageType);
/** Set lower threshold value. */
void SetLowerThreshold(InputImagePixelType val)
{
m_BinaryFilter->SetLowerThreshold(val);
this->Modified();
}
/** Set upper threshold value. */
void SetUpperThreshold(InputImagePixelType val)
{
m_BinaryFilter->SetUpperThreshold(val);
this->Modified();
}
/** Set Inside value. */
void SetInsideValue(InputImagePixelType val)
{
m_BinaryFilter->SetInsideValue(val);
this->Modified();
}
/** Set Outside value. */
void SetOutsideValue(InputImagePixelType val)
{
m_BinaryFilter->SetOutsideValue(val);
this->Modified();
}
protected:
EdgeDetectorImageFilter();
virtual ~EdgeDetectorImageFilter();
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
virtual void GenerateData( );
private:
EdgeDetectorImageFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
DetectionPointerType m_Detector;
BinaryFilterPointerType m_BinaryFilter;
};
}
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbEdgeDetectorImageFilter.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.
Copyright (c) CS systèmes d'information. All rights reserved.
See CSCopyright.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 "otbEdgeDetectorImageFilter.h"
namespace otb
{
/**---------------------------------------------------------
* Constructor
----------------------------------------------------------*/
template <class TInputImage , class TOutputImage, class TEdgeDetection>
EdgeDetectorImageFilter<TInputImage, TOutputImage, TEdgeDetection>
::EdgeDetectorImageFilter()
{
this->SetNumberOfRequiredInputs( 1 );
m_Detector = DetectionType::New();
m_BinaryFilter = BinaryFilterType::New();
m_BinaryFilter->SetInsideValue( static_cast<OutputImagePixelType>(0.) );
m_BinaryFilter->SetOutsideValue( static_cast<OutputImagePixelType>(1.) );
m_BinaryFilter->SetUpperThreshold( static_cast<InputImagePixelType>(255) );
m_BinaryFilter->SetLowerThreshold( static_cast<InputImagePixelType>(0) );
}
/*---------------------------------------------------------
* Destructor.c
----------------------------------------------------------*/
template <class TInputImage , class TOutputImage, class TEdgeDetection>
EdgeDetectorImageFilter<TInputImage, TOutputImage, TEdgeDetection>
::~EdgeDetectorImageFilter()
{}
/**
* threaded Generate Data
*/
template <class TInputImage , class TOutputImage, class TEdgeDetection>
void
EdgeDetectorImageFilter<TInputImage, TOutputImage, TEdgeDetection>
::GenerateData()
{
m_Detector->SetInput( this->GetInput() );
m_BinaryFilter->SetInput( m_Detector->GetOutput() );
m_BinaryFilter->GraftOutput(this->GetOutput());
m_BinaryFilter->Update();
this->GraftOutput(m_BinaryFilter->GetOutput());
}
/*----------------------------------------------------------------
PrintSelf
-----------------------------------------------------------------*/
template <class TInputImage , class TOutputImage, class TEdgeDetection>
void
EdgeDetectorImageFilter<TInputImage, TOutputImage, TEdgeDetection>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
}/** end namesapce otb*/
......@@ -116,7 +116,7 @@ EstimateInnerProductPCAImageFilter<TInputImage,TOutputImage>
for(unsigned int img_number = 0; img_number < numberOfTrainingImages; img_number++ )
{
unsigned int indexNumberOfTrainingImages = numberOfTrainingImages-1;
for( unsigned int vec_number = 0 ; vec_number < m_NumberOfPrincipalComponentsRequired; vec_number++, indexNumberOfTrainingImages-- )
for( unsigned int vec_number = 0 ; vec_number < m_NumberOfPrincipalComponentsRequired; vec_number++, indexNumberOfTrainingImages-- )
{
outputPixel[vec_number] += static_cast<OutputInternalPixelType>( static_cast<double>(inputPixel[img_number]) * static_cast<double>(m_EigenVectorsOfInnerProductMatrix[img_number][indexNumberOfTrainingImages]));
}
......
......@@ -59,7 +59,7 @@ FunctionWithNeighborhoodToImageFilter<TInputImage,TOutputImage,TFunction>
}
m_Function->SetInputImage(inputPtr);
for(unsigned int i = 0 ; i<static_cast<unsigned int>(this->GetNumberOfThreads()); i++)
for(unsigned int i = 0; i<static_cast<unsigned int>(this->GetNumberOfThreads()); i++)
{
FunctionPointerType func = m_Function;
m_FunctionList.push_back( func );
......
......@@ -44,7 +44,7 @@ public:
/** Standard class typedefs. */
typedef KeyPointDensityImageFilter Self;
typedef itk::ImageToImageFilter<TInputImage,TOutputImage> Superclass ;
typedef itk::ImageToImageFilter<TInputImage,TOutputImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
......
......@@ -62,7 +62,7 @@ KeyPointDensityImageFilter<TInputImage, TOutputImage, TDetector >
typename Superclass::OutputImagePointer outputImage = this->GetOutput();
InputImagePointerType ptr = const_cast<InputImageType *>(this->GetInput());
if (!ptr)
return ;
return;
/** Detector*/
m_Detector->SetInput(ptr);
......
......@@ -54,17 +54,17 @@ public:
typedef itk::SmartPointer<const Self> ConstPointer;
/** Run-time type information (and related methods). */
itkTypeMacro(ListSampleToHistogramListGenerator, Object) ;
itkTypeMacro(ListSampleToHistogramListGenerator, Object);
/** Method for creation through the object factory. */
itkNewMacro(Self) ;
itkNewMacro(Self);
/** Type needed for defining the limits of the histogram bins */
typedef typename itk::NumericTraits
< THistogramMeasurement >::RealType HistogramMeasurementRealType;
typedef itk::Statistics::Histogram< HistogramMeasurementRealType,1,
TFrequencyContainer > HistogramType ;
typedef typename HistogramType::SizeType HistogramSizeType ;
TFrequencyContainer > HistogramType;
typedef typename HistogramType::SizeType HistogramSizeType;
typedef typename TListSample::MeasurementVectorType MeasurementVectorType;
typedef ObjectList<HistogramType> HistogramListType;
typedef typename HistogramListType::Pointer HistogramListPointerType;
......@@ -72,11 +72,11 @@ public:
/** plug in the ListSample object */
void SetListSample(const TListSample* list)
{
m_List = list ;
m_List = list;
}
void SetMarginalScale(float scale)
{ m_MarginalScale = scale ; }
{ m_MarginalScale = scale; }
void SetNumberOfBins(unsigned int size)
{
......@@ -84,10 +84,10 @@ public:
}
HistogramListType* GetOutput() const
{ return m_HistogramList ; }
{ return m_HistogramList; }
void Update()
{ this->GenerateData() ; }
{ this->GenerateData(); }
itkSetMacro(AutoMinMax,bool);
itkGetConstReferenceMacro(AutoMinMax,bool);
......@@ -106,21 +106,21 @@ public:
protected:
ListSampleToHistogramListGenerator() ;
ListSampleToHistogramListGenerator();
virtual ~ListSampleToHistogramListGenerator() {}
void GenerateData() ;
void GenerateData();
void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
const TListSample* m_List ;
const TListSample* m_List;
HistogramSizeType m_Size;
float m_MarginalScale ;
float m_MarginalScale;
MeasurementVectorType m_HistogramMin;
MeasurementVectorType m_HistogramMax;
bool m_AutoMinMax;
HistogramListPointerType m_HistogramList;
} ; // end of class
}; // end of class
} // end of namespace itk
......
......@@ -32,11 +32,11 @@ template< class TListSample,
class THistogramMeasurement,
class TFrequencyContainer>
ListSampleToHistogramListGenerator< TListSample,
THistogramMeasurement,
TFrequencyContainer >
THistogramMeasurement,
TFrequencyContainer >
::ListSampleToHistogramListGenerator() : m_List(), m_Size(), m_MarginalScale(100), m_HistogramMin(), m_HistogramMax(), m_AutoMinMax(true), m_HistogramList()
{
m_HistogramList = HistogramListType::New() ;
m_HistogramList = HistogramListType::New();
m_Size.Fill(255);
}
......@@ -46,8 +46,8 @@ template< class TListSample,
class TFrequencyContainer >
void
ListSampleToHistogramListGenerator< TListSample,
THistogramMeasurement,
TFrequencyContainer >
THistogramMeasurement,
TFrequencyContainer >
::GenerateData()
{
otbMsgDebugMacro(<<"ListSampleToHistogramListGenerator::GenerateData(): Entering");
......@@ -77,18 +77,18 @@ ListSampleToHistogramListGenerator< TListSample,
if( m_AutoMinMax && m_List->Size() != 0 )
{
FindSampleBound(m_List, m_List->Begin(),
m_List->End(), lower, upper) ;
float margin ;
m_List->End(), lower, upper);
float margin;
for ( unsigned int i = 0 ; i < m_List->GetMeasurementVectorSize() ; i++ )
for ( unsigned int i = 0; i < m_List->GetMeasurementVectorSize(); i++ )
{
if ( !itk::NumericTraits< THistogramMeasurement >::is_integer )
{
margin =
( (THistogramMeasurement)(upper[i] - lower[i]) /
(THistogramMeasurement) m_Size[0] ) /
(THistogramMeasurement) m_MarginalScale ;
h_upper[i] = (THistogramMeasurement) (upper[i] + margin) ;
( (THistogramMeasurement)(upper[i] - lower[i]) /
(THistogramMeasurement) m_Size[0] ) /
(THistogramMeasurement) m_MarginalScale;
h_upper[i] = (THistogramMeasurement) (upper[i] + margin);
if(h_upper[i] <= upper[i])
{
// an overflow has occurred therefore set upper to upper
......@@ -103,7 +103,7 @@ ListSampleToHistogramListGenerator< TListSample,
else
{
h_upper[i] = ((THistogramMeasurement) upper[i]) +
itk::NumericTraits< THistogramMeasurement >::One ;
itk::NumericTraits< THistogramMeasurement >::One;
if(h_upper[i] <= upper[i])
{
// an overflow has occurred therefore set upper to upper
......@@ -115,7 +115,7 @@ ListSampleToHistogramListGenerator< TListSample,
// computation and clearly the user intended to include min and max.
}
}
h_lower[i] = ( THistogramMeasurement) lower[i] ;
h_lower[i] = ( THistogramMeasurement) lower[i];
}
}
else
......@@ -128,7 +128,7 @@ ListSampleToHistogramListGenerator< TListSample,
m_HistogramList->Clear();
// For each dimension
for(unsigned int comp = 0; comp<m_List->GetMeasurementVectorSize() ;++comp)
for(unsigned int comp = 0; comp<m_List->GetMeasurementVectorSize();++comp)
{
// initialize the Histogram object using the sizes and
// the upper and lower bound from the FindSampleBound function
......@@ -141,11 +141,11 @@ ListSampleToHistogramListGenerator< TListSample,
// Create a new histogrma for this component
m_HistogramList->PushBack(HistogramType::New());
m_HistogramList->Back()->SetClipBinsAtEnds(clipBinsAtEnds);
m_HistogramList->Back()->Initialize(m_Size, comp_lower, comp_upper) ;
m_HistogramList->Back()->Initialize(m_Size, comp_lower, comp_upper);
typename TListSample::ConstIterator iter = m_List->Begin() ;
typename TListSample::ConstIterator last = m_List->End() ;
typename HistogramType::IndexType index ;
typename TListSample::ConstIterator iter = m_List->Begin();
typename TListSample::ConstIterator last = m_List->End();
typename HistogramType::IndexType index;
typename HistogramType::MeasurementVectorType hvector;
while (iter != last)
......@@ -154,16 +154,16 @@ ListSampleToHistogramListGenerator< TListSample,
m_HistogramList->Back()->GetIndex(hvector,index);
if (!m_HistogramList->Back()->IsIndexOutOfBounds(index))
{