[SciPy-user] Vector field filtering

Alexander Borghgraef alexander.borghgraef.rma@gmail....
Thu Feb 5 08:09:28 CST 2009

Hi all,

 I'm trying to implement a mean shift filtering algorithm, and for
that I need to apply a sliding window to a vector field or image,
possibly with as output a vector field of different dimensions. So for
example I could be filtering an RGB image of shape (3, height, width)
and returning a (x, y)+RGB vectorfield containing the mean shift
vector as wel as the color date, resulting in a shape (5,height,

 For solving this, I looked into scipy.ndimage.generic_filter, but
that doesn't seem to do the trick. For one it can't handle input and
output being of different shape (easy to circumvent by adding dummy
(x,y) to the input), and more importantly, it doesn't feature an axis
option, meaning that it shifts the filter footprint not only across
the width and height, but also across the vector dimension, which is
not what I need.

 So generic_filter is out, any suggestions for an alternative
ready-made numpy solution? Anything in scikits? Or should I implement
my own sliding window for vectorfields?

Alex Borghgraef

More information about the SciPy-user mailing list