Table of Contents

NAME

QccWAVSubbandPyramid - data structure for a two-dimensional dyadic subband decomposition of an image

SYNOPSIS

#include "libQccPack.h"

int QccWAVSubbandPyramidInitialize(QccWAVSubbandPyramid *subband_pyramid);
int QccWAVSubbandPyramidAlloc(QccWAVSubbandPyramid *subband_pyramid);
void QccWAVSubbandPyramidFree(QccWAVSubbandPyramid *subband_pyramid);
int QccWAVSubbandPyramidNumLevelsToNumSubbands(int num_levels);
int QccWAVSubbandPyramidNumSubbandsToNumLevels(int num_subbands);
int QccWAVSubbandPyramidCalcLevelFromSubband(int subband, int num_levels);
int QccWAVSubbandPyramidSubbandSize(const QccWAVSubbandPyramid *subband_pyramid, int subband, int *subband_num_rows, int *subband_num_cols);
int QccWAVSubbandPyramidSubbandOffsets(const QccWAVSubbandPyramid *subband_pyramid, int subband, int *row_offset, int *col_offset);
void QccWAVSubbandPyramidSubbandToQccString(int subband, int num_levels, QccString qccstring);
int QccWAVSubbandPyramidPrint(const QccWAVSubbandPyramid *subband_pyramid);

DESCRIPTION

QccPack provides data structure QccWAVSubbandPyramid for representing two-dimensional subband decompositions of images. This subband-pyramid structure can be read from and written to SBP-format files, or a QccWAVSubbandPyramid structure can be used without file input or output.

The main component of a QccWAVSubbandPyramid structure is a matrix; this will be an array of wavelet coefficients and will usually be arranged in "dyadic" or "octave" decompositions (subbands) of several levels. These dyadic subbands are nested in the upper-left corner of the matrix. The size of the subbands decreases by a factor of two with each increase in level of decomposition; the frequency content of the subbands decreases with increasing subband level.

Below is a diagram illustrating the composition of the subband-pyramid matrix. Here "B" indicates the baseband subband, while "H", "V", and "D" indicate, respectively, vertical-, horizontal-, and diagonal-coefficient subbands. The level, or scale, of the subband is the number trailing the letter; e.g., "H2" indicates the horizontal subband on the second level of decomposition. The diagram below shows a two-level (two-scale) decomposition.

------------------------------
| | | |
| B2 | V2 | |
| | | |
--------------- V1 |
| | | |
| H2 | D2 | |
| | | |
------------------------------
| | |
| | |
| | |
| H1 | D1 |
| | |
| | |
| | |
------------------------------

Often, a particular subband in the subband pyramid will be addressed with an integer subband number. The subband number ranges from 0 (the baseband) to L * 3, where L is the number of levels of decomposition in the subband pyramid (the num_levels field in the data structure described below). The order of the subband number is baseband, then horizontal, vertical, and diagonal subbands in order at the highest level, followed by the horizontal, vertical, and diagonal subbands at the next highest level, etc. For example, for the two-level subband pyramid illustrated above, the following diagram shows the corresponding subband numbers.

------------------------------
| | | |
| 0 | 2 | |
| | | |
--------------- 5 |
| | | |
| 1 | 3 | |
| | | |
------------------------------
| | |
| | |
| | |
| 4 | 6 |
| | |
| | |
| | |
------------------------------

DATA STRUCTURE

The QccWAVSubbandPyramid data structure is defined as:

typedef struct
{
QccString filename;
QccString magic_num;
int major_version;
int minor_version;
int num_levels;
int num_rows;
int num_cols;
int origin_row;
int origin_col;
int subsample_pattern_row;
int subsample_pattern_col;
QccMatrix matrix;
} QccWAVSubbandPyramid;

The fields of QccWAVSubbandPyramid are as follows:

filename
The name of the file.
magic_num, major_version, minor_version
The magic number and version of the file.
num_levels
The number of levels to the subband pyramid; i.e., the number of levels (scales) of decomposition.
num_rows, num_cols
The overall size of the matrix of coefficients.
origin_row, origin_col
Indicates the row and column indices of the upper-left corner of the matrix of coefficients.
subsample_pattern_row, subsample_pattern_col
Indicates the subsampling decomposition pattern along the rows and columns.
matrix
The matrix of coefficients.

FILE FORMAT

For reading and writing structures of type QccWAVSubbandPyramid, QccPack provides the SBP file format. This file format starts with an ASCII header followed by binary data. The ASCII header consists of magic-number/revision information followed by any amount of white space (space, `\t' (tab), `\n' (newline), `\r' (carriage return)) and/or comments lines (lines starting with `#'). Following this white space, additional ASCII header information is given, separated by blanks and newlines. Binary data follows this ASCII header information. Note: one (and only one) newline must immediately follow the last component of ASCII header information before the start of the binary data.

The SBP file format consists of the following information:

SBPX.X
<white space>
L
C R
i11 i12...
i21 i22...
.
.
.

where SBP is the magic number, X.X is the version number, <white space> is white space and/or comment lines, L is the number of levels of nested decomposition in the subband pyramid, C is the number of columns of the subband-pyramid image, and R is the number of rows, imn is the coefficient for the mth row, nth column of the subband-pyramid image. L, C, and R are stored in ASCII. The image itself, imn, is stored as binary floating-point numbers (4 bytes each, MSB first, see QccFileWriteDouble(3) ). The value of L gives the number of nested (dyadic) decompositions in the matrix of coefficients. If L = 0, the image has not been decomposed; if L >= 1, then the L dyadic decompositions are recursively nested in the upper-left corner of the coefficient matrix.

ROUTINES

QccWAVSubbandPyramidInitialize() should be called before any use of a QccWAVSubbandPyramid structure. QccWAVSubbandPyramidInitialize() initializes the fields of subband_pyramid to the following values:

filename: NULL string
magic_num: QCCSUBBANDPYRAMID_MAGICNUM
major_version, minor_version: initialized to output of QccGetQccPackVersion(3)
num_levels: 0
num_rows: 0
num_cols: 0
origin_row 0
origin_col 0
subsample_pattern_row: 0
subsample_pattern_col: 0
matrix: NULL

QccWAVSubbandPyramidAlloc() allocates storage space for subband_pyramid->matrix. If subband_pyramid->matrix is not NULL, QccWAVSubbandPyramidAlloc() returns immediately without changing the state of any memory allocation. Otherwise, the subband_pyramid->matrix array is allocated. The fields subband_pyramid->num_rows and subband_pyramid->num_cols must be set prior to calling QccWAVSubbandPyramidAlloc().

QccWAVSubbandPyramidFree() frees the subband_pyramid->matrix array previously allocated by QccWAVSubbandPyramidAlloc().

QccWAVSubbandPyramidNumLevelsToNumSubbands() calculates the number of subbands in a dyadic subband pyramid with num_levels levels. This value is num_levels * 3 + 1.

QccWAVSubbandPyramidNumSubbandsToNumLevels() calculates the number of levels in a dyadic subband pyramid with num_subbands subbands.

QccWAVSubbandPyramidCalcLevelFromSubband() calculates the level of the specified subband in a subband pyramid with num_levels levels. Here, subband gives the subband number of the subband in the pyramid (see diagrams above).

QccWAVSubbandPyramidSubbandSize() calculates the size of the specified subband in subband_pyramid. The size of the subband is returned in subband_num_rows and subband_num_cols, which must be allocated prior to calling QccWAVSubbandPyramidSubbandSize().

QccWAVSubbandPyramidSubbandOffsets() calculates the location in subband_pyramid->matrix of the specified subband. The row and column offsets (relative to the upper-left corner of subband_pyramid->matrix) are returned in row_offset and col_offset, respectively, which must be allocated prior to calling QccWAVSubbandPyramidSubbandOffsets().

QccWAVSubbandPyramidSubbandToQccString() converts the specified subband number into a descriptive string giving the type of subband (horizontal, vertical, diagonal, or baseband) and the level at which the subband resides in the subband pyramid, in a manner exemplified by the diagrams above. The string is returned in qccstring, which must be allocated prior to calling QccWAVSubbandPyramidSubbandToQccString().

QccWAVSubbandPyramidPrint() prints the contents of subband_pyramid to stdout.

RETURN VALUE

These routines return 0 on success, and 1 on failure.

SEE ALSO

QccWAVSubbandPyramidDWT(3) , QccWAVSubbandPyramidInverseDWT(3) , QccPackWAV(3) , QccPack(3)

M. Antonini, M. Barlaud, P. Mathieu, and I. Daubechies, "Image Coding Using Wavelet Transform," IEEE Transactions on Image Processing, vol. 1, pp. 205-220, April 1992.

AUTHOR

Copyright (C) 1997-2021 James E. Fowler


Table of Contents



Get QccPack at SourceForge.net. Fast, secure and Free Open Source software downloads