A lot of non necessary allocations are done almost every time an image is read.
This cost can be removed.
No need to pay for computations that can be avoided.
On simple applications, a x2 speed up is easily observed. It was the case with https://gitlab.orfeo-toolbox.org/s1-tiling/normlim_sigma0
SARComputeLocalIncidenceAngle that reads 2 images, and computes for each pixel 1 cross product, 2 norms, one
This MR relates to #2065.
Classes and files
- A new class to iterate over pixel components is provided:
PixelComponentIterator. For instance this iterator is able to convert a
ClampFilterarchitecture is changed to efficiently handle
VariableLengthVectorpixels: it's no longer an
result = f(in)internally) but a plain filter that calls
f(result, in)on each pixel. This permits to avoid creating (and destroying) a new VLV for each pixel, and thus to avoid dynamic allocations. The filter has also been simplified and optimized.
ConvertTypeFunctorhas been adapted for the new interface of
ClampFilter. Internally, it uses the new
PixelComponentIteratorto copy components from the input pixel to the output pixel. Along the way, it has been simplified and optimized.
CastImageapplication has been simplified. Instead of converting any image into a
VectorImage<double>of the same number of components/bands, and then into the output image, it directly converts the input image into the output image -- thanks to
WrapperOutputImageParameterhave been simplified
Also a few new helpers functions and classes have been provided:
- like a C++14 backport of C++17
otb::is_arraytraits that recognizes
itk::VLVand classes that inherits from
GetNumberOfComponents()that works around shortcomings of
itk::DefaultConvertPixelTraits<complex<>>::GetNumberOfComponents(pix)(which doesn't support
std::complexand that copies
- a port of
Old tests for
bfTvClampImageFilterConversionTest) still runs.
A new test for
PixelComponentIterator has been added.
The copyright owner is CSGroup FRANCE 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
- Optionally, run
git diff develop... -U0 --no-color | clang-format-diff.py -p1 -ion latest changes and commit