Bilateral filter: bug corrected

Attached here a code for bilateral filter: 1. The code is composed of a cython back end (bilateral_base.pyx) and a python front end (bilateral.py) 2. I do not have the tools to make windows binaries (I run it on gentoo linux) . 3. It is not hard to strip the cython code to get a pure (and slow) python implementation. 4. If someone finds the licensing inadequate, I have no problem to re-license. Any comments are (more then) welcome Nadav

Hi Nadav 2009/2/13 Nadav Horesh <nadavh@visionsense.com>:
Attached here a code for bilateral filter:
1. The code is composed of a cython back end (bilateral_base.pyx) and a python front end (bilateral.py) 2. I do not have the tools to make windows binaries (I run it on gentoo linux) . 3. It is not hard to strip the cython code to get a pure (and slow) python implementation. 4. If someone finds the licensing inadequate, I have no problem to re-license.
Any comments are (more then) welcome
Thanks for the update! I added a setup.py and fixed a small problem with the includes. Everything is here: http://github.com/stefanv/bilateral/tree/master Cheers Stéfan

Hi Stefan, I tried the installer and it did not copy bilateral.py. I tried to improve it and the result is in the attached file. I hope it would pass the mail filter, if not contact me directly to the email address below. Nadav. -----הודעה מקורית----- מאת: numpy-discussion-bounces@scipy.org בשם St?fan van der Walt נשלח: ו 13-פברואר-09 11:50 אל: Discussion of Numerical Python נושא: Re: [Numpy-discussion] Bilateral filter: bug corrected Hi Nadav 2009/2/13 Nadav Horesh <nadavh@visionsense.com>:
Attached here a code for bilateral filter:
1. The code is composed of a cython back end (bilateral_base.pyx) and a python front end (bilateral.py) 2. I do not have the tools to make windows binaries (I run it on gentoo linux) . 3. It is not hard to strip the cython code to get a pure (and slow) python implementation. 4. If someone finds the licensing inadequate, I have no problem to re-license.
Any comments are (more then) welcome
Thanks for the update! I added a setup.py and fixed a small problem with the includes. Everything is here: http://github.com/stefanv/bilateral/tree/master Cheers St?fan _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Hi Nadav 2009/2/13 Nadav Horesh <nadavh@visionsense.com>:
I tried the installer and it did not copy bilateral.py. I tried to improve it and the result is in the attached file. I hope it would pass the mail filter, if not contact me directly to the email address below.
Thanks! I applied your changes and modified the setup.py to support in-place building. Again available here: http://github.com/stefanv/bilateral/tree/master Cheers Stéfan

Hi all, I just grabbed the latest bilateral filter from Stéfan's repository, but I can't get it to work! I'm using a recent numpy SVN and the latest release of cython... In [10]: bl = bilateral.bilateral(image, 2, 150) --------------------------------------------------------------------------- NameError Traceback (most recent call last) /Users/zpincus/Documents/Research/Slack Lab/Experimental Data/Big Data/ 2009-2-17/<ipython console> in <module>() /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- packages/bilateral/bilateral.pyc in bilateral(mat, xy_sig, z_sig, filter_size, mode) 36 ''' 37 ---> 38 filter_fcn = _BB.Bilat_fcn(xy_sig, z_sig, filter_size) 39 size = filter_fcn.xy_size 40 return generic_filter(mat, filter_fcn.cfilter, size=size, mode=mode) /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- packages/bilateral/bilateral_base.so in bilateral.bilateral_base.Bilat_fcn.__init__ (bilateral/ bilateral_base.c:590)() NameError: np I know very little about the internals of cython, so I can't figure this error out... it seems to be a problem with the 'cimport numpy as np' line in the pyx file, but beyond that I'm lost. Let me know if I can provide any additional information, Zach On Feb 14, 2009, at 1:29 PM, Stéfan van der Walt wrote:
Hi Nadav
2009/2/13 Nadav Horesh <nadavh@visionsense.com>:
I tried the installer and it did not copy bilateral.py. I tried to improve it and the result is in the attached file. I hope it would pass the mail filter, if not contact me directly to the email address below.
Thanks! I applied your changes and modified the setup.py to support in-place building. Again available here:
http://github.com/stefanv/bilateral/tree/master
Cheers Stéfan _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Hi Zachary 2009/2/27 Zachary Pincus <zachary.pincus@yale.edu>:
I just grabbed the latest bilateral filter from Stéfan's repository, but I can't get it to work! I'm using a recent numpy SVN and the latest release of cython...
Just to do a sanity check, did you do: python setup.py build_ext -i and then ran the example? I've built this using the development version of Cython, but your version sounds new enough. Regards Stéfan

I could not reproduce your error. I am using latest official releases of numpy and cython on a linux box (do you use Mac?). I am attaching the package I have on my PC, for the small chance it would help. Nadav. -----הודעה מקורית----- מאת: numpy-discussion-bounces@scipy.org בשם Zachary Pincus נשלח: ו 27-פברואר-09 22:26 אל: Discussion of Numerical Python נושא: Re: [Numpy-discussion] Bilateral filter Hi all, I just grabbed the latest bilateral filter from St?fan's repository, but I can't get it to work! I'm using a recent numpy SVN and the latest release of cython... In [10]: bl = bilateral.bilateral(image, 2, 150) --------------------------------------------------------------------------- NameError Traceback (most recent call last) /Users/zpincus/Documents/Research/Slack Lab/Experimental Data/Big Data/ 2009-2-17/<ipython console> in <module>() /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- packages/bilateral/bilateral.pyc in bilateral(mat, xy_sig, z_sig, filter_size, mode) 36 ''' 37 ---> 38 filter_fcn = _BB.Bilat_fcn(xy_sig, z_sig, filter_size) 39 size = filter_fcn.xy_size 40 return generic_filter(mat, filter_fcn.cfilter, size=size, mode=mode) /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- packages/bilateral/bilateral_base.so in bilateral.bilateral_base.Bilat_fcn.__init__ (bilateral/ bilateral_base.c:590)() NameError: np I know very little about the internals of cython, so I can't figure this error out... it seems to be a problem with the 'cimport numpy as np' line in the pyx file, but beyond that I'm lost. Let me know if I can provide any additional information, Zach On Feb 14, 2009, at 1:29 PM, St?fan van der Walt wrote:
Hi Nadav
2009/2/13 Nadav Horesh <nadavh@visionsense.com>:
I tried the installer and it did not copy bilateral.py. I tried to improve it and the result is in the attached file. I hope it would pass the mail filter, if not contact me directly to the email address below.
Thanks! I applied your changes and modified the setup.py to support in-place building. Again available here:
http://github.com/stefanv/bilateral/tree/master
Cheers St?fan _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

A correction: The light distribution with two LEDs would be problematic. Nadav -----הודעה מקורית----- מאת: numpy-discussion-bounces@scipy.org בשם Nadav Horesh נשלח: ש 28-פברואר-09 20:53 אל: Discussion of Numerical Python נושא: RE: [Numpy-discussion] Bilateral filter I could not reproduce your error. I am using latest official releases of numpy and cython on a linux box (do you use Mac?). I am attaching the package I have on my PC, for the small chance it would help. Nadav. -----הודעה מקורית----- מאת: numpy-discussion-bounces@scipy.org בשם Zachary Pincus נשלח: ו 27-פברואר-09 22:26 אל: Discussion of Numerical Python נושא: Re: [Numpy-discussion] Bilateral filter Hi all, I just grabbed the latest bilateral filter from St?fan's repository, but I can't get it to work! I'm using a recent numpy SVN and the latest release of cython... In [10]: bl = bilateral.bilateral(image, 2, 150) --------------------------------------------------------------------------- NameError Traceback (most recent call last) /Users/zpincus/Documents/Research/Slack Lab/Experimental Data/Big Data/ 2009-2-17/<ipython console> in <module>() /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- packages/bilateral/bilateral.pyc in bilateral(mat, xy_sig, z_sig, filter_size, mode) 36 ''' 37 ---> 38 filter_fcn = _BB.Bilat_fcn(xy_sig, z_sig, filter_size) 39 size = filter_fcn.xy_size 40 return generic_filter(mat, filter_fcn.cfilter, size=size, mode=mode) /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- packages/bilateral/bilateral_base.so in bilateral.bilateral_base.Bilat_fcn.__init__ (bilateral/ bilateral_base.c:590)() NameError: np I know very little about the internals of cython, so I can't figure this error out... it seems to be a problem with the 'cimport numpy as np' line in the pyx file, but beyond that I'm lost. Let me know if I can provide any additional information, Zach On Feb 14, 2009, at 1:29 PM, St?fan van der Walt wrote:
Hi Nadav
2009/2/13 Nadav Horesh <nadavh@visionsense.com>:
I tried the installer and it did not copy bilateral.py. I tried to improve it and the result is in the attached file. I hope it would pass the mail filter, if not contact me directly to the email address below.
Thanks! I applied your changes and modified the setup.py to support in-place building. Again available here:
http://github.com/stefanv/bilateral/tree/master
Cheers St?fan _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Sorry, wrong addressing -----הודעה מקורית----- מאת: numpy-discussion-bounces@scipy.org בשם Nadav Horesh נשלח: ש 28-פברואר-09 21:19 אל: Discussion of Numerical Python; Discussion of Numerical Python נושא: Re: [Numpy-discussion] Bilateral filter A correction: The light distribution with two LEDs would be problematic. Nadav -----הודעה מקורית----- מאת: numpy-discussion-bounces@scipy.org בשם Nadav Horesh נשלח: ש 28-פברואר-09 20:53 אל: Discussion of Numerical Python נושא: RE: [Numpy-discussion] Bilateral filter I could not reproduce your error. I am using latest official releases of numpy and cython on a linux box (do you use Mac?). I am attaching the package I have on my PC, for the small chance it would help. Nadav. -----הודעה מקורית----- מאת: numpy-discussion-bounces@scipy.org בשם Zachary Pincus נשלח: ו 27-פברואר-09 22:26 אל: Discussion of Numerical Python נושא: Re: [Numpy-discussion] Bilateral filter Hi all, I just grabbed the latest bilateral filter from St?fan's repository, but I can't get it to work! I'm using a recent numpy SVN and the latest release of cython... In [10]: bl = bilateral.bilateral(image, 2, 150) --------------------------------------------------------------------------- NameError Traceback (most recent call last) /Users/zpincus/Documents/Research/Slack Lab/Experimental Data/Big Data/ 2009-2-17/<ipython console> in <module>() /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- packages/bilateral/bilateral.pyc in bilateral(mat, xy_sig, z_sig, filter_size, mode) 36 ''' 37 ---> 38 filter_fcn = _BB.Bilat_fcn(xy_sig, z_sig, filter_size) 39 size = filter_fcn.xy_size 40 return generic_filter(mat, filter_fcn.cfilter, size=size, mode=mode) /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- packages/bilateral/bilateral_base.so in bilateral.bilateral_base.Bilat_fcn.__init__ (bilateral/ bilateral_base.c:590)() NameError: np I know very little about the internals of cython, so I can't figure this error out... it seems to be a problem with the 'cimport numpy as np' line in the pyx file, but beyond that I'm lost. Let me know if I can provide any additional information, Zach On Feb 14, 2009, at 1:29 PM, St?fan van der Walt wrote:
Hi Nadav
2009/2/13 Nadav Horesh <nadavh@visionsense.com>:
I tried the installer and it did not copy bilateral.py. I tried to improve it and the result is in the attached file. I hope it would pass the mail filter, if not contact me directly to the email address below.
Thanks! I applied your changes and modified the setup.py to support in-place building. Again available here:
http://github.com/stefanv/bilateral/tree/master
Cheers St?fan _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Hi all, So, I re-grabbed the latest bilateral code from the repository, and did the following: [axlotl:~/Developer/Python/stefanv-bilateral] zpincus% python setup.py build_ext -i [axlotl:~/Developer/Python/stefanv-bilateral] zpincus% ipython In [1]: import numpy In [2]: import bilateral In [3]: bilateral.bilateral(numpy.ones((10,10)), 4, 4) --------------------------------------------------------------------------- NameError Traceback (most recent call last) /Users/zpincus/Developer/Python/stefanv-bilateral/<ipython console> in <module>() /Users/zpincus/Developer/Python/stefanv-bilateral/bilateral/ bilateral.pyc in bilateral(mat, xy_sig, z_sig, filter_size, mode) 36 ''' 37 ---> 38 filter_fcn = _BB.Bilat_fcn(xy_sig, z_sig, filter_size) 39 size = filter_fcn.xy_size 40 return generic_filter(mat, filter_fcn.cfilter, size=size, mode=mode) /Users/zpincus/Developer/Python/stefanv-bilateral/bilateral/ bilateral_base.so in bilateral.bilateral_base.Bilat_fcn.__init__ (bilateral/bilateral_base.c:590)() NameError: np In [4]: print numpy.version.version 1.3.0.dev6359 In [5]: import Cython.Compiler.Version In [6]: print Cython.Compiler.Version.version 0.10.3 I'm using Python 2.5.2 on OS X 10.5.6. Oddly, when I run the cython tests, numpy_test fails to even compile because it can't find 'numpy/ arrayobject.h' -- I assume this is some problem with their test harness. However, I noticed that the numpy_test.pyx file does both: 'cimport numpy as np' and 'import numpy as np' so I added the second line to the bilateral_base.pyx file... re- running the above then gets a bit farther, but things choke again, with an "AttributeError: 'numpy.ndarray' object has no attribute 'dimensions'", which comes from bilateral_base.c:1060, i.e. bilateral_base.pyx line 73. This is perplexing. I wonder if the problem is using a dev numpy version, but a few-months-old cython. (Unfortunately, I don't have mercurial installed, so I can't easily grab the dev cython -- there's no simple way to download a mercurial repository over HTTP with wget or whatnot, which is annoying.) Any thoughts? In the mean time, I guess I'll install mercurial so I can try the latest cython. Zach On Feb 28, 2009, at 1:53 PM, Nadav Horesh wrote:
I could not reproduce your error. I am using latest official releases of numpy and cython on a linux box (do you use Mac?). I am attaching the package I have on my PC, for the small chance it would help.
Nadav.
-----הודעה מקורית----- מאת: numpy-discussion-bounces@scipy.org בשם Zachary Pincus נשלח: ו 27-פברואר-09 22:26 אל: Discussion of Numerical Python נושא: Re: [Numpy-discussion] Bilateral filter
Hi all,
I just grabbed the latest bilateral filter from St?fan's repository, but I can't get it to work! I'm using a recent numpy SVN and the latest release of cython...
In [10]: bl = bilateral.bilateral(image, 2, 150) --------------------------------------------------------------------------- NameError Traceback (most recent call last)
/Users/zpincus/Documents/Research/Slack Lab/Experimental Data/Big Data/ 2009-2-17/<ipython console> in <module>()
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- packages/bilateral/bilateral.pyc in bilateral(mat, xy_sig, z_sig, filter_size, mode) 36 ''' 37 ---> 38 filter_fcn = _BB.Bilat_fcn(xy_sig, z_sig, filter_size) 39 size = filter_fcn.xy_size 40 return generic_filter(mat, filter_fcn.cfilter, size=size, mode=mode)
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- packages/bilateral/bilateral_base.so in bilateral.bilateral_base.Bilat_fcn.__init__ (bilateral/ bilateral_base.c:590)()
NameError: np
I know very little about the internals of cython, so I can't figure this error out... it seems to be a problem with the 'cimport numpy as np' line in the pyx file, but beyond that I'm lost.
Let me know if I can provide any additional information,
Zach
On Feb 14, 2009, at 1:29 PM, St?fan van der Walt wrote:
Hi Nadav
2009/2/13 Nadav Horesh <nadavh@visionsense.com>:
I tried the installer and it did not copy bilateral.py. I tried to improve it and the result is in the attached file. I hope it would pass the mail filter, if not contact me directly to the email address below.
Thanks! I applied your changes and modified the setup.py to support in-place building. Again available here:
http://github.com/stefanv/bilateral/tree/master
Cheers St?fan _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
<winmail.dat>_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Well, the latest cython doesn't help -- both errors still appear as below. (Also, the latest cython can't run the numpy tests either.) I'm befuddled. Zach On Feb 28, 2009, at 5:18 PM, Zachary Pincus wrote:
Hi all,
So, I re-grabbed the latest bilateral code from the repository, and did the following:
[axlotl:~/Developer/Python/stefanv-bilateral] zpincus% python setup.py build_ext -i [axlotl:~/Developer/Python/stefanv-bilateral] zpincus% ipython In [1]: import numpy In [2]: import bilateral In [3]: bilateral.bilateral(numpy.ones((10,10)), 4, 4) --------------------------------------------------------------------------- NameError Traceback (most recent call last)
/Users/zpincus/Developer/Python/stefanv-bilateral/<ipython console> in <module>()
/Users/zpincus/Developer/Python/stefanv-bilateral/bilateral/ bilateral.pyc in bilateral(mat, xy_sig, z_sig, filter_size, mode) 36 ''' 37 ---> 38 filter_fcn = _BB.Bilat_fcn(xy_sig, z_sig, filter_size) 39 size = filter_fcn.xy_size 40 return generic_filter(mat, filter_fcn.cfilter, size=size, mode=mode)
/Users/zpincus/Developer/Python/stefanv-bilateral/bilateral/ bilateral_base.so in bilateral.bilateral_base.Bilat_fcn.__init__ (bilateral/bilateral_base.c:590)()
NameError: np
In [4]: print numpy.version.version 1.3.0.dev6359 In [5]: import Cython.Compiler.Version In [6]: print Cython.Compiler.Version.version 0.10.3
I'm using Python 2.5.2 on OS X 10.5.6. Oddly, when I run the cython tests, numpy_test fails to even compile because it can't find 'numpy/ arrayobject.h' -- I assume this is some problem with their test harness. However, I noticed that the numpy_test.pyx file does both: 'cimport numpy as np' and 'import numpy as np'
so I added the second line to the bilateral_base.pyx file... re- running the above then gets a bit farther, but things choke again, with an "AttributeError: 'numpy.ndarray' object has no attribute 'dimensions'", which comes from bilateral_base.c:1060, i.e. bilateral_base.pyx line 73.
This is perplexing. I wonder if the problem is using a dev numpy version, but a few-months-old cython. (Unfortunately, I don't have mercurial installed, so I can't easily grab the dev cython -- there's no simple way to download a mercurial repository over HTTP with wget or whatnot, which is annoying.)
Any thoughts? In the mean time, I guess I'll install mercurial so I can try the latest cython.
Zach
On Feb 28, 2009, at 1:53 PM, Nadav Horesh wrote:
I could not reproduce your error. I am using latest official releases of numpy and cython on a linux box (do you use Mac?). I am attaching the package I have on my PC, for the small chance it would help.
Nadav.
-----הודעה מקורית----- מאת: numpy-discussion-bounces@scipy.org בשם Zachary Pincus נשלח: ו 27-פברואר-09 22:26 אל: Discussion of Numerical Python נושא: Re: [Numpy-discussion] Bilateral filter
Hi all,
I just grabbed the latest bilateral filter from St?fan's repository, but I can't get it to work! I'm using a recent numpy SVN and the latest release of cython...
In [10]: bl = bilateral.bilateral(image, 2, 150) --------------------------------------------------------------------------- NameError Traceback (most recent call last)
/Users/zpincus/Documents/Research/Slack Lab/Experimental Data/Big Data/ 2009-2-17/<ipython console> in <module>()
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- packages/bilateral/bilateral.pyc in bilateral(mat, xy_sig, z_sig, filter_size, mode) 36 ''' 37 ---> 38 filter_fcn = _BB.Bilat_fcn(xy_sig, z_sig, filter_size) 39 size = filter_fcn.xy_size 40 return generic_filter(mat, filter_fcn.cfilter, size=size, mode=mode)
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- packages/bilateral/bilateral_base.so in bilateral.bilateral_base.Bilat_fcn.__init__ (bilateral/ bilateral_base.c:590)()
NameError: np
I know very little about the internals of cython, so I can't figure this error out... it seems to be a problem with the 'cimport numpy as np' line in the pyx file, but beyond that I'm lost.
Let me know if I can provide any additional information,
Zach
On Feb 14, 2009, at 1:29 PM, St?fan van der Walt wrote:
Hi Nadav
2009/2/13 Nadav Horesh <nadavh@visionsense.com>:
I tried the installer and it did not copy bilateral.py. I tried to improve it and the result is in the attached file. I hope it would pass the mail filter, if not contact me directly to the email address below.
Thanks! I applied your changes and modified the setup.py to support in-place building. Again available here:
http://github.com/stefanv/bilateral/tree/master
Cheers St?fan _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
<winmail.dat>_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Hey Zach 2009/3/1 Zachary Pincus <zachary.pincus@yale.edu>:
Well, the latest cython doesn't help -- both errors still appear as below. (Also, the latest cython can't run the numpy tests either.) I'm befuddled.
That's pretty weird. Did you remove the .so that was build as well as any source files, before doing build_ext with the latest Cython? Also good to make sure that the latest Cython is, in fact, the one being used. Sorry, these are sanity checks, but I don't have anything better. Cheers Stéfan

I tested again, and got no errors, with the following configuration: cython 10.4 numpy 1.3.0dev6519 (the latest) gcc 4.1.2 python 2.5.4 amd64 gentoo linux Nadav. -----הודעה מקורית----- מאת: numpy-discussion-bounces@scipy.org בשם St?fan van der Walt נשלח: א 01-מרץ-09 01:15 אל: Discussion of Numerical Python נושא: Re: [Numpy-discussion] Bilateral filter Hey Zach 2009/3/1 Zachary Pincus <zachary.pincus@yale.edu>:
Well, the latest cython doesn't help -- both errors still appear as below. (Also, the latest cython can't run the numpy tests either.) I'm befuddled.
That's pretty weird. Did you remove the .so that was build as well as any source files, before doing build_ext with the latest Cython? Also good to make sure that the latest Cython is, in fact, the one being used. Sorry, these are sanity checks, but I don't have anything better. Cheers St?fan _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Well, the latest cython doesn't help -- both errors still appear as below. (Also, the latest cython can't run the numpy tests either.) I'm befuddled.
That's pretty weird. Did you remove the .so that was build as well as any source files, before doing build_ext with the latest Cython? Also good to make sure that the latest Cython is, in fact, the one being used.
Yeah... and I just tried that again, with the same results. I have no idea what could be going wrong. E.g. why would 'cimport numpy as np' not add np to the namespace on my machine whereas it does so on yours... Also, I assume that constructs like: cdef int i, dim = data.dimensions[0] are some special numpy-support syntax that's supposed to be added by the cimport numpy line? (Because numpy arrays don't expose a 'dimensions' attribute to python code...) It's like for some reason on my machine, cython isn't building its numpy support correctly. Which is understandable in the light of the fact that cython can't pass the numpy tests on my machine either. Odd indeed. Maybe I'll try on the cython list, since you guys seem to have demonstrated that the problem isn't in the bilateral code! Zach

