📄 synwtfilterfloatlift9x7.java
字号:
int iStep = 2*outStep; //Upsampling in outSig
int ik; //Indexing outSig
int lk; //Indexing lowSig
int hk; //Indexing highSig
// Initialize counters
lk = lowOff;
hk = highOff;
if ( outLen!=1 ) {
// "Inverse normalize" each sample
for( i=0 ; i<(outLen>>1) ; i++ ) {
lowSig[lk] /= KL;
highSig[hk] /= KH;
lk += lowStep;
hk += highStep;
}
// "Inverse normalise" last high pass coefficient
if ( outLen%2==1 ) {
highSig[hk] /= KH;
}
}
else {
// Normalize for Nyquist gain
highSig[highOff] /= 2;
}
// Generate intermediate low frequency subband
//Initialize counters
lk = lowOff;
hk = highOff;
ik = outOff + outStep;
//Apply lifting step to each "inner" sample
for( i=1 ; i<outLen-1 ; i+=2 ) {
outSig[ik] = lowSig[lk] -
DELTA*(highSig[hk] + highSig[hk+highStep]);
ik += iStep;
lk += lowStep;
hk += highStep;
}
if ( outLen%2==0 && outLen>1) {
//Use symmetric extension
outSig[ik] = lowSig[lk] - 2*DELTA*highSig[hk];
}
// Generate intermediate high frequency subband
//Initialize counters
hk = highOff;
ik = outOff;
if ( outLen>1 ) {
outSig[ik] = highSig[hk] - 2*GAMMA*outSig[ik+outStep];
}
else {
outSig[ik] = highSig[hk];
}
ik += iStep;
hk += highStep;
//Apply lifting step to each "inner" sample
for( i=2 ; i<outLen-1 ; i+=2 ) {
outSig[ik] = highSig[hk] -
GAMMA*(outSig[ik-outStep] + outSig[ik+outStep]);
ik += iStep;
hk += highStep;
}
//Handle head boundary effect if output signal has even length
if( outLen%2==1 && outLen>1 ) {
//Use symmetric extension
outSig[ik] = highSig[hk] - 2*GAMMA*outSig[ik-outStep];
}
// Generate even samples (inverse low-pass filter)
//Initialize counters
ik = outOff + outStep;
//Apply lifting step to each "inner" sample
for( i=1 ; i<outLen-1 ; i+=2 ) {
outSig[ik] -= BETA*(outSig[ik-outStep] + outSig[ik+outStep]);
ik += iStep;
}
if ( outLen%2==0 && outLen>1 ) {
// symmetric extension.
outSig[ik] -= 2*BETA*outSig[ik-outStep];
}
// Generate odd samples (inverse high pass-filter)
//Initialize counters
ik = outOff;
if ( outLen>1 ) {
// symmetric extension.
outSig[ik] -= 2*ALPHA*outSig[ik+outStep];
}
ik += iStep;
//Apply first lifting step to each "inner" sample
for( i=2; i<outLen-1 ; i+=2 ) {
outSig[ik] -= ALPHA*(outSig[ik-outStep] + outSig[ik+outStep]);
ik += iStep;
}
//Handle head boundary effect if input signal has even length
if((outLen%2==1) && (outLen>1)) {
//Use symmetric extension
outSig[ik] -= 2*ALPHA*outSig[ik-outStep];
}
}
/**
* Returns the negative support of the low-pass analysis filter. That is
* the number of taps of the filter in the negative direction.
*
* @return 2
* */
public int getAnLowNegSupport() {
return 4;
}
/**
* Returns the positive support of the low-pass analysis filter. That is
* the number of taps of the filter in the negative direction.
*
* @return The number of taps of the low-pass analysis filter in the
* positive direction
* */
public int getAnLowPosSupport() {
return 4;
}
/**
* Returns the negative support of the high-pass analysis filter. That is
* the number of taps of the filter in the negative direction.
*
* @return The number of taps of the high-pass analysis filter in
* the negative direction
* */
public int getAnHighNegSupport() {
return 3;
}
/**
* Returns the positive support of the high-pass analysis filter. That is
* the number of taps of the filter in the negative direction.
*
* @return The number of taps of the high-pass analysis filter in the
* positive direction
* */
public int getAnHighPosSupport() {
return 3;
}
/**
* Returns the negative support of the low-pass synthesis filter. That is
* the number of taps of the filter in the negative direction.
*
* <P>A MORE PRECISE DEFINITION IS NEEDED
*
* @return The number of taps of the low-pass synthesis filter in the
* negative direction
* */
public int getSynLowNegSupport() {
return 3;
}
/**
* Returns the positive support of the low-pass synthesis filter. That is
* the number of taps of the filter in the negative direction.
*
* <P>A MORE PRECISE DEFINITION IS NEEDED
*
* @return The number of taps of the low-pass synthesis filter in the
* positive direction
* */
public int getSynLowPosSupport() {
return 3;
}
/**
* Returns the negative support of the high-pass synthesis filter. That is
* the number of taps of the filter in the negative direction.
*
* <P>A MORE PRECISE DEFINITION IS NEEDED
*
* @return The number of taps of the high-pass synthesis filter in the
* negative direction
* */
public int getSynHighNegSupport() {
return 4;
}
/**
* Returns the positive support of the high-pass synthesis filter. That is
* the number of taps of the filter in the negative direction.
*
* <P>A MORE PRECISE DEFINITION IS NEEDED
*
* @return The number of taps of the high-pass synthesis filter in the
* positive direction
* */
public int getSynHighPosSupport() {
return 4;
}
/**
* Returns the implementation type of this filter, as defined in this
* class, such as WT_FILTER_INT_LIFT, WT_FILTER_FLOAT_LIFT,
* WT_FILTER_FLOAT_CONVOL.
*
* @return WT_FILTER_INT_LIFT.
* */
public int getImplType() {
return WT_FILTER_FLOAT_LIFT;
}
/**
* Returns the reversibility of the filter. A filter is considered
* reversible if it is suitable for lossless coding.
*
* @return true since the 9x7 is reversible, provided the appropriate
* rounding is performed.
* */
public boolean isReversible() {
return false;
}
/**
* Returns true if the wavelet filter computes or uses the
* same "inner" subband coefficient as the full frame wavelet transform,
* and false otherwise. In particular, for block based transforms with
* reduced overlap, this method should return false. The term "inner"
* indicates that this applies only with respect to the coefficient that
* are not affected by image boundaries processings such as symmetric
* extension, since there is not reference method for this.
*
* <P>The result depends on the length of the allowed overlap when
* compared to the overlap required by the wavelet filter. It also
* depends on how overlap processing is implemented in the wavelet
* filter.
*
* @param tailOvrlp This is the number of samples in the input
* signal before the first sample to filter that can be used for
* overlap.
*
* @param headOvrlp This is the number of samples in the input
* signal after the last sample to filter that can be used for
* overlap.
*
* @param inLen This is the lenght of the input signal to filter.The
* required number of samples in the input signal after the last sample
* depends on the length of the input signal.
*
* @return true if both overlaps are greater than 2, and correct
* processing is applied in the analyze() method.
*
*
*
*/
public boolean isSameAsFullWT(int tailOvrlp, int headOvrlp, int inLen) {
//If the input signal has even length.
if(inLen % 2 == 0) {
if(tailOvrlp >= 2 && headOvrlp >= 1) return true;
else return false;
}
//Else if the input signal has odd length.
else {
if(tailOvrlp >= 2 && headOvrlp >= 2) return true;
else return false;
}
}
/**
* Returns a string of information about the synthesis wavelet filter
*
* @return wavelet filter type.
*
*
*/
public String toString(){
return "w9x7 (lifting)";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -