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);
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 |
| | |
| | |
| | |
------------------------------
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:
The SBP file format consists of the following information:
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.SBPX.X
<white space>
L
C R
i11 i12...
i21 i22...
.
.
.
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.
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.