Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

wavelet code/package

250 views
Skip to first unread message

Luc Moulinier

unread,
Jun 7, 2016, 11:29:29 AM6/7/16
to
Dear all,

I'm wondering if someone wrote some procs to implement wavelet transforms in Tcl. I'm aware there is the Haar example in the wiki, but I'm looking for something more complete that can use Daubevies mother functions for example.

Any ideas ?

Many thanks in advance !
Luc

Arjen Markus

unread,
Jun 7, 2016, 3:03:45 PM6/7/16
to
Op dinsdag 7 juni 2016 17:29:29 UTC+2 schreef Luc Moulinier:
I have been contemplating doing that, but that is as far as I have come, I am afraid. It is definitely something I would like to work on. (Maybe worth a discussion during the upcoming Tcl Users' meeting)

Regards,

Arjen

Luc Moulinier

unread,
Jun 8, 2016, 9:39:22 AM6/8/16
to
Hello Arjen !!

I hope you're well !

Unfortunatly, I won't be able to go to EuroTcl. Since some years now, I can't go alone to such meetings, and no one in my lab join the meeting either ...

Maybe a workaround, instead of programming all, would be to wrap an existing library with SWIG. There are many C/C++ wavelet libraries (http://www.daisy.org/daisypedia/daisy-digital-talking-book for example) , but as I have no experience with SWIG, Iabsolutly don't know if this is a realy hard work or not ....

Luc

Christian Gollwitzer

unread,
Jun 8, 2016, 10:34:17 AM6/8/16
to
Hi Luc,

Am 08.06.16 um 15:39 schrieb Luc Moulinier:
> Unfortunatly, I won't be able to go to EuroTcl. Since some years now,
> I can't go alone to such meetings, and no one in my lab join the
> meeting either ...
>
> Maybe a workaround, instead of programming all, would be to wrap an
> existing library with SWIG. There are many C/C++ wavelet libraries
> (http://www.daisy.org/daisypedia/daisy-digital-talking-book for
> example)

I don't see a wavelet library behind this link. The word wavelet does
not appear once on that page. Could you check the link again, please?

> , but as I have no experience with SWIG, Iabsolutly don't
> know if this is a realy hard work or not ....

Using an existing C library is the only way to get competitive
performance. SWIG is straightforward for simple libraries (not for
template stuff), but for wavelet analysis you typically want to put
vector/2D matrix data into the algorithm. Unfortunately, standard Tcl
lacks a data type for that. You could either create typemaps which
transfer from/to lists of doubles, or interface with VecTcl, which
handles numerical array data for Tcl.

Christian

Luc Moulinier

unread,
Jun 8, 2016, 11:19:29 AM6/8/16
to
Hello Christian,

Definitly sorry ! Here is the good link, which refers to some libraries :
http://stackoverflow.com/questions/9606458/looking-for-a-good-c-c-wavelet-library-for-signal-processing

Passing data to the wavelet functionss is indeed a real problem. And that definitly needs some investigation.
I ported some years ago the FANN library for neural networks. There were only one routine to change and to adapt in order to pass all possible arguments in the form key-value.

If more people are inerested, it may be worth the work ...
Luc

Arjen Markus

unread,
Jun 9, 2016, 12:37:48 AM6/9/16
to
Op woensdag 8 juni 2016 17:19:29 UTC+2 schreef Luc Moulinier:
I just found a wavelets library on SourceForge, called wavelib. It looks easy enough to interface with, but it is limited to 1D wavelets. I would say it is definitely worth the effort - a small collection of such libraries, perhaps, easy to install and use?

Regards,

Arjen

Arjen Markus

unread,
Jun 10, 2016, 2:48:45 AM6/10/16
to
Op donderdag 9 juni 2016 06:37:48 UTC+2 schreef Arjen Markus:
I have done some small-scale experiments with this package. I am not sure I completely understand the output, but it is certainly possible (with fairly little effort (*)) to make a convenient Tcl interface for it.

Regards,

Arjen

(*) I would use my own interface generator (of course :)) that I developed for interfacing with Fortran libraries. It is especially useful for lists of numerical data. One advantage is that you can insert a block of C code, so that you can do all manner of manipulation on the C side to make it look more Tclish on the outside.

Arjen Markus

unread,
Jun 10, 2016, 2:55:48 AM6/10/16
to
Op woensdag 8 juni 2016 16:34:17 UTC+2 schreef Christian Gollwitzer:

>
.., but for wavelet analysis you typically want to put
> vector/2D matrix data into the algorithm. Unfortunately, standard Tcl
> lacks a data type for that. You could either create typemaps which
> transfer from/to lists of doubles, or interface with VecTcl, which
> handles numerical array data for Tcl.
>
> Christian

Well, that does not mean that Tcl is completely incapable of dealing with such data structures. I am thinking about using binary strings ...

Regards,

Arjen

Christian Gollwitzer

unread,
Jun 10, 2016, 3:33:52 AM6/10/16
to
Am 10.06.16 um 08:55 schrieb Arjen Markus:
> Op woensdag 8 juni 2016 16:34:17 UTC+2 schreef Christian Gollwitzer:
>
>>
> .., but for wavelet analysis you typically want to put
>> vector/2D matrix data into the algorithm. Unfortunately, standard
>> Tcl lacks a data type for that. You could either create typemaps
>> which transfer from/to lists of doubles, or interface with VecTcl,
>> which handles numerical array data for Tcl.
>
>
> Well, that does not mean that Tcl is completely incapable of dealing
> with such data structures. I am thinking about using binary strings

That is correct. You can store a blob of memory containing floats as a
binary string, but then you have a hard time manipulating the data.
binary scan/format can convert between this and a list representation,
which is inefficient but accessible to Tcl code (expr/lindex & friends).

I'm arguing that a vector storage format like the one in VecTcl would be
a good additiona to the Tcl core, where binary format, Tk canvas
coordinates and Tk images would be prime users of such a data structure.

Using SWIG it is possible to define the conversion at the Tcl/C boundary
as a snippet of C code, the same as you can do with your own wrapper.
SWIG has the advantage that it can fully parse C++ code, so wrapping a
large library can be easier to start with. To get a really good
interface requires manual work with all options.

Christian

Arjen Markus

unread,
Jun 10, 2016, 7:02:31 AM6/10/16
to
Op vrijdag 10 juni 2016 09:33:52 UTC+2 schreef Christian Gollwitzer:
Perhaps we can work something out - I quite agree with you on such a storage format.

Regards,

Arjen

Arjen Markus

unread,
Jun 13, 2016, 8:56:54 AM6/13/16
to
Op vrijdag 10 juni 2016 08:48:45 UTC+2 schreef Arjen Markus:
I have a small experimental wrapper for this library now. If you are interested, I can send it to you.

Regards,

Arjen

Luc Moulinier

unread,
Jun 14, 2016, 9:30:56 AM6/14/16
to
Woaow !!! Already done Arjen ??

Sure I'd like to try it ! I can't tell I'll give a feedback tomorrow ... But I would be interested to make some tests with it !!

I f you don't mind to give me an address where to download it ....

Many thanks anyway for the work !!
Luc

Arjen Markus

unread,
Jun 15, 2016, 2:49:03 AM6/15/16
to
Op dinsdag 14 juni 2016 15:30:56 UTC+2 schreef Luc Moulinier:
I have no convenient website for this, but I will the code directly to you.

Regards,

Arjen

Luc Moulinier

unread,
Jun 16, 2016, 6:43:12 AM6/16/16
to
Many many thanks Arjen !

You'lll find my e-mail address on the wiki , by searching my name !

Thanks again !
Luc

Arjen Markus

unread,
Jun 20, 2016, 6:05:13 AM6/20/16
to
Op donderdag 16 juni 2016 12:43:12 UTC+2 schreef Luc Moulinier:
FYI: Did my first serious experiment with this wavelets library and the result looks promising, that is, I was able to smooth the timeseries I ran through it and that should highlight the features I am looking for.

Regards,

Arjen

Andreas Kupries

unread,
Jul 1, 2016, 4:07:51 PM7/1/16
to
Luc Moulinier <luc.mo...@igbmc.fr> writes:

> Hello Christian,
>
> Definitly sorry ! Here is the good link, which refers to some libraries :
> http://stackoverflow.com/questions/9606458/looking-for-a-good-c-c-wavelet-library-for-signal-processing

Thank you for the link.

> Passing data to the wavelet functionss is indeed a real problem. And
> that definitly needs some investigation. I ported some years ago
> the FANN library for neural networks. There were only one routine to
> change and to adapt in order to pass all possible arguments in the
> form key-value.

> If more people are inerested, it may be worth the work ...

I would be interested as well.
As Christian already mentioned VecTcl I feel compelled to mention
CRIMP [1] also.

For two reasons actually:

- It could be a place to add the functionality to.
- It demonstrates how you can use critcl.

Although linenoise []2 is a better demonstration on how to create a
wrapper for an existing library.

Creating wrapper is not as automatic as with SWIG, on the other oyu
have more control and can make it look more Tcl'ish.

[1] http://core.tcl.tk/akupries/crimp/index
[2] https://github.com/andreas-kupries/tcl-linenoise

--
So long,
Andreas Kupries <akup...@shaw.ca>
<http://core.tcl.tk/akupries/>
Developer @ Hewlett Packard Enterprise

Tcl'2016, Nov 14-18, Houston, TX, USA. http://www.tcl.tk/community/tcl2016/
-------------------------------------------------------------------------------

Arjen Markus

unread,
Jul 4, 2016, 7:25:40 AM7/4/16
to
Op vrijdag 1 juli 2016 22:07:51 UTC+2 schreef Andreas Kupries:

>
> > If more people are inerested, it may be worth the work ...
>
> I would be interested as well.
> As Christian already mentioned VecTcl I feel compelled to mention
> CRIMP [1] also.
>
> For two reasons actually:
>
> - It could be a place to add the functionality to.
> - It demonstrates how you can use critcl.
>
> Although linenoise []2 is a better demonstration on how to create a
> wrapper for an existing library.
>
> Creating wrapper is not as automatic as with SWIG, on the other oyu
> have more control and can make it look more Tcl'ish.
>
> [1] http://core.tcl.tk/akupries/crimp/index
> [2] https://github.com/andreas-kupries/tcl-linenoise

I used my own solution to wrap a small part of the library I found, which was inspired by Critcl, but I wanted to wrap Fortran libraries. Some time ago I started using it for wrapping C libraries as well. Like the other solutions it offers a way to customise the API at the expense of a bit more work. Here is a small part of the Tcl code I use to write the C source code:


Wrapfort::fproc ::wavelets::forwardDWT dwtC {
string waveform input
integer level input
double-array values input
integer nvalues {assign size(values)}
code {} {
{
... specific C code to call the right function or functions
}
}
}

(the declarations are replaced by pieces of C code that take care of the conversion to and from Tcl_Objs)

Indeed, using this type of code generation allows you to customize the library calls to much more convenient forms. In this case for instance, the library requires you to initialize an object that holds all the settings and then to actually transform the data - seven C routines are involved. Nothing really difficult but you do not want to put that call sequence into a Tcl program - it simply makes no sense.

Regards,

Arjen
0 new messages