PyWavelets / pywt

PyWavelets - Wavelet Transforms in Python
http://pywavelets.readthedocs.org
MIT License
2.03k stars 470 forks source link

new feature: contourlets #58

Open lukepfister opened 9 years ago

lukepfister commented 9 years ago

Is there interest for adding contourlet support to the package?

I was chatting with Minh Do and he's willing to provide the C source used for his Matlab Contourlet toobox. They use MEX for the Matlab to C interface, but it should be an easy(ish..) traslation.

rgommers commented 9 years ago

@lukepfister that would be great I think. The original paper has >3000 citations, so contourlets are clearly of interest to a wide audience.

I assume that Minh Do is okay with a BSD license? I had a look at http://www.mathworks.com/matlabcentral/fileexchange/8837-contourlet-toolbox which states that it's BSD licensed, but in the download there's conflicting licenses (license.txt is 2-clause BSD but COPYING says GPL). Maybe you can point that out to him?

rgommers commented 9 years ago

The Matlab source code doesn't seem too hard to convert to Python.

Regarding the contents of the package, it would be good if you could leave out or replace the Barbara image with another one (maybe scipy.misc.face). See https://github.com/scipy/scipy/pull/4785 for why.

rgommers commented 9 years ago

@stefanv the most important applications seem to be in image processing. How high is this on your wish list?

rgommers commented 9 years ago

@lukepfister how do you plan to wrap the C code? And would it make sense to translate it to Cython for maintainability?

lukepfister commented 9 years ago

@rgommers Minh was very interested in the idea of it eventually being added to Scipy, and he's aware that requires a BSD license. I'll ask him and double check.

As for wrapping the C code, I'm not sure yet. I need to get the source from him. If he wrote a C package with a MEX wrapper, we could use ctypes or Cython to accomplish the same thing. Or, as you suggest, do a complete translation into Cython. Which would be better from your point of view?

rgommers commented 9 years ago

If you go for a wrapper, Cython is preferable over ctypes I'd say. In Scipy there are a lot of older handwritten wrappers; newer code often uses Cython. ctypes is hardly used in the core Scipy stack.

Whether it makes sense to translate C to Cython or not depends on what the code looks like, and also on whether or not Minh is still maintaining the C code. If so, then of course it's easier to keep it in C because then maintenance updates can be merged more easily.

stefanv commented 9 years ago

Admittedly, this was not on my radar until I saw the issue yesterday. I went and had a look at the paper, and while it looks interesting, the only example I've seen is for denoising. It may be worth asking the author for more examples, and including those as part of the package. Also, note that there are several algorithms--each with their own restrictions.

rgommers commented 9 years ago

Looking into this some more, it would be good to define the scope of this package a bit better. There's a large amount of wavelet derivates/improvements out there. Roughly in order of how popular and widely applicable they seem to be:

(and I probably missed a few). Pretty much all code for all these flavors is Matlab and either unlicensed or GPL licensed. With the exception of the coutourlets code under discussion in this issue of course.

My impression is that the top 4 of the above list may be worth considering for inclusion, the rest seems questionable. I'll bring it up on scipy-dev, see what others think.

grlee77 commented 9 years ago

I think contourlets would be a good addition. I have seen them used mainly for image denoising or as a sparsifying transform in the context of compressed sensing image reconstruction algorithms for medical imaging (MRI and CT).

Along similar lines, I recently discovered that the Dual-Tree Complex Wavelet Transform toolbox has been ported to python (https://github.com/rjw57/dtcwt). However, I don't see any explicit mention of the license type at the repository.

The DTCWT has similar applications to contourlets (via improved directionality vs. the standard DWT). There is a highly cited review in IEEE signal processing magazine that is available here: http://dsp.rice.edu/files/publications/journal-article/2005/selthedualtre-spm-2005.pdf

rgommers commented 9 years ago

Here's the link to the discussion about this topic on scipy-dev: http://thread.gmane.org/gmane.comp.python.scientific.devel/19661/focus=19675

Shared opinion seems to be +1 for adding contourlets.

Of the list above, curvelets, contourlets and ridgelets had users. Additionally, the dual-tree complex wavelet transform seems to be quite popular so is a good candidate to add.

grlee77 commented 9 years ago

Hi @lukepfister . Now that we have released v0.30 and moved PyWavelets to its new home, we are starting to add new features and performance enhancements. Are you still interested in helping to add Dr. Do's contourlets to the package?

As mentioned above, Cython would be the preferred way to wrap the underlying C implementation. I have some prior experience converting MEX wrappers to Cython and would be willing to help.

lukepfister commented 9 years ago

I'd love to contribute!

It will probably be a few weeks before I'm able to, though- I'm tied up until the end of September.

I see there has been discussion on adding some of the other multidimensional *lets to PyWavelets. It would be good if we had some way to standardize the interface to each of these.

Any thoughts? Perhaps the first step would be to look at the existing packages and see what their function signatures are like.

On Mon, Aug 3, 2015 at 7:59 AM, Gregory R. Lee notifications@github.com wrote:

Hi @lukepfister https://github.com/lukepfister . Now that we have released v0.30 and moved PyWavelets to its new home https://github.com/PyWavelets/pywt, we are starting to add new features and performance enhancements. Are you still interested in helping to add Dr. Do's contourlets to the package?

As mentioned above, Cython would be the preferred way to wrap the underlying C implementation. I have some prior experience converting MEX wrappers to Cython and would be willing to help.

— Reply to this email directly or view it on GitHub https://github.com/PyWavelets/pywt/issues/58#issuecomment-127270232.

aaren commented 9 years ago

@lukepfister, regarding common interfaces - yes! I don't have any ideas just now but I think it could save us a lot of pain in the future if we at least give this some thought.

rgommers commented 9 years ago

A common interface would be great. I've had a look again at the Matlab code of the Contourlet Toolbox and the function inputs/outputs aren't that bad. The function names are horrible though.

What could be helpful is to only take the public API that would be exposed in a direct translation to Python (changing function names to readable ones) and put that in a Gist or a WIP PR.

vikramc1 commented 6 years ago

Hi, I was wondering if there is any work currently being done on implementing the contourlet transforms in PyWavelets?

stefanv commented 6 years ago

There's still interest in this issue, but I don't believe anyone is working on it actively.

grlee77 commented 6 years ago

Not contourlets specifically, but there is an existing port of the 2D shearlet functions from Shearlab at pyshearlab. I believe the license terms are incompatible with including it directly in PyWavelets.

I recently implemented an n-dimensional version of another closely related transform known as the digital affine shear transform (DAST) and hope to make it publicly available in the near future. It may be appropriate to make a PR to include it in PyWavelets, but it will be quite a bit of work to review, so perhaps it should live elsewhere initially.

A while back, I inquired about the license terms of the original author's Matlab implementations for the DAST and got them to specify a BSD license, so it should be possible to incorporate here at some point if desired. What I have now is already a big improvement over the Matlab package in that it is truly n-dimensional, supports complex-valued data and has higher performance (a pre-planned 192x192x192 3D transform takes < 1 second!).

I also recently implemented an n-dimensional dual-tree complex wavelet transform that I need to finalize and make available as well. If there are other with some expertise in this area who might be interested in volunteering to help review either of these, that could speed up the process.

veritas9872 commented 4 years ago

Hello. I am very interested in this topic. I am currently using Python for my work but the only implementation of contourlets is in MATLAB. Has any work been done on contourlets?

iremkapucuoglu commented 2 years ago

Hello, I am studying on satellite image denoising with Contourlet and Curvelet transforms for my graduation project. However I cannot find the related codes for my study. Can anyone please help me ?

xKHUNx commented 2 years ago

Hello, I am studying on satellite image denoising with Contourlet and Curvelet transforms for my graduation project. However I cannot find the related codes for my study. Can anyone please help me ?

Check out pycontourlet for Contourlet transform. I used a modified version of it for my implementation of Contourlet-CNN.