1. "dimensions" is a field in the C struct, that describes the array object. 2. Is there a chance that the header file numpy/arrayobject.h belongs to a different numpy version that you run? I am not very experienced with cython (I suppose that Stefan has some experience). As you said, probably the cython list is a better place to look for an answer. I would be happy to see how this issue resolved. Nadav -----הודעה מקורית----- מאת: numpy-discussion-bounces@scipy.org בשם Zachary Pincus נשלח: א 01-מרץ-09 20:59 אל: Discussion of Numerical Python נושא: Re: [Numpy-discussion] Bilateral filter
Well, the latest cython doesn't help -- both errors still appear as below. (Also, the latest cython can't run the numpy tests either.) I'm befuddled.
That's pretty weird. Did you remove the .so that was build as well as any source files, before doing build_ext with the latest Cython? Also good to make sure that the latest Cython is, in fact, the one being used.
Yeah... and I just tried that again, with the same results. I have no idea what could be going wrong. E.g. why would 'cimport numpy as np' not add np to the namespace on my machine whereas it does so on yours... Also, I assume that constructs like: cdef int i, dim = data.dimensions[0] are some special numpy-support syntax that's supposed to be added by the cimport numpy line? (Because numpy arrays don't expose a 'dimensions' attribute to python code...) It's like for some reason on my machine, cython isn't building its numpy support correctly. Which is understandable in the light of the fact that cython can't pass the numpy tests on my machine either. Odd indeed. Maybe I'll try on the cython list, since you guys seem to have demonstrated that the problem isn't in the bilateral code! Zach _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Hi guys, Dag, the cython person who seems to deal with the numpy stuff, had this to say:
- cimport and import are different things; you need both. - The "dimensions" field is in Cython renamed "shape" to be closer to the Python interface. This is done in Cython/Includes/numpy.pxd
After including both the 'cimport' and 'import' lines, and changing 'dimensions' to 'shape', things work perfectly. And now the shoe is on the other foot -- I wonder why you guys were getting proper results with what Dag claims to be buggy code! Odd indeed. Zach On Mar 1, 2009, at 2:36 PM, Nadav Horesh wrote:
1. "dimensions" is a field in the C struct, that describes the array object. 2. Is there a chance that the header file numpy/arrayobject.h belongs to a different numpy version that you run?
I am not very experienced with cython (I suppose that Stefan has some experience). As you said, probably the cython list is a better place to look for an answer. I would be happy to see how this issue resolved.
Nadav
-----הודעה מקורית----- מאת: numpy-discussion-bounces@scipy.org בשם Zachary Pincus נשלח: א 01-מרץ-09 20:59 אל: Discussion of Numerical Python נושא: Re: [Numpy-discussion] Bilateral filter
Well, the latest cython doesn't help -- both errors still appear as below. (Also, the latest cython can't run the numpy tests either.) I'm befuddled.
That's pretty weird. Did you remove the .so that was build as well as any source files, before doing build_ext with the latest Cython? Also good to make sure that the latest Cython is, in fact, the one being used.
Yeah... and I just tried that again, with the same results. I have no idea what could be going wrong. E.g. why would 'cimport numpy as np' not add np to the namespace on my machine whereas it does so on yours...
Also, I assume that constructs like: cdef int i, dim = data.dimensions[0] are some special numpy-support syntax that's supposed to be added by the cimport numpy line? (Because numpy arrays don't expose a 'dimensions' attribute to python code...) It's like for some reason on my machine, cython isn't building its numpy support correctly. Which is understandable in the light of the fact that cython can't pass the numpy tests on my machine either. Odd indeed. Maybe I'll try on the cython list, since you guys seem to have demonstrated that the problem isn't in the bilateral code!
Zach _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
<winmail.dat>_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Hey Zach, 2009/3/1 Zachary Pincus <zachary.pincus@yale.edu>:
Dag, the cython person who seems to deal with the numpy stuff, had this to say:
- cimport and import are different things; you need both. - The "dimensions" field is in Cython renamed "shape" to be closer to the Python interface. This is done in Cython/Includes/numpy.pxd
Thanks for following up. I made the fixes in: http://github.com/stefanv/bilateral.git I think we should combine all these image processing algorithms (and the ones you sent to the list) into an image processing scikit. We've certainly got enough algorithms lying around! If you think that's a good idea, I'll set it up this coming week. Cheers Stéfan

2009/3/1 Zachary Pincus <zachary.pincus@yale.edu>:
Dag, the cython person who seems to deal with the numpy stuff, had this to say:
- cimport and import are different things; you need both. - The "dimensions" field is in Cython renamed "shape" to be closer to the Python interface. This is done in Cython/Includes/numpy.pxd
Thanks for following up. I made the fixes in:
Cool! Does this, out of curiosity, break things for you? (Or Nadav?)
I think we should combine all these image processing algorithms (and the ones you sent to the list) into an image processing scikit. We've certainly got enough algorithms lying around!
If you think that's a good idea, I'll set it up this coming week.
I'm all for it. I've got a few other bits lying around that might be good there too: - 2D iso-contour finding (sub-pixel precision) - 2D image warping via thin-plate splines I also have some code for various geometric algorithms lying around: - calculating optimal rigid alignments of point-sets ("Procrustes Analysis") - line intersections, closest points to lines, distance to lines, etc. if that would be of any use to anyone. Zach

2009/3/2 Zachary Pincus <zachary.pincus@yale.edu>:
Cool! Does this, out of curiosity, break things for you? (Or Nadav?)
I wish I had some way to test. Do you maybe have a short example that I can convert to a test?
I'm all for it. I've got a few other bits lying around that might be good there too: - 2D iso-contour finding (sub-pixel precision) - 2D image warping via thin-plate splines
I also have some code for various geometric algorithms lying around: - calculating optimal rigid alignments of point-sets ("Procrustes Analysis") - line intersections, closest points to lines, distance to lines, etc.
if that would be of any use to anyone.
Definitely. In addition I have code for polygon clipping, hough transforms, grey-level co-occurrence matrices, connected components, shortest paths and linear position-invariant filtering. Cheers Stéfan

