Commit 6fcdf04b authored by Antoine Regimbeau's avatar Antoine Regimbeau

MRG: Merge branch 'complexImage_integration' into develop

parents e7da5674 3b59176d
......@@ -264,7 +264,7 @@ private:
{
// fft ttransform
bool shift = IsParameterEnabled( "mode.fft.shift");
typedef otb::Image< std::complex<OutputPixelType> > ComplexOutputImageType;
typedef otb::Image< std::complex<OutputPixelType> > ComplexOutputImageType;
if (dir == 0 )
{
......
......@@ -173,6 +173,14 @@ otb_test_application(NAME apTvUtExtractROIRightInputFile
${INPUTDATA}/couleurs_extrait.png
${TEMP}/apTvUtExtractROIRightInputFile.tif)
otb_test_application(NAME apTvUtExtractROIComplexInputFile
APP ExtractROI
OPTIONS -in ${INPUTDATA}/complexInputCfloat.tif
-out ${TEMP}/apTvUtExtractROIComplexInputFile.tif cfloat
VALID --compare-image ${NOTOL}
${INPUTDATA}/complexInputCfloat.tif
${TEMP}/apTvUtExtractROIComplexInputFile.tif)
#----------- Rescale TESTS ----------------
otb_test_application(NAME apTvUtRescaleTest
......@@ -207,6 +215,11 @@ otb_test_application(NAME apTuUtReadImageInfoExtendedFilename_reader
OPTIONS -in ${INPUTDATA}/ToulouseExtract_WithGeom.tif?&skipgeom=true&skipcarto=true
)
otb_test_application(NAME apTuUtReadComplexImageInfoFilename_reader
APP ReadImageInfo
OPTIONS -in ${INPUTDATA}/complexInputCfloat.tif
)
set(TESTNAME
"gd-pleiades-1" #LARGEINPUT{PLEIADES/TLSE_JP2_DIMAPv2_PRIMARY_PMS_lossless_12bits/IMGPHR_201222215194743808/IMG_PHR1A_PMS_201201151100183_SEN_IPU_20120222_0901-001_R1C1.JP2}
......
......@@ -29,7 +29,7 @@
#include "otbReflectanceToRadianceImageFilter.h"
#include "otbReflectanceToSurfaceReflectanceImageFilter.h"
#include "itkMultiplyImageFilter.h"
#include "otbClampVectorImageFilter.h"
#include "otbClampImageFilter.h"
#include "otbSurfaceAdjacencyEffectCorrectionSchemeFilter.h"
#include "otbGroundSpacingImageFunction.h"
#include "vnl/vnl_random.h"
......@@ -92,7 +92,7 @@ public:
typedef itk::MultiplyImageFilter<DoubleVectorImageType,DoubleImageType,DoubleVectorImageType> ScaleFilterOutDoubleType;
typedef otb::ClampVectorImageFilter<DoubleVectorImageType,
typedef otb::ClampImageFilter<DoubleVectorImageType,
DoubleVectorImageType> ClampFilterType;
typedef ReflectanceToSurfaceReflectanceImageFilter<DoubleVectorImageType,
......
......@@ -60,7 +60,7 @@ private:
AddDocTag(Tags::Calibration);
AddDocTag(Tags::SAR);
AddParameter(ParameterType_ComplexInputImage, "in", "Input Image");
AddParameter(ParameterType_InputImage, "in", "Input Image");
SetParameterDescription("in", "Input complex image");
AddParameter(ParameterType_OutputImage, "out", "Output Image");
......
......@@ -31,7 +31,7 @@
#include "otbSinclairToReciprocalCoherencyMatrixFunctor.h"
#include "otbPerBandVectorImageFilter.h"
#include "itkMeanImageFilter.h"
#include "otbNRIBandImagesToOneNComplexBandsImage.h"
// #include "otbNRIBandImagesToOneNComplexBandsImage.h"
#include "otbImageListToVectorImageFilter.h"
#include "otbImageList.h"
......@@ -109,21 +109,21 @@ private:
AddDocTag(Tags::SAR);
AddParameter(ParameterType_ComplexInputImage, "inhh", "Input Image");
AddParameter(ParameterType_InputImage, "inhh", "Input Image");
SetParameterDescription("inhh", "Input image (HH)");
AddParameter(ParameterType_ComplexInputImage, "inhv", "Input Image");
AddParameter(ParameterType_InputImage, "inhv", "Input Image");
SetParameterDescription("inhv", "Input image (HV)");
MandatoryOff("inhv");
AddParameter(ParameterType_ComplexInputImage, "invh", "Input Image");
AddParameter(ParameterType_InputImage, "invh", "Input Image");
SetParameterDescription("invh", "Input image (VH)");
MandatoryOff("invh");
AddParameter(ParameterType_ComplexInputImage, "invv", "Input Image");
AddParameter(ParameterType_InputImage, "invv", "Input Image");
SetParameterDescription("invv", "Input image (VV)");
AddParameter(ParameterType_ComplexOutputImage, "out", "Output Image");
AddParameter(ParameterType_OutputImage, "out", "Output Image");
SetParameterDescription("out", "Output image");
AddParameter(ParameterType_Choice, "decomp", "Decompositions");
......@@ -201,7 +201,7 @@ private:
m_MeanFilter->SetInput(m_SRFilter->GetOutput());
m_HAFilter->SetInput(m_MeanFilter->GetOutput());
SetParameterComplexOutputImage("out", m_HAFilter->GetOutput() );
SetParameterOutputImage("out", m_HAFilter->GetOutput() );
break;
......@@ -220,7 +220,7 @@ private:
m_MeanFilter->SetInput(m_SRFilter->GetOutput());
m_BarnesFilter->SetInput(m_MeanFilter->GetOutput());
SetParameterComplexOutputImage("out", m_BarnesFilter->GetOutput() );
SetParameterOutputImage("out", m_BarnesFilter->GetOutput() );
break;
......@@ -239,7 +239,7 @@ private:
m_MeanFilter->SetInput(m_SRFilter->GetOutput());
m_HuynenFilter->SetInput(m_MeanFilter->GetOutput());
SetParameterComplexOutputImage("out", m_HuynenFilter->GetOutput() );
SetParameterOutputImage("out", m_HuynenFilter->GetOutput() );
break;
......@@ -257,7 +257,7 @@ private:
m_Concatener->SetInput( m_ImageList );
m_PauliFilter->SetInput(m_Concatener->GetOutput());
SetParameterComplexOutputImage("out", m_PauliFilter->GetOutput() );
SetParameterOutputImage("out", m_PauliFilter->GetOutput() );
break;
}
......
......@@ -232,7 +232,7 @@ private:
AddDocTag(Tags::SAR);
AddParameter(ParameterType_ComplexInputImage, "inc", "Input : multi-band complex image");
AddParameter(ParameterType_InputImage, "inc", "Input : multi-band complex image");
SetParameterDescription("inc", "Input : multi-band complex image");
MandatoryOff("inc");
......@@ -241,23 +241,23 @@ private:
MandatoryOff("inf");
AddParameter(ParameterType_ComplexInputImage, "inhh", "Input : one-band complex image (HH)");
AddParameter(ParameterType_InputImage, "inhh", "Input : one-band complex image (HH)");
SetParameterDescription("inhh", "Input : one-band complex image (HH)");
MandatoryOff("inhh");
AddParameter(ParameterType_ComplexInputImage, "inhv", "Input : one-band complex image (HV)");
AddParameter(ParameterType_InputImage, "inhv", "Input : one-band complex image (HV)");
SetParameterDescription("inhv", "Input : one-band complex image (HV)");
MandatoryOff("inhv");
AddParameter(ParameterType_ComplexInputImage, "invh", "Input : one-band complex image (VH)");
AddParameter(ParameterType_InputImage, "invh", "Input : one-band complex image (VH)");
SetParameterDescription("invh", "Input : one-band complex image (VH)");
MandatoryOff("invh");
AddParameter(ParameterType_ComplexInputImage, "invv", "Input : one-band complex image (VV)");
AddParameter(ParameterType_InputImage, "invv", "Input : one-band complex image (VV)");
SetParameterDescription("invv", "Input : one-band complex image (VV)");
MandatoryOff("invv");
AddParameter(ParameterType_ComplexOutputImage, "outc", "Output Complex Image");
AddParameter(ParameterType_OutputImage, "outc", "Output Complex Image");
SetParameterDescription("outc", "Output Complex image.");
MandatoryOff("outc");
......@@ -509,7 +509,7 @@ private:
m_RCohSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh"));
m_RCohSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv"));
SetParameterComplexOutputImage("outc", m_RCohSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels
SetParameterOutputImage("outc", m_RCohSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels
break;
......@@ -526,7 +526,7 @@ private:
m_RCovSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh"));
m_RCovSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv"));
SetParameterComplexOutputImage("outc", m_RCovSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels
SetParameterOutputImage("outc", m_RCovSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels
break;
......@@ -544,7 +544,7 @@ private:
m_RCCSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh"));
m_RCCSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv"));
SetParameterComplexOutputImage("outc", m_RCCSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels
SetParameterOutputImage("outc", m_RCCSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels
break;
......@@ -565,7 +565,7 @@ private:
m_RCCDFilter = RCCDFilterType::New();
m_RCCDFilter->SetInput(GetParameterComplexDoubleVectorImage("inc"));
SetParameterComplexOutputImage("outc", m_RCCDFilter->GetOutput() ); // input : 6 complex channels | 3 complex channels
SetParameterOutputImage("outc", m_RCCDFilter->GetOutput() ); // input : 6 complex channels | 3 complex channels
break;
......@@ -575,7 +575,7 @@ private:
m_RCRCFilter = RCRCFilterType::New();
m_RCRCFilter->SetInput(GetParameterComplexDoubleVectorImage("inc"));
SetParameterComplexOutputImage("outc", m_RCRCFilter->GetOutput() ); // input : 6 complex channels | 6 complex channels
SetParameterOutputImage("outc", m_RCRCFilter->GetOutput() ); // input : 6 complex channels | 6 complex channels
break;
......@@ -586,7 +586,7 @@ private:
m_RLCRCCFilter = RLCRCCFilterType::New();
m_RLCRCCFilter->SetInput(GetParameterComplexDoubleVectorImage("inc"));
SetParameterComplexOutputImage("outc", m_RLCRCCFilter->GetOutput() ); // input : 6 complex channels | output : 6 complex channels
SetParameterOutputImage("outc", m_RLCRCCFilter->GetOutput() ); // input : 6 complex channels | output : 6 complex channels
break;
......@@ -597,7 +597,7 @@ private:
m_MRCFilter->SetInput(GetParameterDoubleVectorImage("inf"));
SetParameterComplexOutputImage("outc", m_MRCFilter->GetOutput() ); // input : 16 real channels | output : 6 complex channels
SetParameterOutputImage("outc", m_MRCFilter->GetOutput() ); // input : 16 real channels | output : 6 complex channels
break;
......@@ -615,7 +615,7 @@ private:
m_CohSRFilter->SetInputVH(GetParameterComplexDoubleImage("invh"));
m_CohSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv"));
SetParameterComplexOutputImage("outc", m_CohSRFilter->GetOutput() ); // input : 4 x 1 complex channel | 10 complex channels
SetParameterOutputImage("outc", m_CohSRFilter->GetOutput() ); // input : 4 x 1 complex channel | 10 complex channels
break;
......@@ -630,7 +630,7 @@ private:
m_CovSRFilter->SetInputVH(GetParameterComplexDoubleImage("invh"));
m_CovSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv"));
SetParameterComplexOutputImage("outc", m_CovSRFilter->GetOutput() ); // input : 4 x 1 complex channel | output : 10 complex channels
SetParameterOutputImage("outc", m_CovSRFilter->GetOutput() ); // input : 4 x 1 complex channel | output : 10 complex channels
break;
......@@ -644,7 +644,7 @@ private:
m_CCSRFilter->SetInputVH(GetParameterComplexDoubleImage("invh"));
m_CCSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv"));
SetParameterComplexOutputImage("outc", m_CCSRFilter->GetOutput() ); // input : 4 x 1 complex channel | output : 10 complex channels
SetParameterOutputImage("outc", m_CCSRFilter->GetOutput() ); // input : 4 x 1 complex channel | output : 10 complex channels
break;
......
......@@ -86,7 +86,7 @@ private:
AddDocTag(Tags::SAR);
AddParameter(ParameterType_ComplexInputImage, "in", "Input Image");
AddParameter(ParameterType_InputImage, "in", "Input Image");
SetParameterDescription("in", "Input image.");
AddParameter(ParameterType_OutputImage, "out", "Output Image");
SetParameterDescription("out", "Output image.");
......
......@@ -75,7 +75,7 @@ private:
AddDocTag(Tags::SAR);
AddDocTag(Tags::Manip);
// Input images
AddParameter(ParameterType_ComplexInputImage, "in", "Input Image");
AddParameter(ParameterType_InputImage, "in", "Input Image");
SetParameterDescription("in", "Input image (complex single band)");
// Outputs
......@@ -110,7 +110,7 @@ private:
m_Modulus = ModulusFilterType::New();
m_Phase = PhaseFilterType::New();
ComplexFloatVectorImageType::Pointer inImage = GetParameterComplexImage("in");
ComplexFloatVectorImageType::Pointer inImage = GetParameterComplexFloatVectorImage("in");
if (inImage->GetNumberOfComponentsPerPixel() != 1)
{
......
......@@ -21,121 +21,104 @@
#ifndef otbClampImageFilter_h
#define otbClampImageFilter_h
#include "itkImageToImageFilter.h"
#include "otbConvertTypeFunctor.h"
#include "itkUnaryFunctorImageFilter.h"
namespace otb
{
/** \class ClampImageFilter
* \brief Set image values to a user-specified value if they are below,
* above, or between simple threshold values.
* \brief Clamp image values to be below, over, or between threhold values.
*
* ClampImageFilter clamp image values to be between an upper
* and lower value. Values lower than m_Lower values are set to lower,
* and values greater than upper threshold are set to upper threshold
* value.
* This filter can also be used to cast any type of image into any other type
* as long as those types are arithmetics or complex.
*
* By default lower and upper thresholds are set to the maximum and
* minimum bounds of the image pixel type.
*
* The pixels must support the operators >= and <=.
* minimum bounds of the image internal pixel value.
*
* \ingroup IntensityImageFilters Multithreaded
*
* \ingroup OTBImageManipulation
*/
template <class TInputImage, class TOutputImage=TInputImage>
class ITK_EXPORT ClampImageFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage>
class ITK_EXPORT ClampImageFilter
: public itk::UnaryFunctorImageFilter< TInputImage , TOutputImage ,
Functor::ConvertTypeFunctor <typename TInputImage::PixelType ,
typename TOutputImage::PixelType> >
{
public:
/** Standard class typedefs. */
typedef ClampImageFilter Self;
typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef ClampImageFilter Self;
typedef itk::UnaryFunctorImageFilter< TInputImage , TOutputImage ,
Functor::ConvertTypeFunctor <typename TInputImage::PixelType ,
typename TOutputImage::PixelType> > Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
itkNewMacro( Self );
/** Run-time type information (and related methods). */
itkTypeMacro(ClampImageFilter, itk::ImageToImageFilter);
itkTypeMacro( ClampImageFilter , itk::UnaryFunctorImageFilter );
/** Some additional typedefs. */
typedef TInputImage InputImageType;
typedef typename InputImageType::ConstPointer InputImagePointer;
typedef typename InputImageType::RegionType InputImageRegionType;
typedef typename InputImageType::PixelType InputImagePixelType;
/** Some additional typedefs. */
typedef TOutputImage OutputImageType;
typedef typename OutputImageType::Pointer OutputImagePointer;
typedef typename OutputImageType::RegionType OutputImageRegionType;
typedef typename OutputImageType::PixelType OutputImagePixelType;
typedef TOutputImage OutputImageType;
typedef typename OutputImageType::RegionType OutputImageRegionType;
typedef typename OutputImageType::PixelType OutputImagePixelType;
typedef typename OutputImageType::InternalPixelType OutputInternalPixelType;
typedef typename itk::NumericTraits< OutputInternalPixelType >::ValueType OutputPixelValueType;
/** The values greater than or equal to the value are set to OutsideValue. */
void ClampAbove(const OutputImagePixelType &thresh);
/** The values greater than or equal to the value are set to \p thresh. */
void ClampAbove(const OutputPixelValueType &thresh);
/** The values less than or equal to the value are set to OutsideValue. */
void ClampBelow(const OutputImagePixelType &thresh);
/** The values less than or equal to the value are set to \p thresh. */
void ClampBelow(const OutputPixelValueType &thresh);
/** The values outside the range are set to OutsideValue. */
void ClampOutside(const OutputImagePixelType &lower, const OutputImagePixelType &upper);
/** The values outside the range are set to \p lower or \p upper. */
void ClampOutside(const OutputPixelValueType &lower, const OutputPixelValueType &upper);
/** Set/Get methods to set the lower threshold */
void SetLower(OutputImagePixelType val)
{
m_Lower = val;
m_DLower = static_cast<double>(val);
this->Modified();
}
itkGetConstMacro(Lower, OutputImagePixelType);
void SetLower(OutputPixelValueType val);
itkGetConstMacro(Lower, OutputPixelValueType);
/** Set/Get methods to set the upper threshold */
void SetUpper(OutputImagePixelType val)
{
m_Upper = val;
m_DUpper = static_cast<double>(val);
this->Modified();
}
itkGetConstMacro(Upper, OutputImagePixelType);
void SetUpper(OutputPixelValueType val);
itkGetConstMacro(Upper, OutputPixelValueType);
protected:
ClampImageFilter();
~ClampImageFilter() ITK_OVERRIDE {};
void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
/** ClampImageFilter can be implemented as a multithreaded filter.
* Therefore, this implementation provides a ThreadedGenerateData() routine
* which is called for each processing thread. The output image data is
* allocated automatically by the superclass prior to calling
* ThreadedGenerateData(). ThreadedGenerateData can only write to the
* portion of the output image specified by the parameter
* "outputRegionForThread"
*
* \sa ImageToImageFilter::ThreadedGenerateData(),
* ImageToImageFilter::GenerateData() */
void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
itk::ThreadIdType threadId ) ITK_OVERRIDE;
void GenerateOutputInformation(void) ITK_OVERRIDE
{
Superclass::GenerateOutputInformation();
~ClampImageFilter() override {};
void PrintSelf(std::ostream& os, itk::Indent indent) const override;
this->GetOutput()->SetNumberOfComponentsPerPixel( this->GetInput()->GetNumberOfComponentsPerPixel() );
}
void GenerateOutputInformation(void) override
{
Superclass::GenerateOutputInformation();
unsigned int sizeIn = this->GetInput()->GetNumberOfComponentsPerPixel();
this->GetFunctor().SetInputComponents( sizeIn );
this->GetOutput()->SetNumberOfComponentsPerPixel(
this->GetFunctor().GetOutputSize () );
}
private:
ClampImageFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
double m_DLower;
double m_DUpper;
ClampImageFilter(const Self&) = delete ;
void operator=(const Self&) = delete ;
OutputImagePixelType m_Lower;
OutputImagePixelType m_Upper;
OutputPixelValueType m_Lower;
OutputPixelValueType m_Upper;
};
......
......@@ -25,6 +25,7 @@
#include "otbClampImageFilter.h"
#include "itkImageRegionIterator.h"
#include "itkNumericTraits.h"
#include <limits>
#include "itkObjectFactory.h"
#include "itkProgressReporter.h"
......@@ -38,13 +39,35 @@ template <class TInputImage, class TOutputImage>
ClampImageFilter<TInputImage, TOutputImage>
::ClampImageFilter()
{
m_Lower = itk::NumericTraits<OutputImagePixelType>::NonpositiveMin();
m_Upper = itk::NumericTraits<OutputImagePixelType>::max();
m_Lower = std::numeric_limits < OutputPixelValueType >::lowest();
m_Upper = std::numeric_limits < OutputPixelValueType >::max();
}
m_DLower = static_cast<double>(m_Lower);
m_DUpper = static_cast<double>(m_Upper);
template <class TInputImage, class TOutputImage>
void
ClampImageFilter<TInputImage, TOutputImage>
::SetLower(OutputPixelValueType val)
{
if ( m_Lower != val )
{
m_Lower = val;
this->GetFunctor().SetLowest( m_Lower );
this->Modified();
}
}
template <class TInputImage, class TOutputImage>
void
ClampImageFilter<TInputImage, TOutputImage>
::SetUpper(OutputPixelValueType val)
{
if ( m_Upper != val )
{
m_Upper = val;
this->GetFunctor().SetHighest( m_Upper );
this->Modified();
}
}
/**
*
......@@ -70,14 +93,15 @@ ClampImageFilter<TInputImage, TOutputImage>
template <class TInputImage, class TOutputImage>
void
ClampImageFilter<TInputImage, TOutputImage>
::ClampAbove(const OutputImagePixelType &thresh)
::ClampAbove(const OutputPixelValueType &thresh)
{
if (m_Upper != thresh
|| m_Lower > itk::NumericTraits<OutputImagePixelType>::NonpositiveMin())
|| m_Lower > std::numeric_limits < OutputPixelValueType >::lowest())
{
m_Lower = itk::NumericTraits<OutputImagePixelType>::NonpositiveMin();
m_Lower = std::numeric_limits < OutputPixelValueType >::lowest();
m_Upper = thresh;
m_DUpper = static_cast<double>(m_Upper);
this->GetFunctor().SetLowest( m_Lower );
this->GetFunctor().SetHighest( m_Upper );
this->Modified();
}
}
......@@ -88,13 +112,14 @@ ClampImageFilter<TInputImage, TOutputImage>
template <class TInputImage, class TOutputImage>
void
ClampImageFilter<TInputImage, TOutputImage>
::ClampBelow(const OutputImagePixelType &thresh)
::ClampBelow(const OutputPixelValueType &thresh)
{
if (m_Lower != thresh || m_Upper < itk::NumericTraits<OutputImagePixelType>::max())
if (m_Lower != thresh || m_Upper < std::numeric_limits < OutputPixelValueType >::max())
{
m_Upper = std::numeric_limits < OutputPixelValueType >::max();
m_Lower = thresh;
m_DLower = m_Lower;
m_Upper = itk::NumericTraits<InputImagePixelType>::max();
this->GetFunctor().SetLowest( m_Lower );
this->GetFunctor().SetHighest( m_Upper );
this->Modified();
}
}
......@@ -106,7 +131,7 @@ ClampImageFilter<TInputImage, TOutputImage>
template <class TInputImage, class TOutputImage>
void
ClampImageFilter<TInputImage, TOutputImage>
::ClampOutside(const OutputImagePixelType &lower, const OutputImagePixelType &upper)
::ClampOutside(const OutputPixelValueType &lower, const OutputPixelValueType &upper)
{
if (lower > upper)
{
......@@ -118,73 +143,12 @@ ClampImageFilter<TInputImage, TOutputImage>
{
m_Lower = lower;
m_Upper = upper;
m_DLower = m_Lower;
m_DUpper = m_Upper;
this->GetFunctor().SetLowest( m_Lower );
this->GetFunctor().SetHighest( m_Upper );
this->Modified();
}
}
/**
*
*/
template <class TInputImage, class TOutputImage>
void
ClampImageFilter<TInputImage, TOutputImage>
::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
itk::ThreadIdType threadId)
{
itkDebugMacro(<<"Actually executing");
// Get the input and output pointers
InputImagePointer inputPtr = this->GetInput();
OutputImagePointer outputPtr = this->GetOutput(0);
// Define/declare an iterator that will walk the output region for this
// thread.
typedef itk::ImageRegionConstIterator<TInputImage> InputIterator;
typedef itk::ImageRegionIterator<TOutputImage> OutputIterator;
InputIterator inIt(inputPtr, outputRegionForThread);
OutputIterator outIt(outputPtr, outputRegionForThread);
// support progress methods/callbacks
itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels());
// walk the regions, threshold each pixel
while( !outIt.IsAtEnd() && !inIt.IsAtEnd() )
{
// Cast the value of the pixel to double in order to compare
// with the double version of the upper and the lower bounds of
// output image
const double value = static_cast<double>(inIt.Get());
OutputImagePixelType outPix = m_Lower;
if ( m_DLower <= value && value <= m_DUpper)
{
// pixel passes to output unchanged
outPix = static_cast<OutputImagePixelType>(value);
}
/* Already outPix is initialized with m_Lower even for preventing Warning.
*
else if ( value < m_DLower )
{
outPix = m_Lower;
}
*/
else if ( value > m_DUpper)
{
outPix = m_Upper;
}
outIt.Set( outPix );
++inIt;
++outIt;
progress.CompletedPixel();
}
}
} // end namespace itk
#endif
......@@ -21,6 +21,7 @@
#ifndef otbClampVectorImageFilter_h
#define otbClampVectorImageFilter_h
#include <vcl_deprecated_header.h>
#include "itkImageToImageFilter.h"
namespace otb
......
/*
* Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*