ImageTools - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : ImageTools Package : ImageTools/DWT2D

ImageTools

  

DWT2D

  

compute forward discrete wavelet transform

  

InverseDWT2D

  

compute inverse discrete wavelet transform

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

DWT2D(img)

InverseDWT2D(coefficients)

Parameters

img

-

Image

coefficients

-

list

Options

• 

level : posint

• 

bordermode : identical( repl, mirror, const, "repl", "mirror", "const" )

• 

bordervalue : algebraic or list

• 

output identical( listtriples, threelists, flat, default, "listtriples", "threelists", "flat", "default" )

Description

• 

The DWT2D(img) command computes the Haar discrete wavelet transform of the image img. Where img can only be two dimensional or three dimensional. The low-pass decimation filter and the high-pass decimation filter used in this command are 12,12 and 12,12.

• 

The level option specifies the number of levels the wavelet transform should apply. At each level, discrete wavelet transform would be applied to Approximation. The default value is the maximum level. The maximum level can be specified as ilog2minupperboundApproximation,1,upperboundApproximation,2.

• 

When the wavelet transform is applied for one level, the command returns four Arrays with datatype float[4], denoted by Approximation, HorizontalDetail, VerticalDetail and DiagonalDetail. They are obtained by convolving by low-pass filters and high-pass filters. The relevant convolution process are listed below.

Approximation

convolve by low-pass filter horizontally and low-pass filter vertically

HorizontalDetail

convolve by low-pass filter horizontally and high-pass filter vertically

VerticalDetail

convolve by high-pass filter horizontally and low-pass filter vertically

DiagonalDetail

convolve by high-pass filter horizontally and high-pass filer vertically

• 

The bordermode and bordervalue options are used to specify the border extension mode. The bordervalue option can only be specified when the bordermode option is set to const. The bordervalue option can be anything that can be converted to a float or a list of three elements that can be converted to floats, if the img parameter is three dimensional. If only one value is provided when img is three dimensional, this value will be used at each layer. There are three border modes that can be specified: repl, mirror and const. Let A be 1234567891011121314151617181920. The resulting matrices of each border extension mode are shown below.

• 

repl : 11234551123455667891010111112131415151616171819202016161718192020

• 

mirror : 76789109212345476789109121112131415141716171819201912111213141514.

• 

const with bordervalue = v : vvvvvvvv12345vv678910vv1112131415vv1617181920vvvvvvvv.

• 

The border extension is also used when the number of rows or columns of img are odd. In this case, an extra row or column would be added to extend the img, so that it has even number of rows and columns. The way to extend the columns or rows are specified by bordermode and bordervalue.

• 

If output is specified to listtriples, then the command would return Approximationlevel,HorizontalDetaillevel,VerticalDetaillevel,DiagonalDetaillevel,..,HorizontalDetail1,VerticalDetail1,DiagonalDetail1. If output is specified to threelists, then the command would return Approximationlevel,HorizontalDetaillevel,..,HorizontalDetail1,VerticalDetaillevel,..,VerticalDetail1,DiagonalDetaillevel,..,DiagonalDetail1. If output is specified to flat, then the command would return Approxiationlevel,HorizontalDetaillevel,VerticalDetaillevel,DiagonalDetaillevel,..,HorizontalDetail1,VerticalDetail1,DiagonalDetail1. The default value for output is default which sets output to flat if level is one and sets output to listtriples when level is more than one.

• 

The InverseDWT2D(coefficients) computes the inverse Haar discrete wavelet transform. The low-pass decimation filter and the high-pass decimation filter used in this command are 1,1 and −1,1. It returns the results in an Array with datatype float[4].

• 

The InverseDWT2D(coefficients) is not a perfect inverse if the expected output has odd number of rows or columns. Then, the output array would contains the extra row or column that is added in the internal DWT2D procedure. The bordermode and bordervalue must be the same as the input when applying DWT2D. The number of maximum level it can be specified depends on coefficients. The default level is the maximum levels the inverse can apply with the given coefficients. There is no output option in the InverseDWT2D command, but coefficients can be in any form that DWT2D returns.

Examples

with(ImageTools):

img := Read(cat(kernelopts(datadir), "/images/ship.jpg"));

_rtable18446884225106120822

(5.1)

Embed(img);

result := DWT2D(img, 'level' = 1):

The Embed command needs its images to have datatype float[8]. The DWT2D command returns its results with datatype float[4].

result8 := map(rtable, result, datatype = float[8]):

Embed([[result8[1], result8[2]], [result8[3], result8[4]]]);

invresult := InverseDWT2D(result);

_rtable18446884224993392630

(5.2)

Embed(invresult);

A := Array(1..3, 1..3, (i,j) -> j + 3 * (i - 1));

123456789

(5.3)

result2 := DWT2D(A, 'bordermode' = 'const', 'bordervalue' = 25, 'output' = 'threelists');

3.014.7516.2521.0,1.50.758.754.0,0.510.250.254.0,0.00.750.254.0

(5.4)

InverseDWT2D(result2);

1.02.03.025.04.05.06.025.07.08.09.025.025.025.025.025.0

(5.5)

 

Compatibility

• 

The ImageTools[DWT2D] and ImageTools[InverseDWT2D] commands were introduced in Maple 2020.

• 

For more information on Maple 2020 changes, see Updates in Maple 2020.

See Also

SignalProcessing[DWT]

SignalProcessing[InverseDWT]