I am trying out masked arrays for the first time and having some
problems. I have a 2-D image as dtype=numpy.int16
I create a mask of all False to not mask out any pixels.
I calculate the mean of the image original image and it comes out ~597.
I calculate the mean of the masked array and it comes out differently
around -179. It produces the same negative mean value no matter what
masks I try, e.g. (all True, all False, etc). Furthermore there are no
negative samples in the entire array.
Any ideas on what am I doing wrong?
Here is some sample code showing the behavior:
In [1]: img.dtype, img.shape
Out[1]: (dtype('int16'), (3200, 3456))
In [2]: mask = numpy.zeros(img.shape, dtype=bool)
In [3]: imgma = ma.masked_array(img, mask)
In [4]: img.mean()
Out[4]: 597.15437617549185
In [5]: imgma.mean()
Out[5]: -179.56858678747108
In [6]: imgma.min()
Out[6]: 25
In [7]: numpy.__version__
Out[7]: '1.3.0'
In [8]: numpy.ma.__version__
Out[8]: '1.0'
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion