Python: behavior of applications differs in pipelines, when writing the intermediate outputs
Description
When playing with pipelines in python, some behaviors are not regular. In particular, the writing of intermediate outputs fails in some cases but not with the same applications composing the pipeline. As mentioned in issue #2286 (closed), several ways exist to write intermediate outputs of a pipeline. however, some of them fail with specific OTB application depending on their order in the pipeline.
In our context, we play with pipelines in two main steps.
- step 1: build a pipeline composed of several apps, without specifying output files names.
- step 2: when we are happy with the created pipeline, we trigger the writings of some specific outputs.
Steps to reproduce
Reproducible: always.
Code:
This pipeline composed of Mosaic --> ManageNoData does work:
import otbApplication
inp = "input.tif"
# Pipeline creation
app1 = otbApplication.Registry.CreateApplication("Mosaic")
app1.SetParameterStringList("il", [inp])
app1.Execute()
app2 = otbApplication.Registry.CreateApplication("ManageNoData")
app2.SetParameterString("mode", "changevalue")
app2.SetParameterInputImage("in", app1.GetParameterOutputImage("out"))
app2.Execute()
app1.SetParameterString("out", "/tmp/out_1.tif")
app1.WriteOutput()
app2.SetParameterString("out", "/tmp/out_2.tif")
app2.WriteOutput()
Note that we could have replaced Mosaic with other applications, e.g. Smoothing and the pipeline still works.
The exact same pipeline, composed of BandMath --> ManageNoData does not work:
import otbApplication
inp = "input.tif"
# Pipeline creation
app1 = otbApplication.Registry.CreateApplication("BandMath")
app1.SetParameterStringList("il", [inp])
app1.SetParameterString("exp", "im1b1")
app1.Execute()
app2 = otbApplication.Registry.CreateApplication("ManageNoData")
app2.SetParameterString("mode", "changevalue")
app2.SetParameterInputImage("in", app1.GetParameterOutputImage("out"))
app2.Execute()
app1.SetParameterString("out", "/tmp/out_1.tif")
app1.WriteOutput()
app2.SetParameterString("out", "/tmp/out_2.tif")
app2.WriteOutput()
The error is the following:
itk::ERROR: MultiThreader(0x2cf43f0): Exception occurred during SingleMethodExecute
/usr/include/ITK-4.13/itkImageConstIterator.h:210:
itk::ERROR: Region ImageRegion (0x7ffd29290250)
...
is outside of buffered region ImageRegion (0x3005390)
Dimension: 2
Index: [0, 0]
Size: [0, 0]
With OTB 7.4.0, I have noticed the same error replacing BandMath with DynamicConvert. So, this happen with some specific applications, but not all.
I have tried to debug at the applications and filters level, with no finding for now. In particular I was trying to determine if itk::InPlaceFilters
were at the origin, but for now I have no clue.
Configuration information
- Ubuntu 20.04
- OTB 7.4.0 or 8.0.1