Example #1
0
int main() {
  double x[16];
  int i;

  // Makes a fancy cubic signal
  for (i=0;i<16;i++) x[i]=5+i+0.4*i*i-0.02*i*i*i;
  
  // Prints original sigal x
  printf("Original signal:\n");
  for (i=0;i<16;i++) printf("x[%d]=%f\n",i,x[i]);
  printf("\n");

  // Do the forward 9/7 transform
  fwt97(x,16);
  
  // Prints the wavelet coefficients
  printf("Wavelets coefficients:\n");
  for (i=0;i<16;i++) printf("wc[%d]=%f\n",i,x[i]);
  printf("\n");

  // Do the inverse 9/7 transform
  iwt97(x,16); 

  // Prints the reconstructed signal 
  printf("Reconstructed signal:\n");
  for (i=0;i<16;i++) printf("xx[%d]=%f\n",i,x[i]);
  return 0;
}
Example #2
0
void b_synthesis_1d(double *_out,int _out_stride,const double *_in,int _in_stride,
                    const int *_f, double _klt[BLOCKSIZE][BLOCKSIZE]){
  int    j;
  double w[SUPPORT];
  double t[SUPPORT];

  for(j=0;j<SUPPORT;j++){
    t[j]=0;
    w[j]=0;
  }

#if USE_WAVELET
  for(j=0;j<BLOCKSIZE;j++)
    w[j]=_in[j*_in_stride];
  iwt97(t,SUPPORT,w,BLOCKSIZE);
#else
  for(j=0;j<BLOCKSIZE;j++){
    w[SUPPORT/2-BLOCKSIZE/2+j]=_in[j*_in_stride];
  }
#  if USE_KLT
  iklt(&t[SUPPORT/2-BLOCKSIZE/2],&w[SUPPORT/2-BLOCKSIZE/2],&_klt[0][0],BLOCKSIZE);
#  elif USE_DCT
#    if BLOCKSIZE_LOG>=OD_LOG_BSIZE0&&BLOCKSIZE_LOG<OD_LOG_BSIZE0+OD_NBSIZES
  (*OD_IDCT_1D_DOUBLE[BLOCKSIZE_LOG-OD_LOG_BSIZE0])
    (&t[SUPPORT/2-BLOCKSIZE/2],1,&w[SUPPORT/2-BLOCKSIZE/2]);
#    else
#      error "Need an iDCT implementation for this block size."
#    endif
#  else
    for(j=0;j<SUPPORT;j++)
      t[j]=w[j];
#  endif

#  if USE_LAPPING
#    if BLOCKSIZE_LOG>=OD_LOG_BSIZE0&&BLOCKSIZE_LOG<OD_LOG_BSIZE0+OD_NBSIZES
  (*NE_POST_FILTER_DOUBLE[BLOCKSIZE_LOG-OD_LOG_BSIZE0])
    (&t[SUPPORT/2-BLOCKSIZE],&t[SUPPORT/2-BLOCKSIZE],_f);
  (*NE_POST_FILTER_DOUBLE[BLOCKSIZE_LOG-OD_LOG_BSIZE0])
    (&t[SUPPORT/2],&t[SUPPORT/2],_f);
#    else
# error "Need a postfilter implementation for this block size."
#    endif
#  endif

#endif
  for(j=0;j<SUPPORT;j++)
    _out[j*_out_stride]=t[j];
}