Hi Michael,It makes a lot of sense that this would fail, but skimage.filter.rank.mean has a `mask` keyword argument that can do what you want. However, it only works for uint8 or uint16 images, and if I remember correctly, it will be much slower if values exceed 12 bits, that is, your image intensity values should be in [0, 4096).
>>> from skimage.filter import rank >>> arr = array([[np.nan, 1, 2, 3, 4, 5, np.nan]]) # make sure this is 2D >>> selem = np.ones((3, 3)) >>> arr_mean1 = rank.mean(arr.astype(np.uint8)
, selem) >>> arr_mean1 array([[0, 1, 2, 3, 4, 3, 2]], dtype=uint8) >>> arr.astype(np.uint8) # nan's are actually converted to 0... Not good! array([[0, 1, 2, 3, 4, 5, 0]], dtype=uint8) >>> nan_mask = True - np.isnan(arr) >>> arr_mean2 = rank.mean(arr.astype(np.uint8) , selem, mask=nan_mask) >>> arr_mean2 # using the nan mask produces the correct output array([[1, 1, 2, 3, 4, 4, 5]], dtype=uint8) Hope this helps!Juan.On Mon, Sep 2, 2013 at 10:12 PM, Michael Aye <kmicha...@gmail.com> wrote:
Hi!--I am trying to use ndimage's uniform_filter (for a simple local mean filtering) on a map-projected image that has NAN's at the border (basically the corners where the rotated map projected image does not fit into the rectangular grid).Is there a way, maybe in skimage, to use a uniform_filter on an array that contains NANs? ndimage' version does not cope with it correctly:> arr = array([np.nan, 1,2,3,4,5,np.nan])> arrarray([ nan, 1., 2., 3., 4., 5., nan])> nd.filters.uniform_filter(arr, 3)array([ nan, nan, nan, nan, nan, nan, nan])Cheers,Michael
You received this message because you are subscribed to the Google Groups "scikit-image" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image...@googlegroups.com .
For more options, visit https://groups.google.com/groups/opt_out .