Commit 4d4bc36c authored by Cyrille Valladeau's avatar Cyrille Valladeau

ENH : add image size setting in functor

parent 7c063ee8
......@@ -78,6 +78,8 @@ public:
typedef itk::MetaDataDictionary MetaDataDictionaryType;
typedef typename FunctorType::DoubleVectorType DoubleVectorType;
typedef typename FunctorType::DoubleVectorVectorType DoubleVectorVectorType;
typedef typename InputImageType::SizeType SizeType;
// typedef typename FunctorType::LIntVectorType LIntVectorType;
/** Accessors */
......@@ -102,6 +104,9 @@ public:
/** Vector of vector that contain noise polinomial coefficient */
void SetNoisePolynomialCoefficientsList( DoubleVectorVectorType vect );
DoubleVectorVectorType GetNoisePolynomialCoefficientsList() const;
/** Image size (setter is protected)*/
SizeType GetImageSize() const;
/** Fast Calibration Method. If set to trus, will consider only the first noise coefficient else,
* will use all of them and applied it according to its acquisition UTC time and the coordinates
* of the pixel in the image. */
......@@ -121,6 +126,9 @@ protected:
TerraSarCalibrationImageFilter();
/** Destructor */
virtual ~TerraSarCalibrationImageFilter() {};
/** Image Size setter*/
void SetImageSize( SizeType size );
/** Initialize the functor vector */
void BeforeThreadedGenerateData();
......
......@@ -42,18 +42,7 @@ TerraSarCalibrationImageFilter<TInputImage,TOutputImage>
{
Superclass::BeforeThreadedGenerateData();
// If the user doesn't set it AND the metadata is available, set calFactor using image metadata
// std::cout<<this->GetCalFactor()<<std::endl;
// if (this->GetCalFactor() == itk::NumericTraits<double>::min())
// {
// /** TODO : use a factory for RADAR image metadata interface */
// TerraSarImageMetadataInterface::Pointer lImageMetadata = otb::TerraSarImageMetadataInterface::New();
// if( !lImageMetadata->CanRead(this->GetInput()->GetMetaDataDictionary()) )
// {
// itkExceptionMacro(<<"Invalid input image. Only TerraSar images are supproted");
// }
// this->SetCalFactor( lImageMetadata->GetCalibrationFactor(this->GetInput()->GetMetaDataDictionary()) );
// }
this->SetImageSize( this->GetInput()->GetLargestPossibleRegion().GetSize() );
// Load metadata
TerraSarImageMetadataInterface::Pointer lImageMetadata = otb::TerraSarImageMetadataInterface::New();
......@@ -174,6 +163,7 @@ TerraSarCalibrationImageFilter<TInputImage,TOutputImage>
{
double mean = lImageMetadata->GetMeanIncidenceAngles(this->GetInput()->GetMetaDataDictionary());
this->SetLocalIncidentAngle(mean);
this->SetLocalIncidentAngle(mean);
}
else
{
......@@ -298,6 +288,24 @@ TerraSarCalibrationImageFilter<TInputImage,TOutputImage>
return this->GetFunctor().GetNoisePolynomialCoefficientsList();
}
template <class TInputImage, class TOutputImage>
void
TerraSarCalibrationImageFilter<TInputImage,TOutputImage>
::SetImageSize( SizeType size )
{
this->GetFunctor().SetImageSize( size );
this->Modified();
}
template <class TInputImage, class TOutputImage>
typename TerraSarCalibrationImageFilter<TInputImage,TOutputImage>::SizeType
TerraSarCalibrationImageFilter<TInputImage,TOutputImage>
::GetImageSize() const
{
return this->GetFunctor().GetImageSize();
}
template <class TInputImage, class TOutputImage>
void
TerraSarCalibrationImageFilter<TInputImage,TOutputImage>
......
......@@ -94,20 +94,18 @@ template <class TInput, class TOutput>
double
TerraSarCalibrationImageFunctor<TInput, TOutput>
::ComputeCurrentNoise( unsigned int colId )
{
{
double curRange = 0.;
double width_2 = static_cast<double>(m_ImageSize[0])/2.;
// Use +1 because image start index is 0
if( colId < static_cast<unsigned int>(width_2) )
{
curRange = m_NoiseRangeValidityMin + ( m_NoiseRangeValidityRef-m_NoiseRangeValidityMin )/width_2 * static_cast<double>(colId+1);
}
else
{
{
curRange = m_NoiseRangeValidityRef + ( m_NoiseRangeValidityMax-m_NoiseRangeValidityRef )/width_2 * (static_cast<double>(colId+1) - width_2 );
}
return curRange;
}
......@@ -159,6 +157,7 @@ TerraSarCalibrationImageFunctor<TInput, TOutput>
::operator()(const TInput & inPix, IndexType index)
{
double diffCurRange = ComputeCurrentNoise( static_cast<unsigned int>(index[0]) ) - this->GetNoiseRangeValidityRef();
DoubleVectorType curCoeff = this->ComputeCurrentCoeffs( static_cast<unsigned int>(index[1]) );
double outRadBr = this->GetBrightness()( static_cast<double>(inPix) );
......@@ -168,6 +167,7 @@ TerraSarCalibrationImageFunctor<TInput, TOutput>
{
NEBN += curCoeff[i]*vcl_pow( diffCurRange, static_cast<double>(i));
}
double sigma = ( outRadBr - this->GetCalFactor()*NEBN ) * this->GetSinLocalIncidentAngle();
return static_cast<TOutput>(sigma);
......
......@@ -72,7 +72,6 @@ int otbTerraSarCalibrationImageFilterTest(int argc, char * argv[])
filter->SetNoiseRangeValidityMax( 1 );
filter->SetNoiseRangeValidityRef( 0.5 );
filter->SetLocalIncidentAngle( 15 );
filter->SetLocalIncidentAngle( 15 );
std::vector<double> timeUtc;
timeUtc.push_back(1.);
......@@ -84,6 +83,7 @@ int otbTerraSarCalibrationImageFilterTest(int argc, char * argv[])
filter->SetInput(reader->GetOutput());
writer->SetInput(filter->GetOutput());
writer->Update();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment