Support GDAL statitistics into OTB
What changes will be made and why they would make a better Orfeo ToolBox?
This issue is about computing full-image statistics (min, max, mean, standard-deviation) and histogram on all bands as a Monteverdi-driven background task.
Currently, since it takes considerable time to process full image-data, Monteverdi approximates this calculation by doing it synchronously on a reduced pixel-data set which is the 512x512 best-fit overview. However, GDAL allows to compute full image-data statistics and store them in its meta-data file. This feature could be used by Monteverdi and OTB in order to process full image-data statistics and histogram in a background task and store it for future use.
High level description
At the lowest level, the GDAL API provides some statistics and histogram functions on full or resampled image-data. The following ones could be used:
GDALRasterBand::ComputeStatistics(): compute statistics (min, max, mean, standard-deviation) and usually caches it, if possible
GDALRasterBand::GetStatistics(): gets cached statistics, if available
GDALRasterBand::SetStatistics(): caches statistics
GDALRasterBand::GetHistogram(): computes histogram data
GDALRasterBand::SetDefaultHistogram(): stores default histogram data
GDALRasterBand::GetDefaultHistogram(): fetches default histogram data
When histogram-data has been processed by
GDALRasterBand::GetHistogram() on full image-data, it could be stored as the default histogram for further uses by using
Similarly to ITK,
otb::ImageFileWriter use the
otb::ImageIOBase abstract class in order to access image-data via polymorphism. The abstract interface of this class could be improved in order to mimic the GDAL API by adding the following pure virtual functions:
QToolButton could be added to the histogram
QDockWidget in order to start the background computation. The GDAL API statistics and histogram functions provide a progress callback which can be linked to a
QProgressBar of the Monteverdi
QStatusBar. Also, the background computation could be linked to Monteverdi, thanks to the already existing
Risks and benefits
OTB would benefit from an API allowing to drive cached statistics and histogram computation on full image-data directly from
otb::ImageFileWriter. Moreover, the implementation of a
otb::HistogramDataObject and some statistics and histogram filters based on the above-mentioned API could be considered (or, maybe the refactoring of existing filters) in order to use statistics and histogram as input and output in OTB pipelines.
However, the use of the No-Data value is not stated in the documentation of statistics and histogram functions of the GDAL API and should be checked (source code and/or experimentaly). Moreover, since the user can edit and enable/disable the use of the No-Data value which should be taken into acount in the statistics and histograms computations, the statistics and histogram might be inconsistent with image-data setup. Thus, a guarding or identifying mechanism should be discussed (e.g. adding the No-Data value of the last computation in the GDAL meta-data and/or popping-up a warning/failure dialog in Monteverdi).
Alternatives for implementations
Who will be developing the proposed changes?
- Developer who has strong knowledge of OTB and ITK core IO and pipeline.
- Developer who has strong knowledge of Monteverdi Model-View-Controller architecture.