I don't know if I'm going to get an answer to this, but basically I get different mean values when running MPSImageStatisticsMeanAndVariance
shader than when I use either of CUDA nppiMeanStdDev
, custom OpenCL and shader and CPU code.
The difference for mean is significant. For a sample image I get
{ 0.36, 0.30, 0.22 } // MPS
{ 0.55, 0.43, 0.21 } // Any other method
Deviation/Variance is slightly different as well (though much less), but it might be due to the difference in the mean value.
My first guess is that MTLTexture
transforms underlying data somehow (sRBG->linear?) and the mean is calculated from that transformed data, instead of from the original data. But maybe there's something else going on that I'm missing? How can I achieve parity between Metal and other methods?
Any assistance would be appreciated.