Request for Changes-83: New Modulus and Phase application

From OTBWiki
Jump to: navigation, search

Status

Summary

This PR contains a new module which contain an application to compute simultaneously the modulus and the phase of a complex image:

   This is the ComputeModulusAndPhase application, version 5.11.0
   This application computes the modulus and the phase of a complex SAR image.
   
   Complete documentation: http://www.orfeo-toolbox.org/Applications/ComputeModulusAndPhase.html
   
   Parameters: 
           -progress <boolean>        Report progress 
   MISSING -il       <string list>    Input image list  (mandatory)
   MISSING -modulus  <string> [pixel] Modulus  [pixel=uint8/uint16/int16/uint32/int32/float/double] (default value is float) (mandatory)
   MISSING -phase    <string> [pixel] Phase  [pixel=uint8/uint16/int16/uint32/int32/float/double] (default value is float) (mandatory)
           -ram      <int32>          Available RAM (Mb)  (optional, off by default, default value is 128)
           -inxml    <string>         Load otb application from xml file  (optional, off by default)
   
   Examples: 
   otbcli_ComputeModulusAndPhase -il monobandComplexFloat.tif -modulus modulus.tif -phase phase.tif

This complex image can be:

  • A monoband image of complex pixel type
  • Two bands image of real type
  • Two monoband images of real type

So any of the following works:

   otbcli_ComputeModulusAndPhase -il monobandComplexFloat.tif             -modulus modulus.tif -phase phase.tif
   otbcli_ComputeModulusAndPhase -il multibandFloat_2bands.tif            -modulus modulus.tif -phase phase.tif
   otbcli_ComputeModulusAndPhase -il monobandFloat.tif monobandFloat2.tif -modulus modulus.tif -phase phase.tif


Originally submitted as a github PR by Mickael Savinaud, pushed and added some improvements (Victor):

  • Autodetect number of inputs (remove the nbinput parameter)
  • Replace BandMath with a itk::ComposeImageFilter for performance
  • Use explicit parameter names: mod -> modulus, pha -> phase

When changing the BandMath expression "sqrt(real*real + imag*imag)" to a itk::ComposeImageFilter, followed by a itk::ComplexToModulusImageFilter and itk::ComplexToPhaseImageFilter, there is a small difference in output values. On a test Sentinel-1 image, they are on the order of 1e-05 for the modulus, and 1e-07 for the phase. Is this within expected precision limits of BandMath? I updated the baseline in otb-data for this case.

Rationale

Very common processing on complex images.

Implementation details

Classes and files

The new application and tests are added to AppSARUtils:

   A       Modules/Applications/AppSARUtils/CMakeLists.txt
   A       Modules/Applications/AppSARUtils/app/CMakeLists.txt
   A       Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx
   A       Modules/Applications/AppSARUtils/otb-module.cmake
   A       Modules/Applications/AppSARUtils/test/CMakeLists.txt

Additionally, this RFC adds the atan2 function to BandMath:

   M       Modules/Filtering/MathParser/src/otbParser.cxx

Applications

New application ComputeModulusAndPhase.

Tests

Yes.

Documentation

Only app self documentation.

Feedback

After discussion on otb-developers, we decided to only support complex input. Support for two band real and two single band images was removed from this RFC. For details see https://groups.google.com/forum/#!topic/otb-developers/tlvAWBb2OTY

Additional notes

Ideas for possible future improvements:

  • Don't use BandMath for performance in the 2 input mode
  • Auto detect number of inputs (use an input parameter list)
  • Add option to output modulus in dB (amplitude vs intensity)
  • Make output parameters optional: provide at least one