Thank you, this is a start. I seems that there are more issues to resolve. I am 
trying to make a general frame that would enable one to write filters using 
this iterator.


   Nadav

-----Original Message-----
From: [email protected] on behalf of David Warde-Farley
Sent: Mon 23-Nov-09 03:21
To: Discussion of Numerical Python
Subject: Re: [Numpy-discussion] neighborhood iterator
 

On 22-Nov-09, at 12:50 PM, Nadav Horesh wrote:

>
> I wonder if the neighbourhood iterator can be used as a more  
> efficient replacement for ndimage.generic_filter. Is there a way to  
> use it from cython?

Yes, using the NumPy C API, called like any other C function is from  
Cython. Something like:

######################

import numpy as np
cimport numpy as np

cdef extern from "numpy/arrayobject.h":
     object PyArray_NeighborhoodIterNew(object iter, np.npy_intp bounds,
                                       int mode, object, np.ndarray  
fill_value)
     int PyArrayNeighborhoodIter_Next(object iter)
     int PyArrayNeighborhoodIter_Reset(object iter)

######################

should do the trick.

Note that you'll need to call np.import_array() before using any of  
these functions to initialize the C API, I think.

David
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

<<winmail.dat>>

_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to