commit : visushrink updated

This commit is contained in:
Rafat Hussain
2017-09-19 17:08:33 +05:30
parent de4b96e123
commit 310b7759f1
4 changed files with 2133 additions and 18 deletions

1024
test/PieceRegular10.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,19 +4,60 @@
#include <math.h>
#include "../header/denoise.h"
static double rmse(int N,double *x,double *y) {
double rms;
int i;
rms = 0.0;
for(i = 0; i < N;++i) {
rms += (x[i] - y[i]) * (x[i] - y[i]);
}
rms = sqrt(rms/(double)N);
return rms;
}
static double corrcoef(int N,double *x,double *y) {
double cc,xm,ym,tx,ty,num,den1,den2;
int i;
xm = ym = 0.0;
for(i = 0; i < N;++i) {
xm += x[i];
ym += y[i];
}
xm = xm/N;
ym = ym / N;
num = den1 = den2 = 0.0;
for(i = 0; i < N;++i) {
tx = x[i] - xm;
ty = y[i] - ym;
num += (tx*ty);
den1 += (tx*tx);
den2 += (ty*ty);
}
cc = num / sqrt(den1*den2);
return cc;
}
int main() {
// gcc -Wall -I../header -L../Bin denoisetest.c -o denoise -lwauxlib -lwavelib -lm
double *inp,*oup;
double *sig,*inp,*oup;
int i,N,J;
FILE *ifp,*ofp;
double temp[2400];
char *wname = "sym8";
char *method = "swt";
char *wname = "sym6";
char *method = "dwt";
char *ext = "sym";
char *thresh = "soft";
ifp = fopen("noisybumps.txt", "r");
ifp = fopen("pieceregular1024.txt", "r");
i = 0;
if (!ifp) {
printf("Cannot Open File");
@@ -33,24 +74,49 @@ int main() {
N = i;
J = 6;
sig = (double*)malloc(sizeof(double)* N);
inp = (double*)malloc(sizeof(double)* N);
oup = (double*)malloc(sizeof(double)* N);
for(i = 0; i < N;++i) {
inp[i] = temp[i];
sig[i] = temp[i];
}
//visushrink(inp,N,wname,method,ext,thresh,oup);
sureshrink(inp,N,J,wname,method,ext,thresh,oup);
ifp = fopen("PieceRegular10.txt", "r");
i = 0;
if (!ifp) {
printf("Cannot Open File");
exit(100);
}
ofp = fopen("denoiseds.txt", "w");
while (!feof(ifp)) {
fscanf(ifp, "%lf \n", &temp[i]);
i++;
}
fclose(ifp);
for(i = 0; i < N;++i) {
fprintf(ofp,"%g \n",oup[i]);
inp[i] = temp[i];
}
//visushrink(inp,N,J,wname,method,ext,thresh,oup);
sureshrink(inp,N,J,wname,method,ext,thresh,oup);
//ofp = fopen("denoiseds.txt", "w");
for(i = 0; i < N;++i) {
//fprintf(ofp,"%g \n",oup[i]);
}
fclose(ofp);
//fclose(ofp);
printf("RMSE %g\n",rmse(N,sig,inp));
printf("Corr Coeff %g\n",corrcoef(N,sig,inp));
printf("RMSE %g\n",rmse(N,sig,oup));
printf("Corr Coeff %g\n",corrcoef(N,sig,oup));
free(sig);
free(inp);
free(oup);
return 0;

1024
test/pieceregular1024.txt Normal file

File diff suppressed because it is too large Load Diff