A client noticed that in the case of an image with a tiny mask of two pixels, the median is not equal to the mean value which would be as expected. Instead, it is completely off. For example, in the case of two pixel values 152 and 78, the mean is 115 but the median approximation is 78.37 instead of close to 115.
The calculation can be found in mitkHistogramStatisticsCalculator.cpp.
Switching to an exact calculation in all cases could be rather demanding as it would require a lot of time and memory for the sorting of all pixels. However, we should probably introduce a threshold for smaller cases for which the calculation is exact and only switch to the approximation if there are enough samples. We have to figure out what a good threshold would be and we should also indicate with a flag and in the GUI if the median is exact or an approximation.