Refactor compare image
The implementation of otb::TestHelper::RegressionTestImage
could be improved, mostly to deal with large images. I was a bit shocked to read this at the beginning of the function:
baselineReader->UpdateLargestPossibleRegion();
[...]
testReader->UpdateLargestPossibleRegion();
and a few lines later, there is finally a check on the image size, to decide if we upload the difference image to CDash. But if your input images are large (let say a few GB), you already have flooded the RAM memory of your laptop, and maybe the swap as well. As OTB is supposed to manage properly large images this behaviour has to be changed.
My solution step by step:
- First call a
UpdateOutputInformation()
on both readers (baseline and test image) in a try/catch - Check images have the same size
- Plug the pipeline with the
otb::DifferenceImageFilter
(also: add the Reset/Synthetise function to make it streamable) - Test if the total number of pixel is above the "cdash" limit
- No: proceed with actual behaviour
- Update() on the difference filter
- check amount of different pixels
- rescale and write difference image as PNG, as well as baseline and test image
- Yes:
- plug a virtual writer after the difference image and update it (streaming processing)
- TBD: write the difference image (not as a PNG but as a geotiff)
- No: proceed with actual behaviour