[SciPy-Dev] Evolution of the generic_filter function

Martin DRUON martin.druon at wanadoo.fr
Wed Mar 31 08:37:56 EDT 2010


Hi,

first, like it is my first post here, I would like to congratulate you for your great job... thank you very much...

Now, my question. It seems that the function "scipy.ndimage.generic_filter" can only operate onto scalar objets like float or int. Moreover, it returns 
only float objects. Do you think that, in the near future, this function will be able to treat generic objects like tuples or user classes ? In that case, we 
will be able to treat directly, for example, vector fields or color images. We will also be able to apply a function onto multiple arrays at the same time, 
with the same windowing. Then, to my mind, this method will become very powerful for image processing tools.

If this evolution is not scheduled, how I can substitute this method ? For example, I would like to call a function fct(win_a, win_b) with "win_a" a 
window extracted from an array "a" and "win_b" the same window extracted from "b".


Example : 

# The original fields : two 2D vector fields with 2 components for each vector
field_size = (5,5)
a = numpy.random.random(field_size + (2,))
b = numpy.random.random(field_size + (2,))


# A simple function : the result is the sum of the element-wise product
def fct(win1,win2):
return (win1 * win2).sum()


# And now, the new generic_filter() which operates simultaneously onto sub-windows of multiple arrays
# "c" is the result field : a 2D scalar field with the same size "field_size"
c = scipy.ndimage.generic_filter( {"win1":a, "win2":b}, fct, size=(3,3), ...)

Thank you.

Martin





More information about the SciPy-Dev mailing list