wavelet.cpp ( File view )

• By c654162067 2013-10-31
• View(s)：227
• Point(s)： 3
```			 /*---------------------------------------------------------------------------*/
// Baseline Wavelet Transform Coder Construction Kit
//
// Geoff Davis
// gdavis@cs.dartmouth.edu
// http://www.cs.dartmouth.edu/~gdavis
//
// Copyright 1996 Geoff Davis 9/11/96
//
// Permission is granted to use this software for research purposes as
// long as this notice stays attached to this software.
//
/*---------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
#include <new.h>
#include <assert.h>
#include "Wavelet.h"

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

Wavelet::Wavelet (FilterSet *filterset)
{

analysisLow = filterset->analysisLow;
analysisHigh = filterset->analysisHigh;
synthesisLow = filterset->synthesisLow;
synthesisHigh = filterset->synthesisHigh;
symmetric = filterset->symmetric;

// amount of space to leave for padding vectors for symmetric extensions

}

/*---------------------------------------------------------------------------*/

Wavelet::~Wavelet ()
{

}

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

void Wavelet::Antoninitransform1d (float *input, float *output, int size)
{

if (analysisHigh != NULL)
{

Real *temp = new Real[size];
int nstep = 6;
int level = 4 ;			 //从第4层开始置零
transform1d(input,temp,size, nstep, -1);//小波变换

int unit = size/(1<<nstep);
for(int i = (1<<level)*unit;i<size;i++)
temp[i]=0;

invert1d(temp,output,size,nstep,-1);    //逆变换
delete []temp;

}

}

void Wavelet::transform1d (float *input, float *output, int size,
int nsteps, int sym_ext)
{

int i;
int currentIndex = 0;
Real *data[2];
int lowSize = size, highSize;

// If form of extension unspecified, default to symmetric
// extensions for symmetrical filters and periodic extensions for
// asymmetrical filters
if (sym_ext == -1)
sym_ext = symmetric;

// data[0] and data[1] are padded with npad entries on each end
data [0] = new Real [2*npad+size];
data [1] = new Real [2*npad+size];

for (i = 0; i < size; i++)

while (nsteps--)  {

if (lowSize <= 2 && symmetric == 1) {

//warning ("Reduce # of transform steps or increase signal size");
//warning ("  or switch to periodic extension");
//error ("Low pass subband is too small");
;

}

// Transform
//printf ("transforming, size = %d\n", lowSize);
transform_step (data[currentIndex], data[1-currentIndex],
lowSize, sym_ext);

highSize = lowSize/2;
lowSize = (lowSize+1)/2;

// Copy high-pass data to output signal
copy (data[1-currentIndex] + npad + lowSize, output +
lowSize, highSize);

//for (i = 0; i < lowSize+highSize; i++)
//printf ("\n\n");

// Now pass low-pass data (first 1/2 of signal) back to
// transform routine
currentIndex = 1 - currentIndex;

}

// Copy low-pass data to output signal
copy (data[currentIndex] + npad, output, lowSize);

delete [] data [1];
delete [] data [0];

}

/*---------------------------------------------------------------------------*/

void Wavelet::invert1d (float *input, float *output, int size,
int nsteps, int sym_ext)
{

int i;
int currentIndex = 0;
Real *data[2];

// If form of extension unspecified, default to symmetric
// extensions for symmetrical filters and periodic extensions for
// asymmetrical filters
if (sym_ext == -1)
sym_ext = symmetric;

int *lowSize = new int [nsteps];
int *highSize = new int [nsteps];

lowSize[0] = (size+1)/2;
highSize[0] = size/2;

for (i = 1; i < nsteps; i++) {

lowSize[i] = (lowSize[i-1]+1)/2;
highSize[i] = lowSize[i-1]/2;

}

data [0] = new Real [2*npad+size];
data [1] = new Real [2*npad+size];

while (nsteps--)  {

// grab the next high-pass component
copy (input + lowSize[nsteps],

// Combine low-pass data (first 1/2^n of signal) with high-pass
// data (next 1/2^n of signal) to get higher resolution low-pass data
invert_step (data[currentIndex], data[1-currentIndex],
lowSize[nsteps]+highSize[nsteps], sym_ext);

// Now pass low-pass data (first 1/2 of signal) back to
// transform routine
currentIndex = 1 - currentIndex;

}

// Copy inverted signal to output signal

delete [] highSize;
delete [] lowSize;

delete [] data [1];
delete [] data [0];

}

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

void Wavelet::transform2d (float *input, float *output, int hsize, int vsize,
int nsteps, int sym_ext)
{

int j;
int hLowSize = hsize, hHighSize;
int vLowSize = vsize, vHighSize;

// If form of extension unspecified, default to symmetric
// extensions for symmetrical filters and periodic extensions for
// asymmetrical filters
if (sym_ext == -1)
sym_ext = symmetric;

Real *temp_in = new Real [2*npad+max(hsize,vsize)];
Real *temp_out = new Real [2*npad+max(hsize,vsize)];

copy (input, output, hsize*vsize);

while (nsteps--)  {

if ((hLowSize <= 2 || vLowSize <= 2) && sym_ext == 1) {

warning ("Reduce # of transform steps or increase signal size");
warning ("  or switch to periodic extension");
error ("Low pass subband is too small");

}

// Do a convolution on the low pass portion of each row
for (j = 0; j < vLowSize; j++)  {

// Copy row j to data array

// Convolve with low and high pass filters
transform_step (temp_in, temp_out, hLowSize, sym_ext);

// Copy back to image

}

// Now do a convolution on the low pass portion of  each column
for (j = 0; j < hLowSize; j++)  {

// Copy column j to data array

// Convolve with low and high pass filters
transform_step (temp_in, temp_out, vLowSize, sym_ext);

// Copy back to image

}

// Now convolve low-pass portion again
hHighSize = hLowSize/2;
hLowSize = (hLowSize+1)/2;
vHighSize = vLowSize/2;
vLowSize = (vLowSize+1)/2;

}

delete [] temp_out;
delete [] temp_in;

}

/*---------------------------------------------------------------------------*/

void Wavelet::invert2d (float *input, float *output, int hsize, int vsize,
int nsteps, int sym_ext)
{

int i, j;

// If form of extension unspecified, default to symmetric
// extensions for symmetrical filters and periodic extensions for
// asymmetrical filters
if (sym_ext == -1)
sym_ext = symmetric;

int *hLowSize = new int [nsteps],
*hHighSize = new int [nsteps];
int *vLowSize = new int [nsteps],
*vHighSize = new int [nsteps];

hLowSize[0] = (hsize+1)/2;
hHighSize[0] = hsize/2;
vLowSize[0] = (vsize+1)/2;
vHighSize[0] = vsize/2;

for (i = 1; i < nsteps; i++) {

hLowSize[i] = (hLowSize[i-1]+1)/2;
hHighSize[i] = hLowSize[i-1]/2;
vLowSize[i] = (vLowSize[i-1]+1)/2;
vHighSize[i] = vLowSize[i-1]/2;

}

Real *temp_in = new Real [2*npad+max(hsize,vsize)];
Real *temp_out = new Real [2*npad+max(hsize,vsize)];

copy (input, output, hsize*vsize);

while (nsteps--)  {

// Do a reconstruction for each of the columns
for (j = 0; j < hLowSize[nsteps]+hHighSize[nsteps]; j++)  {

// Copy column j to data array
vLowSize[nsteps]+vHighSize[nsteps]);

// Combine low-pass data (first 1/2^n of signal) with high-pass
// data (next 1/2^n of signal) to get higher resolution low-pass data
invert_step (temp_in, temp_out,
vLowSize[nsteps]+vHighSize[nsteps], sym_ext);

// Copy back to image
vLowSize[nsteps]+vHighSize[nsteps]);

}

// Now do a reconstruction pass for each row
for (j = 0; j < vLowSize[nsteps]+vHighSize[nsteps]; j++)  {

// Copy row j to data array
hLowSize[nsteps]+hHighSize[nsteps]);

// Combine low-pass data (first 1/2^n of signal) with high-pass
// data (next 1/2^n of signal) to get higher resolution low-pass data
invert_step (temp_in, temp_out,
hLowSize[nsteps]+hHighSize[nsteps], sym_ext);

// Copy back to image
hLowSize[nsteps]+hHighSize[nsteps]);

}

}

delete [] hLowSize;
delete [] hHighSize;
delete [] vLowSize;
delete [] vHighSize;

delete [] temp_in;
delete [] temp_out;

}

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
// input and output are padded with npad values at the beginning and
// at the end

void Wavelet::transform_step (float *input, float *output, int size,
int sym_ext)
{

int i, j;

int lowSize = (size+1)/2;
int left_ext, right_ext;

if (analysisLow->size %2) {

// odd filter length
left_ext = right_ext = 1;

} else {

left_
...
...
```
...
Expand＞ ＜Close

