[SciPy-user] ndimage zero-ignorant filters, or other ways to fill holes

Vincent Schut schut@sarvision...
Mon Nov 24 09:03:43 CST 2008

Guys, I feel a bit hesistant to ask this because I know: as a fairly 
intensive user of scipy i should try to give something back to the 
community and code it up myself. However, I don't feel confident enough 
with ndimage's c code, and feel I'd spend much too much time and energy 
on it.
That being said, I'm dying (well, almost) for a zero-ignorant version of 
ndimage.uniform_filter. In other words: a nd (2-d would be enough for 
me) windowing average filter that gives me back the mean of the non-zero 
pixels in the window. All current ndimage filters just incorporate the 
zero's, NaN's propagate through, and ndimage doesn't work with masks or 
masked arrays. I often find myself looking for a simple way to fill gaps 
(patches of zeros) in an image with values resembling the average 
surroundings of the gap, or smoothing an image that has zero-filled gaps 
of data that should not be taken into account while smoothing. I could 
solve such a thing very easily by iterating a version of uniform_filter 
that would not incorporate the zero-cells in its calculation.
Hmm, I feel it's hard to explain. I hope someone understands what I mean...

If someone would be willing to contribute such a feature to ndimage, 
please know that you'd at least make me very happy :)

If someone comes up with another brillant idea to fill the zero-gaps in 
my images with values that are in reasonable range of the gap's 
surroundings, I'd also be very grateful. Keep in mind that the images 
typically are pretty large, though. 7000x7000 pixels is no exception.

Vincent Schut.

More information about the SciPy-user mailing list