Skip to content
Snippets Groups Projects
Commit 512485cc authored by Antoine Regimbeau's avatar Antoine Regimbeau
Browse files

REFAC : building pipeline in the CLAHE class constructor

parent f9ae8d5e
No related branches found
No related tags found
No related merge requests found
......@@ -23,9 +23,12 @@
#include "itkImageToImageFilter.h"
#include "otbImage.h"
#include "otbVectorImage.h"
#include "otbComputeHistoFilter.h"
#include "otbComputeGainLutFilter.h"
#include "otbApplyGainFilter.h"
#include "itkStreamingImageFilter.h"
#include "otbInPlacePassFilter.h"
namespace otb
{
......@@ -50,20 +53,77 @@ public :
typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
typedef otb::VectorImage< int , 2 > HistogramType;
typedef itk::StreamingImageFilter< HistogramType , HistogramType >
StreamingImageFilter;
typedef otb::InPlacePassFilter < InputImageType > BufferFilter;
typedef otb::ComputeHistoFilter< InputImageType , HistogramType >
HistoFilter;
typedef otb::ComputeGainLutFilter< HistogramType , HistogramType >
GainLutFilter;
typedef otb::ApplyGainFilter< InputImageType , HistogramType , OutputImageType >
ApplyGainFilter;
typedef typename InputImageType::PixelType InputPixelType;
typedef typename OutputImageType::RegionType OutputImageRegionType;
/** Method for creation through the object factory. */
itkNewMacro(Self)
/** Run-time type information (and related methods). */
itkTypeMacro(CLHistogramEqualizationFilter, ImageToImageFilter)
itkGetMacro(Min, InputPixelType)
itkSetMacro(Min, InputPixelType)
itkGetMacro(Max, InputPixelType)
itkSetMacro(Max, InputPixelType)
itkGetMacro(NbBin, unsigned long)
itkSetMacro(NbBin, unsigned long)
itkSetMacro(ThumbSize, typename InputImageType::SizeType)
itkGetMacro(ThumbSize, typename InputImageType::SizeType)
itkGetMacro(Threshold, double)
itkSetMacro(Threshold, double)
itkGetMacro(NoData, InputPixelType)
itkSetMacro(NoData, InputPixelType)
itkBooleanMacro(NoDataFlag)
itkGetMacro(NoDataFlag, bool)
itkSetMacro(NoDataFlag, bool)
protected :
CLHistogramEqualizationFilter();
~CLHistogramEqualizationFilter() override {}
void PrintSelf(std::ostream& os, itk::Indent indent) const override ;
void BeforeThreadedGenerateData() override;
void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
itk::ThreadIdType threadId) override;
private :
CLHistogramEqualizationFilter(const Self &) = delete ;
void operator =(const Self&) = delete ;
void operator =(const Self&) = delete ;
typename HistoFilter::Pointer m_HistoFilter;
typename GainLutFilter::Pointer m_GainLutFilter;
typename ApplyGainFilter::Pointer m_ApplyGainFilter;
typename StreamingImageFilter::Pointer m_StreamingImageFilter;
typename BufferFilter::Pointer m_BufferFilter;
InputPixelType m_Min , m_Max , m_NoData;
unsigned long m_NbBin;
typename InputImageType::SizeType m_ThumbSize;
double m_Threshold , m_Step;
bool m_NoDataFlag;
};
......
......@@ -31,9 +31,42 @@ namespace otb
{
template < class TInputImage , class TOutputImage >
CLHistogramEqualizationFilter < TInputImage , TOutputImage >
::CLHistogramEqualizationFilter()
::CLHistogramEqualizationFilter():
m_HistoFilter( HistoFilter::New() ) ,
m_GainLutFilter ( GainLutFilter::New() ) ,
m_ApplyGainFilter ( ApplyGainFilter::New() ) ,
m_StreamingImageFilter ( StreamingImageFilter::New() ) ,
m_BufferFilter ( BufferFilter::New() )
{
m_Min = std::numeric_limits< InputPixelType >::quiet_NaN();
m_Max = std::numeric_limits< InputPixelType >::quiet_NaN();
m_NbBin = 256;
m_Threshold = std::numeric_limits< double >::max();
m_NoDataFlag = false;
m_NoData = std::numeric_limits< InputPixelType >::quiet_NaN();
m_ThumbSize.Fill(0);
m_Step = -1;
m_HistoFilter->SetInput( this->GetInput() );
m_GainLutFilter->SetInput( m_HistoFilter->GetOutput() );
m_StreamingImageFilter->SetInput( m_GainLutFilter->GetOutput() );
m_BufferFilter->SetInput( this->GetInput() );
m_ApplyGainFilter->SetInputLut( m_StreamingImageFilter->GetOutput() );
m_ApplyGainFilter->SetInputImage( m_BufferFilter->GetOutput() );
}
template < class TInputImage , class TOutputImage >
void CLHistogramEqualizationFilter < TInputImage , TOutputImage >
::BeforeGenerateData()
{
}
template < class TInputImage , class TOutputImage >
void CLHistogramEqualizationFilter < TInputImage , TOutputImage >
::ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
itk::ThreadIdType threadId)
{
}
/**
......@@ -44,6 +77,14 @@ void CLHistogramEqualizationFilter < TInputImage , TOutputImage >
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
os << indent << "Minimum : " << m_Min << std::endl;
os << indent << "Maximum : " << m_Max << std::endl;
os << indent << "Bin Number : " << m_NbBin << std::endl;
os << indent << "Thumbnail size : " << m_ThumbSize << std::endl;
os << indent << "Threshold value : " << m_Threshold << std::endl;
os << indent << "Is no data activated : " << m_NoDataFlag << std::endl;
os << indent << "No Data : " << m_NoData << std::endl;
os << indent << "Step : " << m_Step << std::endl;
}
......
......@@ -22,6 +22,7 @@ set(DOCUMENTATION "work in progress")
otb_module(OTBContrast
DEPENDS
OTBImageManipulation
OTBITK
OTBCommon
OTBImageBase
......
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