diff --git a/Modules/Filtering/Contrast/include/otbCLHistogramEqualizationFilter.h b/Modules/Filtering/Contrast/include/otbCLHistogramEqualizationFilter.h index 1101e282fafeda3fee06f1691ee7281b18b9bb11..ca132ef814d8d5cca323b4407425bda63486dbc1 100644 --- a/Modules/Filtering/Contrast/include/otbCLHistogramEqualizationFilter.h +++ b/Modules/Filtering/Contrast/include/otbCLHistogramEqualizationFilter.h @@ -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; }; diff --git a/Modules/Filtering/Contrast/include/otbCLHistogramEqualizationFilter.txx b/Modules/Filtering/Contrast/include/otbCLHistogramEqualizationFilter.txx index 6dc123128d525cf2a2a923e7df81f3422d6c7b84..7db3bf77174e37dc1fc2d49187a0b391ee318e44 100644 --- a/Modules/Filtering/Contrast/include/otbCLHistogramEqualizationFilter.txx +++ b/Modules/Filtering/Contrast/include/otbCLHistogramEqualizationFilter.txx @@ -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; } diff --git a/Modules/Filtering/Contrast/otb-module.cmake b/Modules/Filtering/Contrast/otb-module.cmake index 4157167c67f66825557472f277817257724738db..58c014ca07a0434a46052b4eaba0806f6d24a986 100644 --- a/Modules/Filtering/Contrast/otb-module.cmake +++ b/Modules/Filtering/Contrast/otb-module.cmake @@ -22,6 +22,7 @@ set(DOCUMENTATION "work in progress") otb_module(OTBContrast DEPENDS + OTBImageManipulation OTBITK OTBCommon OTBImageBase