Hi Stéfan,
Cool! Does this, out of curiosity, break things for you? (Or Nadav?)
I wish I had some way to test. Do you maybe have a short example that I can convert to a test?
Here's my test case for basic working-ness (e.g. non exception- throwing) of that bilateral code: In [7]: bilateral.bilateral(numpy.arange(25).reshape((5,5)), 4, 10) Out[7]: array([[ 7, 7, 7, 8, 8], [ 9, 9, 9, 10, 10], [11, 11, 12, 12, 12], [13, 13, 14, 14, 14], [15, 15, 16, 16, 16]]) That's all I'd been using to provoke the errors before, so presumably if you get that far with the fixed code, then things should be good as far as cython's concerned?
I'm all for it. I've got a few other bits lying around that might be good there too: - 2D iso-contour finding (sub-pixel precision) - 2D image warping via thin-plate splines
I also have some code for various geometric algorithms lying around: - calculating optimal rigid alignments of point-sets ("Procrustes Analysis") - line intersections, closest points to lines, distance to lines, etc.
if that would be of any use to anyone.
Definitely. In addition I have code for polygon clipping, hough transforms, grey-level co-occurrence matrices, connected components, shortest paths and linear position-invariant filtering.
Aah, fantastic. The co-occurrence matrix stuff will be very useful to me! Zach

Zach, I put the source my Cython generated here: http://mentat.za.net/refer/bilateral_base.c Can you try to compile that? Cheers Stéfan 2009/3/1 Zachary Pincus <zachary.pincus@yale.edu>:
Well, the latest cython doesn't help -- both errors still appear as below. (Also, the latest cython can't run the numpy tests either.) I'm befuddled.
That's pretty weird. Did you remove the .so that was build as well as any source files, before doing build_ext with the latest Cython? Also good to make sure that the latest Cython is, in fact, the one being used.
Yeah... and I just tried that again, with the same results. I have no idea what could be going wrong. E.g. why would 'cimport numpy as np' not add np to the namespace on my machine whereas it does so on yours...
participants (3)
-
Nadav Horesh
-
Stéfan van der Walt
-
Zachary Pincus