mirror of
https://github.com/simon987/wavelib.git
synced 2025-04-20 02:26:45 +00:00
commit : sureshrink error correction
This commit is contained in:
parent
fa68a811af
commit
ee88fece29
@ -248,17 +248,17 @@ void sureshrink(double *signal,int N,char *wname,char *method,char *ext,char *th
|
|||||||
if(!strcmp(thresh,"hard")) {
|
if(!strcmp(thresh,"hard")) {
|
||||||
for(i = 0; i < dwt_len;++i) {
|
for(i = 0; i < dwt_len;++i) {
|
||||||
if (fabs(wt->output[len+i]) < td) {
|
if (fabs(wt->output[len+i]) < td) {
|
||||||
wt->output[i] = 0;
|
wt->output[len+i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(!strcmp(thresh,"soft")) {
|
} else if(!strcmp(thresh,"soft")) {
|
||||||
for(i = 0; i < dwt_len;++i) {
|
for(i = 0; i < dwt_len;++i) {
|
||||||
if (fabs(wt->output[len + i]) < td) {
|
if (fabs(wt->output[len + i]) < td) {
|
||||||
wt->output[i] = 0;
|
wt->output[len+i] = 0;
|
||||||
} else {
|
} else {
|
||||||
sgn = wt->output[len+i] >= 0 ? 1 : -1;
|
sgn = wt->output[len+i] >= 0 ? 1 : -1;
|
||||||
temp = sgn * (fabs(wt->output[len+i]) - td);
|
temp = sgn * (fabs(wt->output[len+i]) - td);
|
||||||
wt->output[i] = temp;
|
wt->output[len+i] = temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@ extern "C" {
|
|||||||
|
|
||||||
void visushrink(double *signal,int N,char *wname,char *method,char *ext,char *thresh,double *denoised);
|
void visushrink(double *signal,int N,char *wname,char *method,char *ext,char *thresh,double *denoised);
|
||||||
|
|
||||||
|
void sureshrink(double *signal,int N,char *wname,char *method,char *ext,char *thresh,double *denoised);
|
||||||
|
|
||||||
double mad(double *x, int N);
|
double mad(double *x, int N);
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,9 +39,10 @@ int main() {
|
|||||||
inp[i] = temp[i];
|
inp[i] = temp[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
visushrink(inp,N,wname,method,ext,thresh,oup);
|
//visushrink(inp,N,wname,method,ext,thresh,oup);
|
||||||
|
sureshrink(inp,N,wname,method,ext,thresh,oup);
|
||||||
|
|
||||||
ofp = fopen("denoised.txt", "w");
|
ofp = fopen("denoiseds.txt", "w");
|
||||||
|
|
||||||
for(i = 0; i < N;++i) {
|
for(i = 0; i < N;++i) {
|
||||||
fprintf(ofp,"%g \n",oup[i]);
|
fprintf(ofp,"%g \n",oup[i]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user