xrec = ihaart2(a,h,v,d) returns
the inverse 2-D Haar transform, xrec, for the
approximation coefficients, a, and the horizontal,
vertical, and diagonal detail coefficients, h, v,
and d. All the inputs, a, h, v,
and d, are outputs of haart2.
Obtain the 2-D Haar transform of an image limiting the transform to 2 levels.
Load and view the image of a cameraman.
im = imread('cameraman.tif');
imagesc(im)
Obtain the 2-D Haar transform using the default maximum number of levels.
[a,h,v,d] = haart2(im);
Reconstruct the image using the inverse 2-D Haar transform and view the image. Notice the near-perfect reconstruction.
xrec = ihaart2(a,h,v,d);
imagesc(xrec)
Reconstruct and view the image using the inverse 2-D Haar transform, limited to level 2. Level 2 corresponds to the fourth scale because scale is defined as , where j is the level.
xrec1 = ihaart2(a,h,v,d,2);
imagesc(xrec1)
Using fewer levels returns the average of the original image at level 2.
Inverse 2-D Haar Transform of Image Limited to Integer Data
Approximation coefficients, specified as a scalar or matrix
of coefficients, depending on the level to which the 2-D Haar transform
was calculated. a is an output from the haart2 function. Approximation, or scaling,
coefficients are a lowpass representation of the input. If a and
the elements of h, v, and d,
are vectors, xrec is a vector. If a and
the elements of h, v, and d are
matrices, xrec is a matrix, where each column
is the inverse 2-D Haar transform of the corresponding columns in a and h, v,
or d.
Data Types: double
h — Horizontal detail coefficients matrix | cell array
Horizontal detail coefficients by level, specified as a matrix
or cell array of matrices. h is an output from
the haart2 function. If h is
a matrix, the 2-D Haar transform was computed only down to one level
coarser in resolution.
Data Types: double
v — Vertical detail coefficients matrix or | cell array
Vertical detail coefficients by level, specified as a matrix
or cell array of matrices. v is an output from
the haart2 function. If v is
a matrix, the 2-D Haar transform was computed only down to one level
coarser in resolution.
Data Types: double
d — Diagonal detail coefficients matrix or | cell array
Diagonal detail coefficients by level, specified as a matrix
or cell array of matrices. d is an output from
the haart2 function. If d is
a matrix, the 2-D Haar transform was computed only down to one level
coarser in resolution.
Data Types: double
level — Maximum level 0 (default) | nonnegative integer
Maximum level to which to invert the Haar transform, specified
as a nonnegative integer. If h is a cell array, level is
less than or equal to length(h)-1. If h is
a vector or matrix, level must equal 0 or
be unspecified.
integerflag — Integer-valued data handling 'noninteger' (default) | 'integer'
Integer-valued data handling, specified as either 'noninteger' or
'integer'. 'noninteger' does not
preserve integer-valued data in the 2-D Haar transform, and
'integer' preserves it. The
'integer' option applies only if all elements of
inputs, a, h,
v, and d, are integer-valued.
The inverse 2-D Haar transform algorithm, however, uses floating-point
arithmetic.