compute forward discrete wavelet transform
compute inverse discrete wavelet transform
level : posint
bordermode : identical( repl, mirror, const, "repl", "mirror", "const" )
bordervalue : algebraic or list
output identical( listtriples, threelists, flat, default, "listtriples", "threelists", "flat", "default" )
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 ilog2⁡min⁡upperbound⁡Approximation,1,upperbound⁡Approximation,2.
When the wavelet transform is applied for one level, the command returns four Arrays with datatype float, 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.
convolve by low-pass filter horizontally and low-pass filter vertically
convolve by low-pass filter horizontally and high-pass filter vertically
convolve by high-pass filter horizontally and low-pass filter vertically
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.
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.
img := Read(cat(kernelopts(datadir), "/images/ship.jpg"));
result := DWT2D(img, 'level' = 1):
The Embed command needs its images to have datatype float. The DWT2D command returns its results with datatype float.
result8 := map(rtable, result, datatype = float):
Embed([[result8, result8], [result8, result8]]);
invresult := InverseDWT2D(result);
A := Array(1..3, 1..3, (i,j) -> j + 3 * (i - 1));
result2 := DWT2D(A, 'bordermode' = 'const', 'bordervalue' = 25, 'output' = 'threelists');
The ImageTools[DWT2D] and ImageTools[InverseDWT2D] commands were introduced in Maple 2020.
For more information on Maple 2020 changes, see Updates in Maple 2020.
Download Help Document
What kind of issue would you like to report? (Optional)