Skip to content

Refactor filters in Polarimetry module to use new FunctorFilter

Manuel Grizonnet requested to merge refactor-sinclairimagefilter into develop

Summary

Refactor filters related to polarimetry processing in Polarimetry module to make them derive from FunctorImageFilter

Rationale

The Polarimetry module consists in a set of filters which derive from UnaryFunctorImageFilters which use dedicated functors to implement various polarimetric processing (13 conversion filters, 4 decomposition filters...)

These operations are documented in the cookbook:

https://www.orfeo-toolbox.org/CookBook/recipes/sarprocessing.html#polarimetry

Using the FunctorImageFilter, polarimetric filters have been refactored to be a definition of FunctorImageFilter templated with the corresponding functor.

For instance for Mueller filters the declaration of MuellerToPolarisationDegreeAndPowerFilter (see otbPolarimetricFilters.h):

// This is the entire declaration of MuellerToPolarisationDegreeAndPowerFilter
template <typename TInputImage, typename TOutputImage>
using MuellerToPolarisationDegreeAndPowerImageFilter =
  FunctorImageFilter<Functor::MuellerToPolarisationDegreeAndPowerFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType>>;

Note that filters which need to provide specific polarimetric configuration as input are handle using NamedFunctor feature and the list of polarimetric configurations are stored in otbPolarimetricTags.h as anonymous struct.

For instance for SinclairToReciprocalCircularCovarianceMatrixFilter (use hh, hv or vh and vv as inputs):

// This is the entire declaration of SinclairToReciprocalCircularCovarianceMatrixFilter
template <typename TInputImage, typename TOutputImage>
using SinclairToReciprocalCircularCovarianceMatrixFilter =
    FunctorImageFilter<Functor::SinclairToReciprocalCircularCovarianceMatrixFunctor<typename TInputImage::PixelType, typename TInputImage::PixelType,
                                                                                    typename TInputImage::PixelType, typename TOutputImage::PixelType>,
                       std::tuple<polarimetry_tags::hh, polarimetry_tags::hv_or_vh, polarimetry_tags::vv>>;

Related tests and applications SARPolarMatrixConvert and SARPolarDecompositions have been updated to follow the new API. Modifications in client code are limitied to change the way inputs are set in corresponding filters.

Moreover corresponding functor operator signature has been changed (from TOutput to void). Output pixels are now passed as reference to avoid copies in the filter.

Note that the branch contains 1072 additions and 2055 deletions which demonstrates the advantage to refactor filters which dereive from itk::*FunctorImageFilter and use FunctorImageFilter instead.

Implementation Details

Additional notes

Not done in this MR

  • the otbMultiChannelsPolarimetricSynthesisFilter is the only remaining filter in the module which was not refactored as it derives from itk::InPlaceImageFilter and have a particular behavior to deal with images with different polarimetry as input.

  • All functor tests could be moved in a single cxx to decrease the number of cmake targets (idem for Functor definition which can be group by thematic applications (monostatic conversion, bistatic conversion, decomposition...)

  • Polar applications could be moved in one single module called "Polarimetry" for instance (for now MatrixConvert and SARDecompositions are splitted in separate module with one application per module)

Copyright

The copyright owner is CNES and has signed the ORFEO ToolBox Contributor License Agreement.


Check before merging:

  • All discussions are resolved
  • At least 2 👍 votes from core developers, no 👎 vote.
  • The feature branch is (reasonably) up-to-date with the base branch
  • Dashboard is green
  • Copyright owner has signed the ORFEO ToolBox Contributor License Agreement
Edited by Manuel Grizonnet

Merge request reports

Loading