Skip to content
Snippets Groups Projects
Commit 2a4fbe18 authored by Rashad Kanavath's avatar Rashad Kanavath
Browse files

Revert "Merge branches 'app_domain_transform' and 'develop' of...

Revert "Merge branches 'app_domain_transform' and 'develop' of https://git.orfeo-toolbox.org/git/otb into develop"

This reverts commit b323ae23, reversing
changes made to 2dc3ad09.
parent b323ae23
No related branches found
No related tags found
No related merge requests found
Showing
with 15 additions and 1575 deletions
project(OTBAppDomainTransform)
otb_module_impl()
otb_create_application(
NAME DomainTransform
SOURCES otbDomainTransform.cxx
LINK_LIBRARIES ${${otb-module}_LIBRARIES})
/*=========================================================================
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 "otbWrapperApplication.h"
#include "otbWrapperApplicationFactory.h"
#include "otbWaveletImageFilter.h"
#include "otbWaveletInverseImageFilter.h"
#include "otbWaveletGenerator.h"
#include <itkConfigure.h>
#include <itkForwardFFTImageFilter.h>
#include <itkInverseFFTImageFilter.h>
#include <itkUnaryFunctorImageFilter.h>
namespace otb
{
namespace Wrapper
{
template< class TInput, class TOutput>
class FromComplexPixel
{
public:
FromComplexPixel ( ) { };
~FromComplexPixel( ) { };
bool operator!=( const FromComplexPixel & ) const
{
return false;
}
bool operator==( const FromComplexPixel & other ) const
{
return !(*this != other);
}
inline TOutput operator( )( const TInput & A ) const
{
TOutput out;
out.SetSize(2);
out[0] = A.real();
out[1] = A.imag();
return out;
}
};
template< class TInput, class TOutput>
class ToComplexPixel
{
public:
ToComplexPixel ( ) { };
~ToComplexPixel( ) { };
bool operator!=( const ToComplexPixel & ) const
{
return false;
}
bool operator==( const ToComplexPixel & other ) const
{
return !(*this != other);
}
inline TOutput operator( )( const TInput & A ) const
{
TOutput out(A[0], A[1]);
return out;
}
};
class DomainTransform : public Application
{
public:
/** Standard class typedefs. */
typedef DomainTransform Self;
typedef Application Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef float TInputPixel;
typedef float TOutputPixel;
/** Standard macro */
itkNewMacro(Self);
itkTypeMacro(Self, otb::Application);
private:
void DoInit() ITK_OVERRIDE
{
SetName("DomainTransform");
const char * app_descr = "Domain Transform application for wavelet and fourier";
SetDescription(app_descr);
// Documentation
SetDocName(app_descr);
SetDocLongDescription("TODO");
SetDocLimitations("None");
SetDocAuthors("OTB-Team");
SetDocSeeAlso("otbWaveletImageFilter, otbWaveletInverseImageFilter, otbWaveletTransform");
AddDocTag(Tags::Filter);
AddParameter(ParameterType_InputImage, "in", "Input Image");
SetParameterDescription("in", "This will take an input image to be transformed image. For FFT inverse transform, it expects a complex image as two-band image in which first band represent real part and second band represent imaginary part.");
AddRAMParameter();
AddParameter(ParameterType_Choice, "mode", "mode");
SetParameterDescription("mode", "This parameter allows one to select between fft(fourier) and wavelet");
AddChoice("mode.fft", "FFT transform");
SetParameterDescription("mode.fft", "FFT transform");
AddChoice("mode.wavelet", "wavelet");
SetParameterDescription("mode.wavelet", "Wavelet transform");
AddParameter(ParameterType_Choice,
"mode.wavelet.form",
"Select wavelet form. default is HAAR");
AddChoice("mode.wavelet.form.haar", "HAAR");
AddChoice("mode.wavelet.form.db4", "DAUBECHIES4");
AddChoice("mode.wavelet.form.db6", "DAUBECHIES6");
AddChoice("mode.wavelet.form.db8", "DAUBECHIES8");
AddChoice("mode.wavelet.form.db12", "DAUBECHIES12");
AddChoice("mode.wavelet.form.db20", "DAUBECHIES20");
AddChoice("mode.wavelet.form.sb24", "SPLINE_BIORTHOGONAL_2_4");
AddChoice("mode.wavelet.form.sb44", "SPLINE_BIORTHOGONAL_4_4");
AddChoice("mode.wavelet.form.sym8", "SYMLET8");
//Default value
SetParameterString("mode", "wavelet");
SetParameterString("mode.wavelet.form", "haar");
AddParameter(ParameterType_Choice,
"dir",
"dir: forward/inverse");
AddChoice("dir.fwd", "fwd");
AddChoice("dir.inv", "inv");
AddParameter(ParameterType_OutputImage, "out", "Output Image");
SetParameterDescription("out", "This parameter holds the output file name to which transformed image will be written. This has a slightly different behaviour depending on transform type. \n For Wavelet, output is a single band image for both forward and inverse transform. \n For FFT forward transform, output is two band image where first band represents real part and second band represents imaginary part of a complex image.");
SetDocExampleParameterValue("in", "input.tif");
SetDocExampleParameterValue("mode.wavelet.form", "haar");
SetDocExampleParameterValue("out", "output_wavelet_haar.tif");
}
void DoUpdateParameters() ITK_OVERRIDE
{
// wavelet and fourier are mutually exclusive parameters.
// check it here
#if 0
if ( HasUserValue("mode.wavelet.form") &&
GetParameterString("mode") == "fft"
)
{
std::stringstream oss;
oss << std::endl
<< this->GetNameOfClass() << "::DoUpdateParameters() "
<< "Cannot use 'mode.wavelet.form' and '-mode fft' at same time"
<< std::endl;
throw std::runtime_error( oss.str() );
}
#endif
}
void DoExecute() ITK_OVERRIDE
{
int dir = GetParameterInt("dir");
int mode = GetParameterInt("mode");
if( dir != 0 && dir != 1)
{
itkExceptionMacro( << "-dir is '"
<< dir << "'."
<< "It must be either 'fwd' or 'inv'");
}
if( mode != 0 && mode != 1)
{
itkExceptionMacro( << "mode is '"
<< mode << "'."
<< "It must must be either 'fft' or 'wavelet'");
}
if ( mode == 1)
{
int wavelet_type = GetParameterInt("mode.wavelet.form");
switch (wavelet_type)
{
case 0:
DoWaveletTransform<otb::Wavelet::HAAR> ( dir );
break;
case 1:
DoWaveletTransform< otb::Wavelet::DB4 > ( dir );
break;
case 2:
DoWaveletTransform<otb::Wavelet::DB4> ( dir );
break;
case 3:
DoWaveletTransform<otb::Wavelet::DB6> ( dir );
break;
case 4:
DoWaveletTransform<otb::Wavelet::DB8> ( dir );
break;
case 5:
DoWaveletTransform<otb::Wavelet::DB12> ( dir );
break;
case 6:
DoWaveletTransform<otb::Wavelet::DB20> ( dir );
break;
case 7:
DoWaveletTransform<otb::Wavelet::SPLINE_BIORTHOGONAL_2_4 > ( dir );
break;
case 8:
DoWaveletTransform<otb::Wavelet::SPLINE_BIORTHOGONAL_4_4> ( dir );
break;
case 9:
DoWaveletTransform<otb::Wavelet::SYMLET8> ( dir );
break;
default:
itkExceptionMacro( << "Invalid wavelet type: '" << wavelet_type << "'");
break;
}
}
// fft ttransform
else
{
//forward fft
if (dir == 0 )
{
typedef otb::Image<TInputPixel> TInputImage;
typedef typename TInputImage::Pointer TInputImagePointer;
//get input paramter as otb::Image<TInputPixel>
TInputImagePointer inImage = GetParameterImage<TInputImage>("in");
inImage->UpdateOutputInformation();
//typedef itk::::ForwardFFTImageFilter over otbImage< TInputPixel >
typedef itk::ForwardFFTImageFilter < TInputImage> FFTFilter;
FFTFilter::Pointer fwdFilter = FFTFilter::New();
fwdFilter->SetInput( inImage );
//typedef VectorImage for output of UnaryFunctorImageFilter
typedef otb::VectorImage<TOutputPixel> TOutputImage;
//UnaryFunctorImageFilter for Complex to VectorImage
typedef itk::UnaryFunctorImageFilter<
typename FFTFilter::OutputImageType,
TOutputImage,
FromComplexPixel<
typename FFTFilter::OutputImageType::PixelType,
TOutputImage::PixelType> > UnaryFunctorImageFilter;
//convert complex pixel to variable length vector
//with unaryfunctor image filter
UnaryFunctorImageFilter::Pointer unaryFunctorImageFilter
= UnaryFunctorImageFilter::New();
unaryFunctorImageFilter->SetInput(fwdFilter->GetOutput());
unaryFunctorImageFilter->Update();
//set output image
SetParameterOutputImage<TOutputImage>
( "out", unaryFunctorImageFilter->GetOutput() );
}
//inverse fft
else
{
typedef otb::VectorImage<TInputPixel> TInputImage;
typedef typename TInputImage::Pointer TInputImagePointer;
TInputImagePointer inImage = GetParameterImage("in");
inImage->UpdateOutputInformation();
// typedef TComplexImage for InverseFFTImageFilter input
// This a image type of std::complex<TInputPixel>
typedef otb::Image<
std::complex<TInputPixel>, 2 > TComplexImage;
//typedef TOutputImage for InverseFFTImageFilter output
typedef otb::Image< TOutputPixel > TOutputImage;
// a unary functor to convert vectorimage to complex image
typedef itk::UnaryFunctorImageFilter
<TInputImage,
TComplexImage,
ToComplexPixel
<TInputImage::PixelType,
TComplexImage::PixelType> > UnaryFunctorImageFilter;
UnaryFunctorImageFilter::Pointer
unary_filter = UnaryFunctorImageFilter::New();
unary_filter->SetInput(inImage);
//typedef itk::::InverseFFTImageFilter over TComplexImage
typedef itk::InverseFFTImageFilter
< TComplexImage,
TOutputImage > FFTFilter;
FFTFilter::Pointer invFilter = FFTFilter::New();
invFilter->SetInput( unary_filter->GetOutput() );
invFilter->Update();
//set output image
SetParameterOutputImage<TOutputImage>( "out", invFilter->GetOutput() );
}
}
}
template<otb::Wavelet::Wavelet TWaveletOperator>
void DoWaveletTransform(const int dir,
const std::string inkey = "in",
const std::string outkey = "out")
{
typedef otb::Image< TInputPixel > TInputImage;
typedef otb::Image< TOutputPixel > TOutputImage;
typedef typename TInputImage::Pointer TInputImagePointer;
TInputImagePointer inImage = GetParameterImage<TInputImage>(inkey);
inImage->UpdateOutputInformation();
if( dir == 0)
{
typedef otb::WaveletImageFilter<
TInputImage,
TOutputImage,
TWaveletOperator> TWaveletImageFilter;
typedef typename
TWaveletImageFilter::Pointer
TWaveletImageFilterPointer;
TWaveletImageFilterPointer waveletImageFilter =
TWaveletImageFilter::New();
waveletImageFilter->SetInput(inImage);
waveletImageFilter->Update();
SetParameterOutputImage<TOutputImage>(outkey, waveletImageFilter->GetOutput() );
}
else
{
typedef otb::WaveletInverseImageFilter<
TInputImage,
TOutputImage,
TWaveletOperator > TWaveletImageFilter;
typedef typename
TWaveletImageFilter::Pointer
TWaveletImageFilterPointer;
TWaveletImageFilterPointer waveletImageFilter =
TWaveletImageFilter::New();
waveletImageFilter->SetInput(inImage);
waveletImageFilter->Update();
SetParameterOutputImage<TOutputImage>( outkey, waveletImageFilter->GetOutput() );
}
}
};
}
}
OTB_APPLICATION_EXPORT(otb::Wrapper::DomainTransform)
set(DOCUMENTATION "TODO")
otb_module(OTBAppDomainTransform
DEPENDS
OTBWavelet
OTBApplicationEngine
TEST_DEPENDS
OTBTestKernel
OTBCommandLine
DESCRIPTION
"${DOCUMENTATION}"
)
......@@ -83,7 +83,7 @@ SubsampleImageFilter<TInputImage, TOutputImage, TDirectionOfTransformation>
{
Superclass::CallCopyOutputRegionToInputRegion(destRegion, srcRegion);
if (DirectionOfTransformation == Wavelet::INVERSE)
if (static_cast<int>(DirectionOfTransformation) == Wavelet::INVERSE)
{
typename OutputImageRegionType::IndexType srcIndex = srcRegion.GetIndex();
typename OutputImageRegionType::SizeType srcSize = srcRegion.GetSize();
......@@ -112,7 +112,7 @@ SubsampleImageFilter<TInputImage, TOutputImage, TDirectionOfTransformation>
{
Superclass::CallCopyInputRegionToOutputRegion(destRegion, srcRegion);
if (DirectionOfTransformation == Wavelet::INVERSE)
if (static_cast<int>(DirectionOfTransformation) == Wavelet::INVERSE)
{
typename InputImageRegionType::IndexType srcIndex = srcRegion.GetIndex();
typename InputImageRegionType::SizeType srcSize = srcRegion.GetSize();
......@@ -161,7 +161,8 @@ SubsampleImageFilter<TInputImage, TOutputImage, TDirectionOfTransformation>
SubsampledImageRegionConstIterator<InputImageType> inputIter
(this->GetInput(), inputRegionForThread);
if (DirectionOfTransformation == Wavelet::FORWARD)
if (static_cast<int>(itkGetStaticConstMacro(DirectionOfTransformation))
== static_cast<int>(Wavelet::FORWARD))
{
inputIter.SetSubsampleFactor(GetSubsampleFactor());
inputIter.GoToBegin();
......
......@@ -399,11 +399,6 @@ protected:
WaveletFilterBank();
~WaveletFilterBank() ITK_OVERRIDE {}
void VerifyInputInformation() ITK_OVERRIDE
{
}
/** GenerateOutputInformation
* Set the size of the output image depending on the decimation factor
* Copy information from the input image if existing.
......
......@@ -27,6 +27,9 @@
#include "itkPeriodicBoundaryCondition.h"
// FIXME
#define __myDebug__ 0
namespace otb {
/**
......@@ -63,9 +66,11 @@ WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD>
if (GetSubsampleImageFactor() == 1) return;
#if __myDebug__
otbGenericMsgDebugMacro(<< " down sampling output regions by a factor of " << GetSubsampleImageFactor());
otbGenericMsgDebugMacro(<< "initial region " << this->GetInput()->GetLargestPossibleRegion().GetSize()[0]
<< "," << this->GetInput()->GetLargestPossibleRegion().GetSize()[1]);
#endif
OutputImageRegionType newRegion;
this->CallCopyInputRegionToOutputRegion(newRegion, this->GetInput()->GetLargestPossibleRegion());
......@@ -75,8 +80,9 @@ WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD>
this->GetOutput(i)->SetRegions(newRegion);
}
#if __myDebug__
otbGenericMsgDebugMacro(<< "new region output " << newRegion.GetSize()[0] << "," << newRegion.GetSize()[1]);
#endif
}
template <class TInputImage, class TOutputImage, class TWaveletOperator>
......@@ -636,18 +642,21 @@ WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE>
}
}
#if __myDebug__
otbGenericMsgDebugMacro(<< " up sampling output regions by a factor of " << GetSubsampleImageFactor());
otbGenericMsgDebugMacro(<< "initial region "
<< this->GetInput(0)->GetLargestPossibleRegion().GetSize()[0]
<< "," << this->GetInput(0)->GetLargestPossibleRegion().GetSize()[1]);
#endif
OutputImageRegionType newRegion;
this->CallCopyInputRegionToOutputRegion(newRegion, this->GetInput(0)->GetLargestPossibleRegion());
this->GetOutput()->SetRegions(newRegion);
#if __myDebug__
otbGenericMsgDebugMacro(<< "new region output " << newRegion.GetSize()[0] << "," << newRegion.GetSize()[1]);
#endif
}
template <class TInputImage, class TOutputImage, class TWaveletOperator>
......
/*=========================================================================
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 otbWaveletImageFilter_h
#define otbWaveletImageFilter_h
#include "otbWaveletOperator.h"
#include "otbWaveletFilterBank.h"
#include "otbWaveletTransform.h"
#include "otbWaveletsBandsListToWaveletsSynopsisImageFilter.h"
namespace otb {
/** \class WaveletImageFilter
* \brief
*
* \ingroup OTBWavelet
* \sa WaveletInverseImageFilter
*/
template < class TInputImage,
class TOutputImage,
Wavelet::Wavelet TMotherWaveletOperator >
class WaveletImageFilter :
public itk::ImageToImageFilter< TInputImage, TOutputImage >
{
public:
/** Standard class typedefs. */
typedef TInputImage InputImageType;
typedef TOutputImage OutputImageType;
itkStaticConstMacro( ImageDimension, unsigned int, InputImageType::ImageDimension );
itkStaticConstMacro( MotherWaveletOperator, short, TMotherWaveletOperator );
itkStaticConstMacro( DirectionOfTransformation, short, otb::Wavelet::FORWARD );
typedef WaveletImageFilter<InputImageType,OutputImageType, TMotherWaveletOperator> Self;
typedef itk::ImageToImageFilter<InputImageType, OutputImageType> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef typename InputImageType::PixelType InputPixelType;
typedef otb::WaveletOperator< TMotherWaveletOperator, otb::Wavelet::FORWARD, InputPixelType, ImageDimension >
WaveletOperatorType;
typedef otb::WaveletFilterBank< InputImageType, InputImageType, WaveletOperatorType, otb::Wavelet::FORWARD >
FilterBankType;
typedef otb::WaveletTransform< InputImageType, InputImageType, FilterBankType, otb::Wavelet::FORWARD >
WaveletTransformFilterType;
typedef typename WaveletTransformFilterType::Pointer
WaveletTransformFilterPointerType;
typedef typename WaveletTransformFilterType::OutputImageListType
WaveletTransformFilterOutputImageListType;
typedef otb::WaveletsBandsListToWaveletsSynopsisImageFilter<WaveletTransformFilterOutputImageListType, OutputImageType>
WaveletBandsListToWaveletsSynopsisImageFilterType;
typedef typename WaveletBandsListToWaveletsSynopsisImageFilterType::Pointer
WaveletBandsListToWaveletsSynopsisImageFilterPointerType;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(WaveletImageFilter, ImageToImageFilter);
itkGetMacro(NumberOfDecompositions,unsigned int);
itkSetMacro(NumberOfDecompositions,unsigned int);
protected:
WaveletImageFilter();
virtual ~WaveletImageFilter();
virtual void GenerateInputRequestedRegion();
virtual void GenerateData();
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
WaveletImageFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
WaveletTransformFilterPointerType m_WaveletTransform;
WaveletBandsListToWaveletsSynopsisImageFilterPointerType m_WaveletBandsListToWaveletsSynopsis;
unsigned int m_NumberOfDecompositions;
};
}
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbWaveletImageFilter.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.
=========================================================================*/
#ifndef otbWaveletImageFilter_txx
#define otbWaveletImageFilter_txx
#include "otbWaveletImageFilter.h"
namespace otb
{
/** Constructor */
template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator>
WaveletImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator>
::WaveletImageFilter() : m_NumberOfDecompositions(2)
{
m_WaveletTransform = WaveletTransformFilterType::New();
m_WaveletTransform->SetSubsampleImageFactor(2);
m_WaveletBandsListToWaveletsSynopsis = WaveletBandsListToWaveletsSynopsisImageFilterType::New();
// Force to use a unique thread otherwise there is a bug on Mac
//m_WaveletBandsListToWaveletsSynopsis->SetNumberOfThreads(1);
m_WaveletBandsListToWaveletsSynopsis->SetInput( m_WaveletTransform->GetOutput() );
}
/** Destructor */
template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator>
WaveletImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator>
::~WaveletImageFilter()
{
}
/**
* GenerateInputRequestedRegion
*/
template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator>
void
WaveletImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator>
::GenerateInputRequestedRegion(void)
{
// call the superclass' implementation of this method
Superclass::GenerateInputRequestedRegion();
// get pointers to the inputs
typename InputImageType::Pointer input =
const_cast<InputImageType *> (this->GetInput());
if ( !input )
{
return;
}
input->SetRequestedRegionToLargestPossibleRegion();
}
/**
* Main computation method
*/
template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator>
void
WaveletImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator>
::GenerateData()
{
m_WaveletTransform->SetInput( this->GetInput() );
m_WaveletTransform->SetNumberOfDecompositions( m_NumberOfDecompositions );
m_WaveletBandsListToWaveletsSynopsis->GraftOutput( this->GetOutput() );
m_WaveletBandsListToWaveletsSynopsis->Update();
this->GraftOutput( m_WaveletBandsListToWaveletsSynopsis->GetOutput() );
}
/**
* PrintSelf Method
*/
template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator>
void
WaveletImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
}
#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.
=========================================================================*/
#ifndef otbWaveletInverseImageFilter_h
#define otbWaveletInverseImageFilter_h
#include "otbWaveletOperator.h"
#include "otbWaveletFilterBank.h"
#include "otbWaveletTransform.h"
#include "otbWaveletsSynopsisImageToWaveletsBandsListFilter.h"
namespace otb {
/** \class WaveletInverseImageFilter
* \brief
*
* \ingroup OTBWavelet
* \sa WaveletImageFilter
*/
template < class TInputImage,
class TOutputImage,
Wavelet::Wavelet TMotherWaveletOperator >
class WaveletInverseImageFilter :
public itk::ImageToImageFilter< TInputImage, TOutputImage >
{
public:
/** Standard class typedefs. */
typedef TInputImage InputImageType;
typedef TOutputImage OutputImageType;
itkStaticConstMacro( ImageDimension, unsigned int, InputImageType::ImageDimension );
itkStaticConstMacro( MotherWaveletOperator, short, TMotherWaveletOperator );
itkStaticConstMacro( DirectionOfTransformation, short , otb::Wavelet::FORWARD );
typedef WaveletInverseImageFilter<InputImageType,OutputImageType, TMotherWaveletOperator> Self;
typedef itk::ImageToImageFilter<InputImageType, OutputImageType> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef typename InputImageType::PixelType InputPixelType;
typedef typename OutputImageType::PixelType OutputPixelType;
typedef otb::WaveletOperator< TMotherWaveletOperator, otb::Wavelet::INVERSE, OutputPixelType, ImageDimension >
WaveletOperatorType;
typedef otb::WaveletFilterBank< OutputImageType, OutputImageType, WaveletOperatorType, otb::Wavelet::INVERSE >
FilterBankType;
typedef otb::WaveletTransform< OutputImageType, OutputImageType, FilterBankType, otb::Wavelet::INVERSE >
WaveletInverseTransformFilterType;
typedef typename WaveletInverseTransformFilterType::Pointer
WaveletInverseTransformFilterPointerType;
typedef otb::WaveletsSynopsisImageToWaveletsBandsListFilter<InputImageType, typename WaveletInverseTransformFilterType::InputImageListType>
WaveletsSynopsisImageToWaveletsBandsListFilterType;
typedef typename WaveletsSynopsisImageToWaveletsBandsListFilterType::Pointer
WaveletsSynopsisImageToWaveletsBandsListFilterPointerType;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(WaveletInverseImageFilter, ImageToImageFilter);
itkGetMacro(NumberOfDecompositions,unsigned int);
itkSetMacro(NumberOfDecompositions,unsigned int);
/** If the filter is modified, the internal filters need to be modified too */
virtual void Modified() const;
protected:
WaveletInverseImageFilter();
virtual ~WaveletInverseImageFilter();
virtual void GenerateInputRequestedRegion();
virtual void GenerateData();
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
WaveletInverseImageFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
WaveletsSynopsisImageToWaveletsBandsListFilterPointerType m_SynopsisImageToWaveletsBandsList;
WaveletInverseTransformFilterPointerType m_WaveletTransform;
unsigned int m_NumberOfDecompositions;
};
}
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbWaveletInverseImageFilter.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.
=========================================================================*/
#ifndef __otbWaveletInverseImageFilter_txx
#define __otbWaveletInverseImageFilter_txx
#include "otbWaveletInverseImageFilter.h"
namespace otb
{
/** Constructor */
template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator>
WaveletInverseImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator>
::WaveletInverseImageFilter() : m_NumberOfDecompositions(2)
{
m_SynopsisImageToWaveletsBandsList = WaveletsSynopsisImageToWaveletsBandsListFilterType::New();
//m_SynopsisImageToWaveletsBandsList->SetNumberOfThreads(1);
m_SynopsisImageToWaveletsBandsList->SetDecimationRatio(2);
m_WaveletTransform = WaveletInverseTransformFilterType::New();
m_WaveletTransform->SetSubsampleImageFactor(2);
m_WaveletTransform->SetInput( m_SynopsisImageToWaveletsBandsList->GetOutput() );
}
/** Destructor */
template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator>
WaveletInverseImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator>
::~WaveletInverseImageFilter()
{
}
/** Destructor */
template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator>
void
WaveletInverseImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator>
::Modified() const
{
Superclass::Modified();
m_SynopsisImageToWaveletsBandsList->Modified();
m_WaveletTransform->Modified();
}
/**
* GenerateInputRequestedRegion
*/
template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator>
void
WaveletInverseImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator>
::GenerateInputRequestedRegion(void)
{
// call the superclass' implementation of this method
Superclass::GenerateInputRequestedRegion();
// get pointers to the inputs
typename InputImageType::Pointer input =
const_cast<InputImageType *> (this->GetInput());
if ( !input )
{
return;
}
input->SetRequestedRegionToLargestPossibleRegion();
}
/**
* Main computation method
*/
template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator>
void
WaveletInverseImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator>
::GenerateData()
{
m_SynopsisImageToWaveletsBandsList->SetInput( this->GetInput() );
m_SynopsisImageToWaveletsBandsList->SetNumberOfLevels( m_NumberOfDecompositions );
m_WaveletTransform->GraftOutput( this->GetOutput() );
m_WaveletTransform->Update();
this->GraftOutput( m_WaveletTransform->GetOutput() );
}
/**
* PrintSelf Method
*/
template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator>
void
WaveletInverseImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
}
#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.
=========================================================================*/
#ifndef otbWaveletsBandsListToWaveletsSynopsisImageFilter_h
#define otbWaveletsBandsListToWaveletsSynopsisImageFilter_h
#include "otbImageListToImageFilter.h"
namespace otb
{
/** \class WaveletsBandsListToWaveletsSynopsisImageFilter
* \brief Converts a list of wavelets bands to the traditionnal multi-resolution wavelets view
*
* The decimation ratio is taken into account.
*
* \ingroup Streamed, Threaded
*/
template <class TImageList, class TImage>
class ITK_EXPORT WaveletsBandsListToWaveletsSynopsisImageFilter
: public ImageListToImageFilter<typename TImageList::ImageType, TImage>
{
public:
/** Standard typedefs */
typedef WaveletsBandsListToWaveletsSynopsisImageFilter Self;
typedef ImageListToImageFilter<
typename TImageList::ImageType,TImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Type macro */
itkNewMacro(Self);
/** Useful typedefs */
typedef TImageList InputImageListType;
typedef typename InputImageListType::ImageType InputImageType;
typedef TImage OutputImageType;
typedef typename OutputImageType::RegionType RegionType;
/** Creation through object factory macro */
itkTypeMacro(WaveletsBandsListToWaveletsSynopsisImageFilter,ImageToImageListFilter);
/** Set the decimation ratio */
itkSetMacro(DecimationRatio,unsigned int);
/** Get the decimation ratio */
itkGetMacro(DecimationRatio,unsigned int);
protected:
/** Main computation method */
virtual void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId);
/** GenerateOutputInformation
* Set the number of bands of the output.
* Copy informations from the first image of the list if existing.
**/
virtual void GenerateOutputInformation(void);
/**
* GenerateInputRequestedRegion
* Set the requested region of each image in the list.
*/
virtual void GenerateInputRequestedRegion(void);
/** Constructor */
WaveletsBandsListToWaveletsSynopsisImageFilter();
/** Destructor */
virtual ~WaveletsBandsListToWaveletsSynopsisImageFilter();
/**PrintSelf method */
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
WaveletsBandsListToWaveletsSynopsisImageFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
/** The decimation ratio used in the decomposition */
unsigned int m_DecimationRatio;
};
}// End namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbWaveletsBandsListToWaveletsSynopsisImageFilter.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.
=========================================================================*/
#ifndef otbWaveletsBandsListToWaveletsSynopsisImageFilter_txx
#define otbWaveletsBandsListToWaveletsSynopsisImageFilter_txx
#include "otbWaveletsBandsListToWaveletsSynopsisImageFilter.h"
#include "itkImageRegionIterator.h"
#include "itkImageRegionConstIterator.h"
#include "otbMacro.h"
#include "itkProgressReporter.h"
namespace otb
{
/** Constructor */
template <class TImageList, class TImage>
WaveletsBandsListToWaveletsSynopsisImageFilter<TImageList,TImage>
::WaveletsBandsListToWaveletsSynopsisImageFilter() : m_DecimationRatio(2)
{}
/** Destructor */
template <class TImageList, class TImage>
WaveletsBandsListToWaveletsSynopsisImageFilter<TImageList,TImage>
::~WaveletsBandsListToWaveletsSynopsisImageFilter()
{}
/**
* GenerateOutputInformation
*/
template <class TImageList, class TImage>
void
WaveletsBandsListToWaveletsSynopsisImageFilter<TImageList,TImage>
::GenerateOutputInformation(void)
{
// We must set the size of the output image to be twice the size of the last image
// of the image list, which is the first band.
if(this->GetOutput())
{
if (this->GetInput()->Size()>0)
{
// Retrieve the largest band
typename InputImageType::Pointer lastBand = this->GetInput()->Back();
// Retrieve the region of the largest band
RegionType largestBandRegion = lastBand->GetLargestPossibleRegion();
// Retrieve the size of the largest region
typename RegionType::SizeType outputSize = largestBandRegion.GetSize();
// Multiply this size by two
outputSize[0]*=m_DecimationRatio;
outputSize[1]*=m_DecimationRatio;
// Build the output region
RegionType outputLargestRegion;
outputLargestRegion.SetSize(outputSize);
// Copy information to the output image
this->GetOutput()->CopyInformation(lastBand);
this->GetOutput()->SetLargestPossibleRegion(outputLargestRegion);
}
}
}
/**
* GenerateInputRequestedRegion
*/
template <class TImageList, class TImage>
void
WaveletsBandsListToWaveletsSynopsisImageFilter<TImageList,TImage>
::GenerateInputRequestedRegion(void)
{
typename InputImageListType::Pointer inputPtr = this->GetInput();
typename InputImageListType::ConstIterator inputListIt = inputPtr->Begin();
while (inputListIt!=inputPtr->End())
{
inputListIt.Get()->SetRequestedRegionToLargestPossibleRegion();
++inputListIt;
}
}
/**
* Main computation method
*/
template <class TImageList, class TImage>
void
WaveletsBandsListToWaveletsSynopsisImageFilter<TImageList,TImage>
::ThreadedGenerateData(const RegionType & outputRegionForThread,
itk::ThreadIdType threadId)
{
// Retrieve input and output pointers
typename InputImageListType::Pointer inputPtr = this->GetInput();
typename OutputImageType::Pointer outputPtr = this->GetOutput();
// Set up progress reporting
itk::ProgressReporter progress(this,
threadId,
outputRegionForThread.GetNumberOfPixels());
// defines input and output iterators
typedef itk::ImageRegionConstIterator<InputImageType> InputIteratorType;
typedef itk::ImageRegionIterator<OutputImageType> OutputIteratorType;
// Set up an iterator on the input wavelets band
typename InputImageListType::ConstIterator inputListIt = inputPtr->Begin();
unsigned int bandIndex = 0;
// Compute number of decomposition levels
unsigned int numberOfDecompositionLevels = (inputPtr->Size()-1)/3;
// Retrieve the largest possible region size
typename RegionType::SizeType largestSize = outputPtr->GetLargestPossibleRegion().GetSize();
// Iterate on each band
for (;inputListIt!=inputPtr->End();++inputListIt,++bandIndex)
{
// Build a band offset
typename RegionType::OffsetType currentOffset;
currentOffset.Fill(0);
// Initialise Current level
unsigned int currentLevel = 0;
unsigned int currentSubBand = 0;
if(bandIndex > 0)
{
// Compute current level and sub band
currentLevel = 1 + (bandIndex-1)/3;
currentSubBand = (bandIndex-1)%3;
// Compute potentiel offset in x and y
unsigned int offsetX = largestSize[0]/(unsigned int)vcl_pow((double)m_DecimationRatio,(double)1+numberOfDecompositionLevels-currentLevel);
unsigned int offsetY = largestSize[1]/(unsigned int)vcl_pow((double)m_DecimationRatio,(double)1+numberOfDecompositionLevels-currentLevel);
// Compute final offset according to the subband index
if(currentSubBand == 0)
{
currentOffset[0]+=offsetX;
}
else if(currentSubBand == 1)
{
currentOffset[1]+=offsetY;
}
else
{
currentOffset[0]+=offsetX;
currentOffset[1]+=offsetY;
}
}
// Retrieve current band region
RegionType currentBandRegion = inputListIt.Get()->GetLargestPossibleRegion();
// Apply offset to get the current output region
RegionType currentOutputRegion = currentBandRegion;
typename RegionType::IndexType currentOutputIndex = currentBandRegion.GetIndex();
currentOutputIndex+=currentOffset;
currentOutputRegion.SetIndex(currentOutputIndex);
// Crop with the outputRegionForThread. If the crop fails,
// it means that currentOutputRegion is outside of outputRegionForThread,
// and in this case we skip to the next image in the list.
if(currentOutputRegion.Crop(outputRegionForThread))
{
// Compute the corresponding input region
RegionType currentInputRegion = currentBandRegion;
currentOutputIndex = currentOutputRegion.GetIndex();
typename RegionType::IndexType currentInputIndex = currentBandRegion.GetIndex();
for(unsigned int i = 0; i < InputImageType::ImageDimension;++i)
{
currentInputIndex[i]+=currentOutputIndex[i];
currentInputIndex[i]-=currentOffset[i];
}
currentInputRegion.SetSize(currentOutputRegion.GetSize());
currentInputRegion.SetIndex(currentInputIndex);
InputIteratorType inIt(inputListIt.Get(),currentInputRegion);
OutputIteratorType outIt(outputPtr,currentOutputRegion);
// Go to begin
inIt.GoToBegin();
outIt.GoToBegin();
// Copy pixels
while(!inIt.IsAtEnd() && !outIt.IsAtEnd())
{
// Copy pixel value
outIt.Set(static_cast<typename OutputImageType::InternalPixelType>(inIt.Get()));
// Step forward
++inIt;
++outIt;
progress.CompletedPixel();
}
}
}
}
/**
* PrintSelf Method
*/
template <class TImageType, class TImageList>
void
WaveletsBandsListToWaveletsSynopsisImageFilter<TImageType,TImageList>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
} // End namespace otb
#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.
=========================================================================*/
#ifndef otbWaveletsSynopsisImageToWaveletsBandsListFilter_h
#define otbWaveletsSynopsisImageToWaveletsBandsListFilter_h
#include "otbImageToImageListFilter.h"
#include "itkRegionOfInterestImageFilter.h"
namespace otb
{
/** \class WaveletsSynopsisImageToWaveletsBandsListFilter
* \brief This class convert the standard wavelets view to a list of bands.
*
* \ingroup Streamed
*/
template <class TImage, class TImageList>
class ITK_EXPORT WaveletsSynopsisImageToWaveletsBandsListFilter
: public ImageToImageListFilter<TImage,typename TImageList::ImageType>
{
public:
/** Standard typedefs */
typedef WaveletsSynopsisImageToWaveletsBandsListFilter Self;
typedef ImageToImageListFilter<TImage,
typename TImageList::ImageType> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Type macro */
itkNewMacro(Self);
/** Creation through object factory macro */
itkTypeMacro(WaveletsSynopsisImageToWaveletsBandsListFilter,ImageToImageListFilter);
/** Template parameters typedefs */
typedef TImage InputImageType;
typedef typename InputImageType::RegionType RegionType;
typedef TImageList OutputImageListType;
typedef typename OutputImageListType::ImageType OutputImageType;
typedef itk::RegionOfInterestImageFilter<
InputImageType,
InputImageType > ExtractFilterType;
typedef typename ExtractFilterType::Pointer ExtractFilterPointerType;
typedef std::vector<ExtractFilterPointerType> ExtractFilterVectorType;
/** Set the number of levels */
itkSetMacro(NumberOfLevels,unsigned int);
/** Get the number of levels */
itkGetMacro(NumberOfLevels,unsigned int);
/** Set the decimation ratio */
itkSetMacro(DecimationRatio,unsigned int);
/** Get the decimation ratio */
itkGetMacro(DecimationRatio,unsigned int);
/** If the filter is modified, the extract list need to be regenerated */
virtual void Modified() const;
protected:
/** Constructor */
WaveletsSynopsisImageToWaveletsBandsListFilter();
/** Destructor */
virtual ~WaveletsSynopsisImageToWaveletsBandsListFilter();
/**PrintSelf method */
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
/** Generate the input requested region from the first element in the list. */
virtual void GenerateInputRequestedRegion(void);
/** Generate the output information by building the output list. */
virtual void GenerateOutputInformation(void);
/** Main computation method */
virtual void GenerateData(void);
private:
WaveletsSynopsisImageToWaveletsBandsListFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
/** The number of levels in the decomposition */
unsigned int m_NumberOfLevels;
/** The decimation ratio used in the decomposition */
unsigned int m_DecimationRatio;
/** The vector of extraction filters for each band */
ExtractFilterVectorType m_ExtractFilters;
/** True if extract list is up-to-date */
mutable bool m_ExtractFiltersUpToDate;
};
}// End namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbWaveletsSynopsisImageToWaveletsBandsListFilter.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.
=========================================================================*/
#ifndef otbWaveletsSynopsisImageToWaveletsBandsListFilter_txx
#define otbWaveletsSynopsisImageToWaveletsBandsListFilter_txx
#include "otbWaveletsSynopsisImageToWaveletsBandsListFilter.h"
namespace otb
{
/** Constructor */
template <class TImage, class TImageList>
WaveletsSynopsisImageToWaveletsBandsListFilter<TImage,TImageList>
::WaveletsSynopsisImageToWaveletsBandsListFilter() : m_NumberOfLevels(1),
m_DecimationRatio(2),
m_ExtractFilters(),
m_ExtractFiltersUpToDate(false)
{}
/** Destructor */
template <class TImage, class TImageList>
WaveletsSynopsisImageToWaveletsBandsListFilter<TImage,TImageList>
::~WaveletsSynopsisImageToWaveletsBandsListFilter()
{
m_ExtractFilters.clear();
}
/** Modify overload */
template <class TImage, class TImageList>
void
WaveletsSynopsisImageToWaveletsBandsListFilter<TImage,TImageList>
::Modified() const
{
// Call superclass implementation
Superclass::Modified();
m_ExtractFiltersUpToDate = false;
}
/** Generate the input requested region from the first element in the list. */
template <class TImage, class TImageList>
void
WaveletsSynopsisImageToWaveletsBandsListFilter<TImage,TImageList>
::GenerateOutputInformation(void)
{
typename OutputImageListType::Pointer outputPtr = this->GetOutput();
typename InputImageType::ConstPointer inputPtr = this->GetInput();
// Check if we need to regenerate the extract filters
if (inputPtr && !m_ExtractFiltersUpToDate)
{
// Retrieve image size
typename RegionType::SizeType largestSize = inputPtr->GetLargestPossibleRegion().GetSize();
// Compute the number of output images
unsigned int numberOfOutputImages = m_NumberOfLevels*3 + 1;
// Clear the output image list
outputPtr->Clear();
// Clear the extract filter vector
m_ExtractFilters.clear();
// For each output image
for (unsigned int i=0;i<numberOfOutputImages;++i)
{
// Build the current extract filter
typename ExtractFilterType::Pointer currentExtract = ExtractFilterType::New();
currentExtract->SetInput(inputPtr);
// Add it to the filter list
m_ExtractFilters.push_back(currentExtract);
// Add its output to the filter's output
outputPtr->PushBack(currentExtract->GetOutput());
// Build the corresponding region
RegionType currentRegion;
typename RegionType::IndexType currentIndex;
typename RegionType::SizeType currentSize;
currentIndex.Fill(0);
// If this is not the first sub-band
if(i > 0)
{
// Compute current sub-band and level
unsigned int currentLevel = (i-1)/3;
unsigned int currentSubBand = (i-1)%3;
unsigned int offsetX = largestSize[0]/(unsigned int)vcl_pow((double)m_DecimationRatio,(double)m_NumberOfLevels-currentLevel);
unsigned int offsetY = largestSize[1]/(unsigned int)vcl_pow((double)m_DecimationRatio,(double)m_NumberOfLevels-currentLevel);
// Compute current size
currentSize[0] = offsetX;
currentSize[1] = offsetY;
// Compute current index
if(currentSubBand == 0)
{
currentIndex[0]+= offsetX;
}
else if(currentSubBand == 1)
{
currentIndex[1]= offsetY;
}
else
{
currentIndex[0]= offsetX;
currentIndex[1]= offsetY;
}
}
else
{
// The coarsest scale size
currentSize[0] = largestSize[0]/(unsigned int)vcl_pow((double)m_DecimationRatio,(double)m_NumberOfLevels);
currentSize[1] = largestSize[1]/(unsigned int)vcl_pow((double)m_DecimationRatio,(double)m_NumberOfLevels);
}
// Build current region
currentRegion.SetIndex(currentIndex);
currentRegion.SetSize(currentSize);
//std::cout<<"Band: "<<i<<", region "<<currentRegion<<std::endl;
currentExtract->SetRegionOfInterest(currentRegion);
}
m_ExtractFiltersUpToDate = true;
}
}
/** Generate the output information by building the output list. */
template <class TImage, class TImageList>
void
WaveletsSynopsisImageToWaveletsBandsListFilter<TImage,TImageList>
::GenerateInputRequestedRegion(void)
{
typename InputImageType::Pointer inputPtr = this->GetInput();
if (inputPtr)
{
inputPtr->SetRequestedRegionToLargestPossibleRegion();
}
}
/**
* Main computation method
*/
template <class TImage, class TImageList>
void
WaveletsSynopsisImageToWaveletsBandsListFilter<TImage,TImageList>
::GenerateData(void)
{
// Update each extract fillter
for(typename ExtractFilterVectorType::iterator it = m_ExtractFilters.begin();
it!=m_ExtractFilters.end();++it)
{
(*it)->Update();
}
}
/**
* PrintSelf Method
*/
template <class TImage, class TImageList>
void
WaveletsSynopsisImageToWaveletsBandsListFilter<TImage,TImageList>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
} // End namespace otb
#endif
......@@ -15,7 +15,6 @@ otbWaveletFilterBank.cxx
otbWaveletPacketTransformNew.cxx
otbWaveletFilterBankNew.cxx
otbWaveletOperatorNew.cxx
otbWaveletImageToImageFilter.cxx
)
add_executable(otbWaveletTestDriver ${OTBWaveletTests})
......@@ -573,11 +572,3 @@ otb_add_test(NAME msTuWaveletFilterBankNew COMMAND otbWaveletTestDriver
otb_add_test(NAME msTuWaveletOperatorNew COMMAND otbWaveletTestDriver
otbWaveletOperatorNew )
otb_add_test(NAME msTvWaveletImageToImageFilter COMMAND otbWaveletTestDriver
--compare-image ${EPSILON_6}
${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif
${TEMP}/msTvWaveletImageToImageFilterOut.tif
otbWaveletImageToImageFilter
${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif
${TEMP}/msTvWaveletImageToImageFilterOut.tif
)
/*=========================================================================
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.
=========================================================================*/
/*
This test code will run a WaveletImageFilter on given input image. Output
from this filter is then fed to WaveletInverseImageFilter which does
the inverse transform. Hence output of inverse transform passed to
ImageFileWriter will result in the input image.
Wavelet operator used is HAAR (otb::Wavelet::HAAR).
This filter works only in single-threaded setup
*/
#include "otbImage.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "otbWaveletImageFilter.h"
#include "otbWaveletInverseImageFilter.h"
int otbWaveletImageToImageFilter(int argc, char * argv[])
{
const char * inputFileName = argv[1];
const char * outputFileName = argv[argc-1];
/* Wavelet operator */
const otb::Wavelet::Wavelet OperatorType = otb::Wavelet::HAAR;
const int Dimension = 2;
typedef double PixelType;
typedef otb::Image<PixelType, Dimension> ImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::WaveletImageFilter<
ImageType,
ImageType,
OperatorType> FwdFilterType;
typedef otb::WaveletInverseImageFilter<
ImageType,
ImageType,
OperatorType> InvFilterType;
typedef otb::ImageFileWriter<ImageType> WriterType;
// itk::MultiThreader::SetGlobalMaximumNumberOfThreads( 1 );
/* Reading */
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(inputFileName);
/* Forward Transformation */
FwdFilterType::Pointer fwdFilter = FwdFilterType::New();
fwdFilter->SetInput(reader->GetOutput());
fwdFilter->Update();
/* Inverse Transformation */
InvFilterType::Pointer invFilter = InvFilterType::New();
invFilter->SetInput(fwdFilter->GetOutput());
invFilter->Update();
/* Writing output */
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(outputFileName);
writer->SetInput(invFilter->GetOutput());
writer->Update();
return EXIT_SUCCESS;
}
......@@ -14,5 +14,4 @@ void RegisterTests()
REGISTER_TEST(otbWaveletPacketTransformNew);
REGISTER_TEST(otbWaveletFilterBankNew);
REGISTER_TEST(otbWaveletOperatorNew);
REGISTER_TEST(otbWaveletImageToImageFilter);
}
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