Point(s): 3

0 lines left, continue to read

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
01.96 kB
~\$?+?+?-+?-?+???+?final.doc162.00 B2013-10-21 17:36
01.96 kB
01.96 kB
1001099ECG.txt303.95 kB2011-10-27 09:55
1001104ECG.txt449.72 kB2011-10-27 09:55
1001105ECG.txt300.11 kB2011-10-27 09:55
1002122ECG.txt298.52 kB2011-10-27 09:55
20090010ECG.txt306.25 kB2011-10-27 09:55
01.96 kB
01.96 kB
1002093ECG.txt298.05 kB2011-10-27 09:55
1002113ECG.txt297.83 kB2011-10-27 09:55
20080962ECG.txt300.06 kB2011-10-27 09:55
20080983ECG.txt302.18 kB2011-10-27 09:55
20091662ECG.txt302.89 kB2011-10-27 09:55
01.96 kB
cplxCput.cpp1.31 kB2011-10-27 09:55
cplxCput.h816.00 B2011-10-27 09:55
01.96 kB
cplxCput.obj21.55 kB2011-10-27 15:16
cplxCput.sbr1.33 MB2011-10-27 15:16
ECG.bsc5.12 MB2011-10-27 09:55
ECG.exe176.07 kB2013-10-24 18:12
ECG.ilk537.42 kB2013-10-24 18:12
ECG.obj25.34 kB2011-10-27 15:16
ECG.pch6.93 MB2011-10-27 15:16
ECG.pdb593.00 kB2013-10-24 18:12
ECG.res4.60 kB2011-10-27 15:16
ECG.sbr1.34 MB2011-10-27 15:16
ECGDlg.obj153.13 kB2013-10-24 18:12
ECGDlg.sbr1.56 MB2013-10-24 18:12
HeartAnalyse.obj20.09 kB2011-10-27 15:16
HeartAnalyse.sbr1.31 MB2011-10-27 15:16
mfc42d.dll908.05 kB2011-10-27 09:55
mfco42d.dll780.05 kB2011-10-27 09:55
MSVCIRTD.DLL92.08 kB2011-10-27 09:55
msvcrt.dll335.00 kB2011-10-27 09:55
msvcrtd.dll392.07 kB2011-10-27 09:55
Parameter.obj19.91 kB2011-10-27 15:16
Parameter.sbr1.31 MB2011-10-27 15:16
StdAfx.obj103.36 kB2011-10-27 15:16
StdAfx.sbr1.31 MB2011-10-27 15:16
vc60.idb601.00 kB2013-10-25 10:15
vc60.pdb484.00 kB2013-10-24 18:12
WaveCoef.obj13.76 kB2011-10-27 15:16
WaveCoef.sbr1.31 MB2011-10-27 15:16
wavelet.obj75.29 kB2011-10-27 09:55
wavelet.sbr22.38 kB2011-10-27 09:55
WaveParamSet.obj25.86 kB2011-10-27 15:16
WaveParamSet.sbr1.31 MB2011-10-27 15:16
ECG.APS24.64 kB2011-11-10 20:30
ECG.clw5.99 kB2011-11-10 21:56
ECG.cpp2.01 kB2011-10-27 09:55
ECG.dsp4.88 kB2011-10-27 09:55
ECG.dsw531.00 B2011-10-27 09:55
ECG.h1.26 kB2011-10-27 09:55
ECG.ncb553.00 kB2013-10-25 18:56
ECG.opt452.00 kB2013-10-25 18:56
ECG.plg240.00 B2013-10-25 10:15
ECG.rc9.51 kB2011-10-27 09:55
ECGDlg.cpp52.35 kB2013-10-24 18:12
ECGDlg.cpp.bak49.92 kB2013-10-24 13:59
ECGDlg.h3.12 kB2011-10-27 09:55
HeartAnalyse.cpp1.25 kB2011-10-27 09:55
HeartAnalyse.h1.29 kB2011-10-27 09:55
Parameter.cpp1.03 kB2011-10-27 09:55
Parameter.h1.22 kB2011-10-27 09:55
01.96 kB
resource.h2.47 kB2011-10-27 09:55
cursor1.cur326.00 B2011-10-27 09:55
ECG.ico1.05 kB2011-10-27 09:55
ECG.rc2395.00 B2011-10-27 09:55
StdAfx.cpp205.00 B2011-10-27 09:55
StdAfx.h1.03 kB2011-10-27 09:55
WaveCoef.cpp667.00 B2011-10-27 09:55
WaveCoef.h703.00 B2011-10-27 09:55
wavelet.cpp33.78 kB2011-10-27 09:55
wavelet.h8.32 kB2011-10-27 09:55
WaveParamSet.cpp1.75 kB2011-10-27 09:55
WaveParamSet.h1.26 kB2011-10-27 09:55
~VCBAE.tmp432.00 kB2013-10-23 19:28
<~VCBAF.tmp>0.00 B2013-10-23 19:28
?-???+?+?-+?-?+???+?final.doc495.50 kB2011-11-10 20:06
-?-???4.33 MB2012-01-28 17:39
...
• Sent successfully!
• 心电信号检测算法很好
• 3 point

wavelet.cpp (14.44 MB)

Need 3 point

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

Don't have an account？ Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版？

CodeForge Chinese Version
CodeForge English Version

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!

Warm tip!

Favorite by Ctrl+D