mirror of
https://github.com/simon987/wavelib.git
synced 2025-04-20 18:46:45 +00:00
56 lines
968 B
C
56 lines
968 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
#include "../header/denoise.h"
|
|
|
|
int main() {
|
|
// gcc -Wall -I../header -L../Bin denoisetest.c -o denoise -ldenoiselib -lwavelib -lm
|
|
double *inp,*oup;
|
|
int i,N;
|
|
FILE *ifp,*ofp;
|
|
double temp[2400];
|
|
|
|
char *wname = "sym8";
|
|
char *method = "dwt";
|
|
char *ext = "sym";
|
|
char *thresh = "soft";
|
|
|
|
ifp = fopen("noisyheavisine.txt", "r");
|
|
i = 0;
|
|
if (!ifp) {
|
|
printf("Cannot Open File");
|
|
exit(100);
|
|
}
|
|
|
|
while (!feof(ifp)) {
|
|
fscanf(ifp, "%lf \n", &temp[i]);
|
|
i++;
|
|
}
|
|
|
|
fclose(ifp);
|
|
|
|
N = i;
|
|
|
|
inp = (double*)malloc(sizeof(double)* N);
|
|
oup = (double*)malloc(sizeof(double)* N);
|
|
|
|
for(i = 0; i < N;++i) {
|
|
inp[i] = temp[i];
|
|
}
|
|
|
|
visushrink(inp,N,wname,method,ext,thresh,oup);
|
|
|
|
ofp = fopen("denoised.txt", "w");
|
|
|
|
for(i = 0; i < N;++i) {
|
|
fprintf(ofp,"%g \n",oup[i]);
|
|
}
|
|
|
|
fclose(ofp);
|
|
|
|
free(inp);
|
|
free(oup);
|
|
return 0;
|
|
}
|