📄 ifc.h
字号:
is no Wavelet decomposition at all and the image may be reconstructed
only at one resolution. If K = 1, there is one level of decomposition and
the image can be reconstructed at the original or half the original
resolution, where in the latter case we keep only the LL band of the
decomposition. In general, the image may be reconstructed at K+1
resolutions, where successive resolutions are related roughly by a factor
of 2 in each direction, with one exception which is described below.
In general, then, the resolution level index (`level_idx') supplied to
the relevant object interface functions must lie in the range 0 through
K. When the function is querying information about image dimensions,
as for `forward_info__get_level_info', these will be the dimensions of
the image which can be reconstructed from the first `level_idx' levels
of the transform. When the function is querying information about
subbands, the relevant subbands are those which are required to augment
the image reconstructed from the first `level_idx'-1 resolution levels
to that associated with the first `level_idx' levels. Thus, subbands
corresponding to `level_idx'=K are the highest frequency subbands. All
subbands in any given resolution level have roughly the same size (give
or take a pixel to account for odd-dimensioned images) and occupy the
same spectral bandwidth, but in different regions of the spatial
frequency spectrum. The number of these subbands and their bandwidth
depend upon a so-called "hp_descent" parameter, which we shall denote
D_k, where k is the resolution level index. D_k is only defined for
1 <= k <= K, since the lowest resolution level simply consists of the
LL subband at the base of the decomposition tree.
If D_k = 1, we have (at least in this resolution level) the conventional
Mallat decomposition, so that three subbands are involved in recovering
resolution level k from the previous resolution. These bands have indices,
HL_BAND (horizontally high-pass), LH_BAND (vertically high-pass) and
HH_BAND, respectively.
If D_k = 2, we have a more complex decomposition, in which each of the
conventional Mallat bands is further split into four bands. In this
case, the resolution level has 12 bands, with indices of the form
4*B_1 + B_2, where B_1 identifies the initial division into HL, LH and
HH bands and B_2 identifies which of the LL_BAND, HL_BAND, LH_BAND or
HH_BAND sub-divisions of the original Mallat bands is being considered.
Similarly, if D_k = 3, we have yet another four band split of each of the
bands resulting in the D_k=2 case. Band indices in this case must be of
the form, 16*B_1 + 4*B_2 + B_3, where B_3 identifies the finest
sub-division as one of LL_BAND, HL_BAND, LH_BAND or HH_BAND.
Note that the only legal subband index for resolution level 0 is
LL_BAND, i.e. there is only one subband at the lowest resolution level.
The dimensions of any of these subbands may be computed directly from
the dimensions of the relevant resolution level by following the rule
that even indices in the relevant dimension map to low-pass subband
samples and odd indices map to high-pass subband samples; however, note
that this rule is applied to a canvas, whose origin is at (0,0) and whose
right and lower boundaries correspond to those of the image; however, the
upper and left hand boundaries may lie anywhere within the canvas. For
a more detailed discussion of the canvas concept see the special topic
entitled "Blocks, Tiles and Frames".
********************/
/* ========================================================================= */
/* ------- Wavelet Kernel Specification and Implementation Policies -------- */
/* ========================================================================= */
/********************
The purpose of this section is to carefully describe the way in which
Wavelet transform kernels are expressed within the framework of VM3A,
and to detail the policies which must be followed at both the
compressor and the decompressor in order to get correct reconstruction,
particularly in the neighbourhood of boundaries.
Convolution Kernels
-------------------
We begin by describing kernels which are to be implemented by convolution.
These are kernels for which the `forward_info' and `reverse_info' objects'
`get_kernel_type' returns INFO__CONVOLUTION. Convolution implementations
are inherently non-reversible, i.e. they do not permit exact
reconstruction, even though perfect reconstruction is supported. As a
result, it does not much matter how the convolution operators are
implemented, whether in floating or fixed point arithmetic. In either
case there will be numerical rounding error and good implementations will
strive to minimize this within the constraints of a particular
implementation complexity. We support only FIR kernels which possess
the usual odd or even symmetry property, as explained below.
We specify these kernels from the vector space perspective, rather than
the filtering perspective. Thus, the analysis system is described in
terms of low- and high-pass vectors (waveforms) such that the subband
samples are obtained by taking inner products, while the synthesis system
is described in terms of the synthesis basis vectors (waveforms). Also,
we interpret the low-pass subband samples as belonging to the even
samples of the input sequence and the high-pass subband samples as
belonging to the odd samples of the input sequence, where sample are
indexed from 0 on. Let x[n] denote the input sequence and let y[n]
denote the sequence of interleaved subband samples, such that the
y[2n] are the low-pass samples and y[2n+1] are the high-pass samples.
This means that the low-pass subbands are associated with even indices
while the high-pass subbands are associated with odd indices. Note,
however, that the coordinate reference for the notion of even and odd
is that of the canvas, which is not necessarily identical to the image.
For a thorough discussion of the canvas idea, see the special topic
entitled "Blocks, Tiles and Frames"; for the moment, though it is
sufficient to understand that the indices of the first and last samples
in x[n] and y[n] are arbitrary. It is sufficient to consider the case in
which the relevant indices are even and odd. We write the equations for
the subband samples as:
y[2n+i] = \sum_{k=-N_i}^{P_i} A_i[k] * x[2n+i+k]
where A_0[k] is the low-pass analysis kernel, with support from -N_0 to
P_0, and A_1[k] is the high-pass analysis kernel, with support from
-N_1 to P_1. The original input sequence may be recovered using
x[k] = \sum_n S_0[k-2n] * y_0[2n] + \sum_n S_1[k-2n] * y[2n+1]
where S_0[k] is the low-pass synthesis kernel, with support from
-N'_0 to P'_0 and S_1[k] is the high-pass synthesis kernel, with
support from -N'_1 to P'_1. The `forward_info' and `reverse_info'
objects automatically construct compatible synthesis kernels and
their supports from the analysis kernels and supports; the relationships
are well-known, but we do not dwell on them here.
Convolution kernels are restricted to symmetric basis vectors.
Specifically we have either an odd number of taps, in which case,
A_i[k] = A_i[-k] for i=0, 1,
or an even number of taps, in which case
A_0[k] = A_0[1-k] and A_1[k] = -A_1[-1-k].
We turn out attention now to the left and right boundaries. We begin
by considering the most uniform case of odd length kernels. This is
also the most important for the JPEG2000 standard, since only odd
length kernels are supported in PART-I (and maybe the other parts).
* Suppose that x[n] is defined for n >= B so that the index of the
left boundary sample is B. Then we extend x[B-n] = x[B+n] and find
that y[B-n] = y[B+n]. Similarly, considering the right hand boundary,
suppose that x[n] is defined for n <= B so that the index of the right
boundary sample is now B. Again, we extend according to x[B+n] = x[B-n]
and we find that y[B+n] = y[B+n]. Thus symmetric extension in both
the original image sample domain and the interleaved subband domain is
completely trivial, regardless of where the left and right boundaries
might be. This is important, because we allow these boundaries to
occur at arbitrary indices so as to support efficient cropping and
geometric manipulation of compressed images.
Unlike odd length symmetric kernels, symmetric extension for the even
length kernels is highly dependent upon whether each of the left and
right boundaries falls on an even or an odd index. In fact, significant
problems arise if the left boundary falls on an odd index. Consequently,
for even length kernels we do not currently allow arbitrary reference
points for the Wavelet transform. Instead, in this case we insist that
the upper left hand corner of the image coincide with the origin of the
canvas, i.e. (0,0). This is unlikely to prove a limitation, since even
length kernels might never be supported by JPEG2000.
* We begin by considering the left boundary for even length filters.
As mentioned, this must have index 0, so x[n] is defined for n >= 0.
We extend according to x[-n] = x[-1+n]; that is, the boundary sample
is repeated (x[0] = x[-1]). We find that y[-2n] = y[2n-2] and
y[-2n+1] = -y[2n-1]. That is, the sub-sequence of low-pass samples,
y[2n] exhibits even symmetry (repeated boundary sample), whereas the
sub-sequence of high-pass samples, y[2n+1], exhibits odd anti-symmetry.
* To understand the symmetric extension policy at the right boundary of
for even length filters, suppose that x[n] is defined for n <= B. We
extend according to x[B+n] = x[B+1-n], i.e. the boundary sample is
again repeated.
Now if the signal has an even length, B will be odd. We find in
this case that the low-pass samples satisfy the even symmetry relation,
y[B+1+2n] = y[B-1-2n], while the high-pass samples satisfy the even
antisymmetry, y[B+2n+2] = -y[B-2n].
For odd length signals, B will be even and we find that the
low-pass samples satisfy the odd symmetry, y[B+2n] = y[B-2n], while
the high-pass samples satisfy the odd anti-symmetry relation,
y[B+2n+1] = -y[B-2n+1]. It may appear at first glance that y[B+1]
is defined in terms of itself (when n = 0) and hence not recoverable;
however, the sign flip tells us that y[B+1] = y[B-1] and so we must
have y[B+1] = 0. In fact, this is easily seen to be a consequence
of the source extension policy. So, again, all missing subband samples
are easily recovered by following the extension policy and no sample
expansion is incurred.
Lifting Kernels
---------------
We turn our attention now to lifting implementations. Lifting may be
used as a mechanism for implementing reversible or non-reversible
decompositions. In the reversible application, all coefficients and
sample values are integers and the rounding policy is important. We
understand lifting as follows: first partition the input signal into its
even and odd sub-sequences, x_0[n]=x[2n] and x_1[n] = x[2n+1]. Let S be
the number of lifting steps and label the steps s=1,2,3,...,S. The
odd labelled steps update the odd sub-sequence by adding some rounded
linear combination of the even sub-sequence samples, while the even
labelled steps update the even sub-sequence by adding some rounded
linear combination of the odd sub-sequence samples; the odd and even
labelled steps are often identified as predict and update steps,
respectively, but we do not make the distinction here and
we do not alternate the sign of the update term as is common when using
the predict-update terminology. Specifically, we set
x_{mod(s,2)}[n] = x_{mod(s,s)}[n] +
RND(\sum_{k=-N_s}^{P_s} L_s[k] * x_{mod(s+1,2)}[n+k])
where L_s[k] denotes the sequence of tap values for step s, with
support -N_s <= k <= P_s. Note that lifting taps are expressed with an
inner-product order, rather than an impulse response order. The rounding
function, RND(), applies only to reversible kernels. When the kernel
is reversible, we require all lifting coefficients to have a rational
expression of the form, L_s[k] = I_s[k] / (2^{R_s}), where I_s[k] is
an integer and R_s is the integral "radix" for step s; it is the smallest
power of 2 such that L_s[k] * 2^{R_s} is an integer for each k. This is
not, of course, the most general formulation, since we could allow
arbitrary integers on the denominator, but the more general formulation
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -