The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

# NAME

Math::DWT::UDWT - Pure Perl 1-D Undecimated Discrete Wavelet Transform.

Version 0.01

# SYNOPSIS

This module implements a pure Perl version of the 1-D Undecimated Discrete Wavelet Transform (UDWT), also known as the "stationary" Discrete Wavelet Transform, because it is shift-invariant.

Do not look here for efficiency - only implementation. It is designed to be a reference for others who would like to see wavelets in action. It is based off of MATLAB code from Ivan Selesnick's website at http://eeweb.poly.edu/iselesni/software/index.html.

``````    use Math::DWT::UDWT;

# new object with Math::DWT::Wavelet::Symmlet module loaded
# as wavelet; specifically, Symmlet5
my \$udwt = Math::DWT::UDWT->new('Symmlet',5);

@signal=@signal[0..509];
my \$x = \@signal;  # can be any length - not just 2^n

# performs one iteration of the UDWT on \$x
my \$coeffs = \$udwt->udwt(\$x);

# notice how the UDWT returns more data than it took in
# this is due to the linear convolution used right now.
print scalar(@{\$coeffs->[0]}); # 265
print scalar(@{\$coeffs->[1]}); # 265

# test Perfect Reconstruction
my \$y=\$udwt->iudwt(\$coeffs);

my \$maxerr=0;
foreach my \$i (0 .. scalar(@x)-1) {
my \$err = abs(\$x[\$i] - \$y->[\$i]);
\$maxerr = \$err if (\$err > \$maxerr);
}
print "\$maxerr\n"; # prints 7.92255150372512e-12 (close to 0)``````

# SUBROUTINES/METHODS

## new()

Create a new UDWT object with the wavelet WAVELET and variable VAR.

## udwt(SIGNAL)

This performs the forward Undecimated Discrete Wavelet Transform on SIGNAL using LO-PASS and HI-PASS as filters. The process is repeated LEVEL times. If the filters are omitted, it uses the filters set in the wavelet when the udwt object was created. LEVEL defaults to 1.

The structure of \$coeffs is the same as in Math::DWT, i.e., the first LEVEL arrayrefs are iterative arrays of detail coefficients, and the last arrayref is the remaining array of scaling coefficients.

## iudwt(COEFFICIENTS)

Inverse Undecimated Discrete Wavelet Transform. Same options as for Math::DWT::idwt.

## set_filters(LO_D,HI_D,LO_R,HI_R)

Set the filters manually. Each of LO_D, HI_D, LO_R, and HI_R is an arrayref to the set of coefficients for the respective filter set. Returns undef.

## get_filters()

Get the set of filters. Returns an array or an arrayref containing LO_D, HI_D, LO_R, HI_R in that order.

# AUTHOR

Mike Kroh, `<kroh at cpan.org>`

# BUGS

Please report any bugs or feature requests to `bug-math-dwt-udwt at rt.cpan.org`, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Math-DWT-UDWT. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

# ACKNOWLEDGEMENTS

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at: