Table of Contents

NAME

QccWAVwdrEncode, QccWAVwdrDecode - encode/decode an image using the wavelet-difference-reduction (WDR) algorithm

SYNOPSIS

#include "libQccPack.h"

int QccWAVwdrEncode(const QccIMGImageComponent *image, const QccIMGImageComponent *mask, QccBitBuffer *buffer, int num_levels, const QccWAVWavelet *wavelet, const QccWAVPerceptualWeights *perceptual_weights, int target_bit_cnt);
int QccWAVwdrDecodeHeader(QccBitBuffer *buffer, int *num_levels, int *num_rows, int *num_cols, double *image_mean, int *max_coefficient_bits);
int QccWAVwdrDecode(QccBitBuffer *buffer, QccIMGImageComponent *image, const QccIMGImageComponent *mask, int num_levels, const QccWAVWavelet *wavelet, const QccWAVPerceptualWeights *perceptual_weights, double image_mean, int max_coefficient_bits, int target_bit_cnt);

DESCRIPTION

Encoding

QccWAVwdrEncode() encodes an image component, image, using the WDR algorithm by Tian and Wells. The WDR algorithm involves a 2D-DWT followed by a progressive encoding of the bitplanes of wavelet coefficients. The encoding of each bitplane involves significance-map coding and refinement-bits coding. Significance-map coding encodes the significance of a wavelet coefficient against a given threshold. In WDR, the two-dimensional wavelet pyramid is first mapped into a one-dimensional array according to a scanning order. Each entry in the array is assigned an index. The difference between the indices of two significant coefficients is encoded using index coding. The sign of the significant coefficient is also encoded in significance-map coding. The output symbol stream of significance-map coding is entropy-encoded using arithmetic coding with a 4-symbol context, i.e. 0, 1, +, -.

Refinement-bits coding encodes the refining bits of significant coefficients detected before the current bitplane. The output symbol stream is entropy-encoded using arithmetic coding with a 2-symbol context, i.e. 0 and 1.

image is the image component to be coded, mask is the mask for the image object (see below), buffer is the output bitstream following arithmetic coding (must be of QCCBITBUFFER_OUTPUT type and opened via a prior call to QccBitBufferStart(3) ), num_levels gives the number of levels of dyadic wavelet decomposition to perform, wavelet is the wavelet to use for decomposition, perceptual_weights is the optional perceptual weights to employ (see QccWAVPerceptualWeights(3) ; use NULL for no perceptual weighting). target_bit_cnt is the bit budget as an integer.

QccWAVwdrEncode() optionally supports the use of a shape-adaptive DWT (SA-DWT) rather than the usual DWT. That is, QccWAVwdrEncode() can call QccWAVSubbandPyramidShapeAdaptiveDWT(3) as the wavelet transform rather than the usual QccWAVSubbandPyramidDWT(3) . The use of a SA-DWT is indicated by a non-NULL mask; if mask is NULL, then the usual DWT is used. In the case of a SA-DWT, mask gives the transparency mask which indicates which pixels of the image are non-transparent and thus have data that is to be transformed. Refer to QccWAVSubbandPyramidShapeAdaptiveDWT(3) for more details on the calculation of this SA-DWT. The wavelet transform is essentially the only component of the WDR algorithm that is affected by the shape-adaptive nature of the processing. That is, transparent regions in the image are effectively skipped over when the WDR algorithm is initialized; i.e., transparent coefficients are not added to the lists of coefficients when the lists are created. Thus, the transparent coefficients are not counted in the calculation of runlengths. Note that the concept of shape-adaptive coding arose in the recent MPEG-4 standard and was not considered in the original work by Tian and Wells.

Decoding

QccWAVwdrDecodeHeader() decodes the header information in the bitstream in the input buffer (which must be of QCCBITBUFFER_INPUT type and opened via a prior call to QccBitBufferStart(3) ). The header information is returned in num_levels (number of levels of wavelet decomposition), num_rows (vertical size of image), num_cols (horizontal size of image), image_mean (the mean value of the original image), and max_coefficient_bits (the number of bits used to represent the magnitude of the coefficient with largest absolute value).

QccWAVwdrDecode() decodes the bitstream buffer, producing the reconstructed image component, image. The bitstream must already have had its header read by a prior call to QccWAVwdrDecodeHeader() (i.e., you call QccWAVwdrDecodeHeader() first and then QccWAVwdrDecode()). If target_bit_cnt is QCCENT_ANYNUMBITS, then decoding stops when the end of the input bitstream is reached; otherwise, decoding stops when target_num_bits from the input bitstream have been decoded.

If a SA-DWT was used in WDR encoding, then the original transparency mask should be passed to QccWAVwdrDecode() as mask. That is, mask should be the same transparency mask (in the spatial domain) that was passed to QccWAVwdrEncode(). Note that QccWAVwdrDecode() will transform this mask via a Lazy wavelet transform, and then pass the transformed mask to QccWAVSubbandPyramidInverseShapeAdaptiveDWT(3) . If the usual DWT was used in encoding, then mask should be a NULL pointer.

NOTES

The WDR algorithm as described originally by Tian and Wells does not employ perceptual weighting or shape-adaptive coding.

SEE ALSO

wdrencode(1) , wdrdecode(1) , imgdwt(1) , imgdist(1) , QccBitBuffer(3) , QccENTArithmeticEncode(3) , QccENTArithmeticDecode(3) , QccWAVPerceptualWeights(3) , QccWAVSubbandPyramid(3) , QccPackWAV(3) , QccPackIMG(3) , QccPack(3)

J. Tian and R. O. Wells, Jr., "Embedded Image Coding Using Wavelet Difference Reduction", in Wavelet Image and Video Compression, P. N. Topiwala, Ed., pp. 289-302, Kluwer Academic Publishers, Norwell, MA, 1998.

AUTHOR

Written by Yufei Yuan <yuanyufei@hotmail.com>

Copyright (C) 1997-2021 James E. Fowler


Table of Contents



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