From ee88fece29b48aaf368be4fd4207a60e9ea7342a Mon Sep 17 00:00:00 2001 From: Rafat Hussain Date: Wed, 9 Aug 2017 04:50:41 +0530 Subject: [PATCH] commit : sureshrink error correction --- denoise/denoise.c | 6 +++--- header/denoise.h | 2 ++ test/denoisetest.c | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/denoise/denoise.c b/denoise/denoise.c index d4bc27d..d895579 100644 --- a/denoise/denoise.c +++ b/denoise/denoise.c @@ -248,17 +248,17 @@ void sureshrink(double *signal,int N,char *wname,char *method,char *ext,char *th if(!strcmp(thresh,"hard")) { for(i = 0; i < dwt_len;++i) { if (fabs(wt->output[len+i]) < td) { - wt->output[i] = 0; + wt->output[len+i] = 0; } } } else if(!strcmp(thresh,"soft")) { for(i = 0; i < dwt_len;++i) { if (fabs(wt->output[len + i]) < td) { - wt->output[i] = 0; + wt->output[len+i] = 0; } else { sgn = wt->output[len+i] >= 0 ? 1 : -1; temp = sgn * (fabs(wt->output[len+i]) - td); - wt->output[i] = temp; + wt->output[len+i] = temp; } } } diff --git a/header/denoise.h b/header/denoise.h index 34b5e12..31cb80b 100644 --- a/header/denoise.h +++ b/header/denoise.h @@ -13,6 +13,8 @@ extern "C" { 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); diff --git a/test/denoisetest.c b/test/denoisetest.c index 2d12046..b4059b2 100644 --- a/test/denoisetest.c +++ b/test/denoisetest.c @@ -39,9 +39,10 @@ int main() { 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) { fprintf(ofp,"%g \n",oup[i]);