Refactor filters in Polarimetry module to use new FunctorFilter
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
Merge request reports
Activity
- Automatically resolved by Manuel Grizonnet
- Automatically resolved by Manuel Grizonnet
- Automatically resolved by Manuel Grizonnet
- Automatically resolved by Manuel Grizonnet
- Automatically resolved by Manuel Grizonnet
- Automatically resolved by Manuel Grizonnet
- Automatically resolved by Manuel Grizonnet
- Automatically resolved by Manuel Grizonnet
@jmichel even if I understand your will to remove maximum of code when refactoring we should keep backward compatibility in mind... But we could make those function deprecated right?
added 16 commits
-
b85c6eec...c3fa194e - 15 commits from branch
develop
- 76580390 - Merge branch 'develop' into refactor-sinclairimagefilter
-
b85c6eec...c3fa194e - 15 commits from branch
@aregimbeau For 7.0.0, I think we should be allowed to break things:
- We only follow semver starting 7.0.0
- 7.0.0 is a major release, so we can explain that things are broken
This is why I strongly advocate for doing all the refactoring and removal we can in 7.0.0 (for instance, TileMapImageIO and other classes that are not used/unusable or modules to move out of OTB). The rationale is that it will be easier to enforce semver if we start from a cleaner codebase.
added 1 commit
- d437206a - REFAC: move template using at same place than functor
added 31 commits
-
cb67e91b...664de77c - 29 commits from branch
develop
- 3627b43e - Merge branch 'develop' into refactor-sinclairimagefilter
- 1fa30d44 - merge SARPolarMatrixConvert by hand
-
cb67e91b...664de77c - 29 commits from branch
mentioned in merge request !321 (merged)
added 1 commit
- fe742a18 - ENH: make functor const and move doxygen ingroup doc