📄 qccspihtencode.3.html
字号:
<!-- manual page source format generated by PolyglotMan v3.0.4, -->
<!-- available via anonymous ftp from ftp.cs.berkeley.edu:/ucb/people/phelps/tcltk/rman.tar.Z -->
<HTML>
<HEAD>
<TITLE>QccSPIHTEncode.3</TITLE>
</HEAD>
<BODY>
<A HREF="#toc">Table of Contents</A><P>
<H2><A NAME="sect0" HREF="#toc0">NAME </A></H2>
QccSPIHTEncode, QccSPIHTDecode - encode/decode an image using the
SPIHT algorithm
<H2><A NAME="sect1" HREF="#toc1">SYNOPSIS </A></H2>
<B>#include <QccPack.h></B> <P>
<B>int QccSPIHTEncode(const
QccIMGImageComponent *</B><I>image</I><B>, const QccIMGImageComponent *</B><I>mask</I><B>, QccBitBuffer
*</B><I>buffer</I><B>, int </B><I>num_levels</I><B>, const QccWAVWavelet *</B><I>wavelet</I><B>, const QccWAVPerceptualWeights
*</B><I>perceptual_weights</I><B>, int </B><I>target_bit_cnt</I><B>, int </B><I>arithmetic_coded</I><B>);</B> <P>
<B>int QccSPIHTDecodeHeader(QccBitBuffer
*</B><I>buffer</I><B>, int *</B><I>num_levels</I><B>, int *</B><I>num_rows</I><B>, int *</B><I>num_cols</I><B>, double *</B><I>image_mean</I><B>,
int *</B><I>max_coefficient_bits</I><B>, int *</B><I>arithmetic_coded</I><B>);</B> <P>
<B>int QccSPIHTDecode(QccBitBuffer
*</B><I>buffer</I><B>, QccIMGImageComponent *</B><I>image</I><B>, const QccIMGImageComponent *</B><I>mask</I><B>,
int </B><I>num_levels</I><B>, const QccWAVWavelet *</B><I>wavelet</I><B>, const QccWAVPerceptualWeights
*</B><I>perceptual_weights</I><B>, double </B><I>image_mean</I><B>, int </B><I>max_coefficient_bits</I><B>, int
</B><I>arithmetic_coded</I><B>);</B>
<H2><A NAME="sect2" HREF="#toc2">DESCRIPTION </A></H2>
<H3><A NAME="sect3" HREF="#toc3">Encoding </A></H3>
<P>
<B>QccSPIHTEncode()</B> encodes an
image component, <I>image</I>, using the Set Partitioning In Hierarchical Trees
(SPIHT) algorithm by Said and Pearlman. The SPIHT algorithm involves a
2D DWT followed by a progressive "bit-plane" coding of the wavelet coefficients
using a zerotree-like quantization structure. <P>
<I>image</I> is the image component
to be coded and <I>buffer</I> is the output bitstream. <I>buffer</I> must be of <B>QCCBITBUFFER_OUTPUT</B>
type and opened via a prior call to <B><A HREF="QccBitBufferStart.3.html">QccBitBufferStart</B>(3)</A>
. <P>
<I>num_levels</I> gives
the number of levels of dyadic wavelet decomposition to perform, and <I>wavelet</I>
is the wavelet to use for decomposition. <I>perceptual_weights</I> is the optional
perceptual weights to employ (see <B><A HREF="QccWAVPerceptualWeights.3.html">QccWAVPerceptualWeights</B>(3)</A>
) or use <B>NULL</B>
for no perceptual weighting. Note: the SPIHT algorithm as described originally
by Said and Pearlman in their ITCSVT paper does not employ perceptual
weighting. <P>
The bitstream output from the SPIHT encoder is embedded, meaning
that any prefix of the bitstream can be decoded to give a valid representation
of the image. The SPIHT encoder essentially produces output bits until
the number of bits output reaches <I>target_bit_cnt</I>, 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 pixel). <P>
As originally described by Said
and Pearlman, the SPIHT algorithm uses arithmetic coding of symbols as
a final output step to improve coding efficiency. Alternatively, arithmetic
coding can be suppressed, producing what Said and Pearlman call "binary-uncoded"
output. The QccPack SPIHT implementation supports both arithmetic-coded
and binary-uncoded output modes. <I>arithmetic_coded</I> is a flag passed to <B>QccSPIHTEncode()</B>
that indicates whether arithmetic coding should be performed (1 = arithmetic
coding, 0 = binary-uncoded). <P>
<B>QccSPIHTEncode()</B> optionally supports the use
of a shape-adaptive DWT (SA-DWT) rather than the usual DWT. That is, <B>QccSPIHTEncode()</B>
can call <B><A HREF="QccWAVSubbandPyramidShapeAdaptiveDWT.3.html">QccWAVSubbandPyramidShapeAdaptiveDWT</B>(3)</A>
as the wavelet transform
rather than the usual <B><A HREF="QccWAVSubbandPyramidDWT.3.html">QccWAVSubbandPyramidDWT</B>(3)</A>
. The use of a SA-DWT is
indicated by a non-NULL <I>mask</I>; if <I>mask</I> is NULL, then the usual DWT is used.
In the case of a SA-DWT, <I>mask</I> 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 <B><A HREF="QccWAVSubbandPyramidShapeAdaptiveDWT.3.html">QccWAVSubbandPyramidShapeAdaptiveDWT</B>(3)</A>
for
more details on the calculation of this SA-DWT. The wavelet transform is
the only component of the SPIHT algorithm that is affected by the shape-adaptive
nature of the processing. That is, transparent regions in the image are
effectively set to "insignificant" by the SA-DWT, so the SPIHT algorithm
processes these transparent regions in a manner identical to that of other
insignificant coefficients. This approach has been described for a number
of zerotree-based coding algorithms; see Li and Li for an example of such.
Finally, note that the concept of shape-adaptive coding arose in the recent
MPEG-4 standard and was not considered in the original work by Said and
Pearlman.
<H3><A NAME="sect4" HREF="#toc4">Decoding </A></H3>
<P>
<B>QccSPIHTDecodeHeader()</B> decodes the header information
in a bitstream previously produced by <B>QccSPIHTEncode()</B>. The input bitstream
is <I>buffer</I> which must be of <B>QCCBITBUFFER_INPUT</B> type and opened via a prior
call to <B><A HREF="QccBitBufferStart.3.html">QccBitBufferStart</B>(3)</A>
. <P>
The header information is returned in <I>num_levels</I>
(number of levels of wavelet decomposition), <I>num_rows</I> (vertical size of
image), <I>num_cols</I> (horizontal size of image), <I>image_mean</I> (the mean value
of the original image), <I>max_coefficient_bits</I> (indicates the precision,
in number of bits, of the wavelet coefficient with the largest magnitude),
and <I>arithmetic_coded</I> (indicates whether the to data stream to follow is
arithmetic-coded or not). <P>
<B>QccSPIHTDecode()</B> decodes the bitstream <I>buffer</I>,
producing the reconstructed image component, <I>image</I>. The bitstream must
already have had its header read by a prior call to <B>QccSPIHTDecodeHeader()</B>
(i.e., you call <B>QccSPIHTDecodeHeader() </B> first and then <B>QccSPIHTDecode()</B>).
<P>
If a SA-DWT was used in SPIHT encoding, then the original transparency
mask should be passed to <B>QccSPIHTDecode()</B> as <I>mask</I>. That is, <I>mask</I> should
be the same transparency mask (in the spatial domain) that was passed
to <B>QccSPIHTEncode()</B>. Note that <B>QccSPIHTDecode()</B> will transform this <I>mask</I>
via a Lazy wavelet transform, and then pass the transformed mask to <B><A HREF="QccWAVSubbandPyramidInverseShapeAdaptiveDWT.3.html">QccWAVSubbandPyramidInverseShapeAdaptiveDWT</B>(3)</A>
.
If the usual DWT was used in encoding, then <I>mask</I> should be a NULL pointer.
<H2><A NAME="sect5" HREF="#toc5">PERFORMANCE </A></H2>
The QccPack implementation of the SPIHT algorithm was coded
"from scratch," with no consultation of the original SPIHT source code
produced at RPI by Said and Pearlman. The QccPack implementation follows
as description of the SPIHT algorithm as described by Said and Pearlman
in their original ITCSVT paper as closely as can be extrapolated from
that description. (Note that the description of the algorithm given in
their patent documents differs slightly from that of the ITCSVT description).
However, since no algorithm of complexity can ever be described <I>completely</I>
in a journal article, it is inevitable that certain subtle details were
implemented in the QccPack SPIHT coder differently from in the coder
used by Said and Pearlman for their results. As a consequence, the performance
of the QccPack implementation differs slightly from that reported by Said
and Pearlman in their ITCSVT paper and from that obtained by the binary
executable SPIHT programs available from RPI (see <A HREF="http://www.cipr.rpi.edu/research/SPIHT">http://www.cipr.rpi.edu/research/SPIHT</A>
-- with <I>arithmetic_coded</I> = 1, the QccPack code is similar to RPI's <B>codetree</B>/<B>decdtree</B>
programs, and with <I>arithmetic_coded</I> = 0, the QccPack code is similar to
RPI's <B>fastcode</B>/<B>fastdecd</B> programs). However, the difference has been observed
to be rather small, with the QccPack implementation achieving PSNR typically
0.15 dB below that achieved with the RPI binary executables (although
look at the Barbara arithmetic-coded results below for an unusually strong
QccPack performance!) <P>
A quantitative comparison follows using the three
"standard" images (Lenna, Barbara, and Goldhill) provided with QccPack.
In all of the results, the wavelet transform employed is a 5-level dyadic
decomposition using the 9/7 Cohen-Daubechies-Feauveau biorthogonal wavelet
with symmetric extension at the image boundaries (this is the same transform
used in Said and Pearlman's paper and in their executable code). The RPI
results refer to the results obtained using the SPIHT executable code
available from RPI. The "average difference" is the average of the RPI
PSNR minus the QccPack PSNR over the range 0.05 dB to 1 dB calculated at
every 0.025 dB. <P>
<blockquote> Lenna - Arithmetic Coding <BR>
------------------------------------ <BR>
| Rate | PSNR
(db) | <BR>
| (bpp) | RPI QccPack | <BR>
------------------------------------ <BR>
| 0.2 | 33.15
| 32.94 | <BR>
| 0.5 | 37.21 | 37.11 | <BR>
| 1.0 | 40.41 | 40.28
| <BR>
------------------------------------ <BR>
Average difference = 0.17 dB <BR>
<P>
<P>
Lenna - No Arithmetic Coding
<BR>
------------------------------------ <BR>
| Rate | PSNR (db) | <BR>
| (bpp) | RPI QccPack
| <BR>
------------------------------------ <BR>
| 0.2 | 32.73 | 32.59 | <BR>
| 0.5 | 36.84 | 36.72 | <BR>
| 1.0 | 39.98 | 39.88 | <BR>
------------------------------------ <BR>
Average difference = 0.14 dB <BR>
<P>
<P>
Barbara - Arithmetic Coding <BR>
------------------------------------ <BR>
| Rate | PSNR (db)
| <BR>
| (bpp) | RPI QccPack | <BR>
------------------------------------ <BR>
| 0.2 | 26.66 | 26.48
| <BR>
| 0.5 | 31.40 | 31.33 | <BR>
| 1.0 | 36.41 | 36.43 | <BR>
------------------------------------ <BR>
Average difference = 0.05 dB <BR>
<P>
<P>
Barbara - No Arithmetic Coding <BR>
------------------------------------ <BR>
| Rate | PSNR (db) | <BR>
| (bpp) | RPI QccPack
| <BR>
------------------------------------ <BR>
| 0.2 | 26.29 | 26.11 | <BR>
| 0.5 | 30.94 | 30.80 | <BR>
| 1.0 | 35.94 | 35.79 | <BR>
------------------------------------ <BR>
Average difference = 0.16 dB <BR>
<P>
<P>
Goldhill - Arithmetic Coding <BR>
------------------------------------ <BR>
| Rate | PSNR (db)
| <BR>
| (bpp) | RPI QccPack | <BR>
------------------------------------ <BR>
| 0.2 | 29.85 | 29.68
| <BR>
| 0.5 | 33.13 | 32.96 | <BR>
| 1.0 | 36.55 | 36.37 | <BR>
------------------------------------
<BR>
Average difference = 0.15 dB <BR>
<P>
<P>
Goldhill - No Arithmetic Coding
<BR>
------------------------------------ <BR>
| Rate | PSNR (db) | <BR>
| (bpp) | RPI QccPack
| <BR>
------------------------------------ <BR>
| 0.2 | 29.53 | 29.33 | <BR>
| 0.5 | 32.71 | 32.54 | <BR>
| 1.0 | 36.00 | 35.84 | <BR>
------------------------------------ <BR>
Average difference = 0.14 dB <BR>
</blockquote>
<P>
<H2><A NAME="sect6" HREF="#toc6">SEE ALSO </A></H2>
<B><A HREF="spihtencode.1.html">spihtencode</B>(1)</A>
, <B><A HREF="spihtdecode.1.html">spihtdecode</B>(1)</A>
, <B><A HREF="imgdwt.1.html">imgdwt</B>(1)</A>
, <B><A HREF="squniform.1.html">squniform</B>(1)</A>
, <B><A HREF="QccBitBuffer.3.html">QccBitBuffer</B>(3)</A>
,
<B><A HREF="QccWAVPerceptualWeights.3.html">QccWAVPerceptualWeights</B>(3)</A>
, <B><A HREF="QccWAVSubbandPyramid.3.html">QccWAVSubbandPyramid</B>(3)</A>
, <B><A HREF="QccWAVSubbandPyramidDWT.3.html">QccWAVSubbandPyramidDWT</B>(3)</A>
,
<B><A HREF="QccWAVSubbandPyramidShapeAdaptiveDWT.3.html">QccWAVSubbandPyramidShapeAdaptiveDWT</B>(3)</A>
, <B><A HREF="QccPackWAV.3.html">QccPackWAV</B>(3)</A>
, <B><A HREF="QccPackIMG.3.html">QccPackIMG</B>(3)</A>
,
<B><A HREF="QccPack.3.html">QccPack</B>(3)</A>
<P>
A. Said and W. A. Pearlman, "A New, Fast, and Efficient Image
Codec Based on Set Partitioning in Hierarchical Trees," <I>IEEE Transactions
on Circuits and Systems for Video Technology</I>, vol. 6, no. 3, pp. 243-250,
June 1996. <P>
S. Li and W. Li, "Shape-Adaptive Discrete Wavelet Transforms for
Arbitrarily Shaped Visual Object Coding," <I>IEEE Transactions on Circuits
and Systems for Video Coding</I>, vol. 10, pp. 725-743, August 2000. <P>
<H2><A NAME="sect7" HREF="#toc7">AUTHOR
</A></H2>
Copyright (C) 1997-2001 James E. Fowler <P>
<H2><A NAME="sect8" HREF="#toc8">LICENSE </A></H2>
The Set Partitioning
In Hierarchical Trees (SPIHT) algorithm is protected by US Patent #5,764,807
(issued June 9, 1998) and other international patents and patents pending.
An implementation of the SPIHT algorithm is included herein (utility programs
spihtencode and spihtdecode, and spiht.c in the QccPackSPIHT module of
the QccPack library) with the permission of PrimaComp, Inc., exclusive
holder of patent rights. PrimaComp has graciously granted a license with
certain restrictions governing the terms and conditions for use, copying,
distribution, and modification of the SPIHT algorithm implementation contained
herein. Specifically, only use in academic and non-commercial research is
permitted, while all commercial use is prohibited. Refer to the file LICENSE-SPIHT
for more details. <P>
<P>
<HR><P>
<A NAME="toc"><B>Table of Contents</B></A><P>
<UL>
<LI><A NAME="toc0" HREF="#sect0">NAME</A></LI>
<LI><A NAME="toc1" HREF="#sect1">SYNOPSIS</A></LI>
<LI><A NAME="toc2" HREF="#sect2">DESCRIPTION</A></LI>
<UL>
<LI><A NAME="toc3" HREF="#sect3">Encoding</A></LI>
<LI><A NAME="toc4" HREF="#sect4">Decoding</A></LI>
</UL>
<LI><A NAME="toc5" HREF="#sect5">PERFORMANCE</A></LI>
<LI><A NAME="toc6" HREF="#sect6">SEE ALSO</A></LI>
<LI><A NAME="toc7" HREF="#sect7">AUTHOR</A></LI>
<LI><A NAME="toc8" HREF="#sect8">LICENSE</A></LI>
</UL>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -