int QccWAVTarp3DEncode(const QccIMGImageCube *image, const QccIMGImageCube *mask, QccBitBuffer *buffer, int transform_type, int temporal_num_levels, int spatial_num_levels, double alpha, const QccWAVWavelet *wavelet, int target_bit_cnt);
int QccWAVTarp3DDecodeHeader(QccBitBuffer *buffer, int *transform_type, int *temporal_num_levels, int *spatial_num_levels, int *num_frames, int *num_rows, int *num_cols, double *image_mean, int *max_coefficient_bits, double *alpha);
int QccWAVTarp3DDecode(QccBitBuffer *buffer, QccIMGImageCube *image, const QccIMGImageCube *mask, int transform_type, int temporal_num_levels, int spatial_num_levels, double alpha, const QccWAVWavelet *wavelet, double image_mean, int max_coefficient_bits, int target_bit_bit);
QccWAVTarp3DEncode() encodes an image cube, image, using a 3D generalization of the tarp algorithm. The original tarp algorithm was developed for 2D images by Simard et al.; it was latter extended to 3D by Wang et al. In essence, the 3D tarp algorithm involves a 3D DWT followed by a progressive "bitplane" coding of the wavelet coefficients using a Parzen-window technique to estimate probability of significance and nonadaptive arithmetic coding to code significance-map and refinement information. See "ALGORITHM" below for more detail.
image is the image cube to be coded and buffer is the output bitstream. buffer must be of QCCBITBUFFER_OUTPUT type and opened via a prior call to QccBitBufferStart(3) .
QccWAVTarp3DEncode() supports the use of both wavelet-packet and dyadic wavelet-transform decompositions. If transform_type is QCCWAVSUBBANDPYRAMID3D_DYADIC, a dyadic DWT is used; if transform_type is QCCWAVSUBBANDPYRAMID3D_PACKET, a wavelet-packet DWT is used. temporal_num_levels and spatial_num_levels give the number of levels of wavelet decomposition to perform for both transform types; for a dyadic transform, temporal_num_levels should equal spatial_num_levels. wavelet is the wavelet to use for decomposition.
The 3D tarp algorithm performance is determined primarily through the parameter alpha, a value that gives the learning rate of the density-estimation process implemented by the tarp filter. Wang et al. used a value of alpha = 0.3.
The bitstream output from the 3D tarp encoder is embedded, meaning that any prefix of the bitstream can be decoded to give a valid representation of the image. The 3D tarp encoder essentially produces output bits until the number of bits output reaches target_bit_cnt, the desired (target) total length of the output bitstream in bits, and then it stops. Note that this is the bitstream length in bits, not the rate of the bitstream (which would be expressed in bits per voxel).
QccWAVTarp3DEncode() optionally supports the use of a shape-adaptive DWT (SA-DWT) rather than the usual DWT. That is, QccWAVTarp3DEncode() can call QccWAVSubbandPyramid3DShapeAdaptiveDWT(3) as the wavelet transform rather than the usual QccWAVSubbandPyramid3DDWT(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 voxels of the image are non-transparent and thus have data that is to be transformed. Refer to QccWAVSubbandPyramid3DShapeAdaptiveDWT(3) for more details on the calculation of this SA-DWT. See "ALGORITHM" below for details on how the 3D tarp algorithm handles shape-adaptive coding.
QccWAVTarp3DDecodeHeader() decodes the header information in a bitstream previously produced by QccWAVTarp3DEncode(). The input bitstream is buffer which must be of QCCBITBUFFER_INPUT type and opened via a prior call to QccBitBufferStart(3) .
The header information is returned in transform_type (either QCCWAVSUBBANDPYRAMID3D_DYADIC or QCCWAVSUBBANDPYRAMID3D_PACKET to indicate a dyadic or wavelet-packet transform decomposition, respectively), temporal_num_levels (number of levels of wavelet decomposition in the temporal direction), spatial_num_levels (number of levels of wavelet decomposition in the spatial directions), num_frames (size of the image cube in the temporal direction), num_rows (vertical size of image cube), num_cols (horizontal size of image cube), image_mean (the mean value of the original image cube), max_coefficient_bits (indicates the precision, in number of bits, of the wavelet coefficient with the largest magnitude), and alpha (the value of the learning rate).
QccWAVTarp3DDecode() decodes the bitstream buffer, producing the reconstructed image cube, image. The bitstream must already have had its header read by a prior call to QccWAVTarp3DDecodeHeader() (i.e., you call QccWAVTarp3DDecodeHeader() first and then QccWAVTarp3DDecode()). 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 3D tarp encoding, then the original transparency mask should be passed to QccWAVTarp3DDecode() as mask. That is, mask should be the same transparency mask (untransformed) that was passed to QccWAVTarp3DEncode(). Note that QccWAVTarp3DDecode() will transform this mask via a Lazy wavelet transform, and then pass the transformed mask to QccWAVSubbandPyramid3DInverseShapeAdaptiveDWT(3) . If the usual, full-volume DWT was used in encoding, then mask should be a NULL pointer.
The 3D tarp algorithm implemented here is that described by Wang et al. This 3D tarp coder follows the same significance-refinement approach to embedded coding as employed in the 2D QccPack tarp coder QccWAVTarpEncode(3) and involves a 3D DWT followed by a progressive encoding of the bitplanes of wavelet coefficients. As is common with bitplane-based embedded coders, the encoder of the tarp algorithm codes significance information in a significance pass followed by refinement-bit information in a refinement pass. The significance pass determines the significance of a wavelet coefficient against a given threshold, while the refinement pass codes the bits of those coefficients previously determined to be significant.
The unique aspect of the 3D tarp algorithm is in the significance pass. The 3D tarp algorithm employs a density-estimation process based upon Parzen windows to determine the probability that each currently insignificant coefficient becomes significant in the current significance pass. This probability is passed to a two-symbol, nonadaptive arithmetic coder to code the actual significance value of the current coefficient. The alpha parameter to the algorithm determines the shape of the Parzen windows employed, effectively determining the learning rate of the density-estimation process. The actual density estimation is implemented as an efficient set of filtering operations that create a causal 3D filter.
The refinement pass codes refinement bits using the same nonadaptive arithmetic coder used in the significance pass except that the refinement bits are assumed equally likely, and thus a uniform density is used by the nonadaptive arithmetic coder.
As proposed by Fowler, to handle shape-adaptive coding (not originally considered by Simard et al. for the initial 2D algorithm, or by Wang et al. for the subsequent 3D algorithm), the implementation here merely skips over the transparent regions, maintaining the current probability estimate unchanged.
Y. Wang, J. T. Rucker, and J. E. Fowler, "Embedded Wavelet-Based Compression of Hyperspectral Imagery Using Tarp Coding," in Proceedings of the International Geoscience and Remote Sensing Symposium, Toulouse, France, July 2003, vol. 3, pp. 2027-2029.
P. Simard, D. Steinkraus, and H. Malvar, "On-Line Adaptation in Image Coding with a 2-D Tarp Filter", in Proceedings of the IEEE Data Compression Conference, J. A. Storer and M. Cohn, Eds., Snowbird, UT, April 2002, pp. 422-431.
J. E. Fowler, "Shape-Adaptive Tarp Coding," in Proceedings of the International Conference on Image Processing, Barcelona, Spain, September 2003, vol. 1, pp. 621-624.