[Scipy-tickets] [SciPy] #1155: ndimage.filters and ndimage.interpolation is incompatible with masked_array
SciPy Trac
scipy-tickets@scipy....
Tue Apr 20 05:13:58 CDT 2010
#1155: ndimage.filters and ndimage.interpolation is incompatible with masked_array
-----------------------------------+----------------------------------------
Reporter: sam | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 0.8.0
Component: Other | Version: 0.7.0
Keywords: ndimage, masked_array |
-----------------------------------+----------------------------------------
When processing 2D images where some pixels are missing (coming from an
optical profilometer), some of the functions of ndimage give rather
unexpected results when used with masked array.
Example:
{{{
import scipy
import scipy.ndimage.interpolation as interp
L=asarray(scipy.lena(),dtype=double)
L[100,100]=NaN
Lm=ma.masked_array(L,isnan(L))
Lr=interp.rotate(Lm,5)
}}}
When looking at the resulting Lr, we see that all values have become NaN
(or the cval, 0).
On the contrary, when I do
{{{
Lr=interp.rotate(Lm,5,prefilter=False)
}}}
The result of this operation is much better and Lena is visible again.
However, the gap of 1 pixel has now become 4x4 pixels large. while this is
a much better result, in my case these 'exploding' missing data boxes are
destroying a lot of the few data points I have. Thus, it seems that the
filters in ndimage seem to be partly to blame.
Alternatively, if I use ma.fix_invalid as so:
{{{
Lf=ma.fix_invalid(Lm,fill_value=0)
Lfr=interp.rotate(Lf,5)
}}}
then the missing pixel is almost completely filtered out. However, this
modifies the results significantly as, in my case, I introduce a lot of
artificial data and my scientific data depends on the fill_value I
introduce.
All of this, seems to suggest to me that the mask in the masked array is
not used in the filtering stage and the mapping stage.
--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1155>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
More information about the Scipy-tickets
mailing list