aboutsummaryrefslogtreecommitdiff
path: root/src/peakdetect.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/peakdetect.c')
-rw-r--r--src/peakdetect.c48
1 files changed, 19 insertions, 29 deletions
diff --git a/src/peakdetect.c b/src/peakdetect.c
index 666e23f..37e88c5 100644
--- a/src/peakdetect.c
+++ b/src/peakdetect.c
@@ -22,7 +22,7 @@
void renormalise(gsl_matrix *m) {
double max,min;
gsl_matrix_minmax(m,&min,&max);
- printf("Renormalising min=%lf max=%lf\n",min,max);
+ //printf("Renormalising min=%lf max=%lf\n",min,max);
gsl_matrix_add_constant(m,0.-min);
gsl_matrix_scale(m,1./(max-min));
}
@@ -44,7 +44,7 @@ gsl_matrix* createImageMatrix(ControlContext *ctx, int16_t *image) {
gsl_matrix_set(raw,i,j,(double)image[i+j*ctx->width]);
}
}
- printf("Created %dx%d matrix\n",ctx->width,ctx->height);
+ //printf("Created %dx%d matrix\n",ctx->width,ctx->height);
renormalise(raw);
return raw;
}
@@ -191,7 +191,7 @@ void local_sigma_filter(gsl_matrix *m, int r, double k) {
int i,j;
int interval = (m->size1-r)/20;
//printf("lsf: starting loop\n");
- printf("lsf: ");
+ //printf("lsf: ");
//for (i=r;i<m->size1-r;i++) {
// for (j=r;j<m->size2-r;j++) {
for (i=0;i<m->size1;i++) {
@@ -216,9 +216,9 @@ void local_sigma_filter(gsl_matrix *m, int r, double k) {
gsl_matrix_set(new,i,j,0.);
}
}
- if (i % interval == 0) printf(".");
+ //if (i % interval == 0) printf(".");
}
- printf("done\n");
+ //printf("done\n");
gsl_matrix_memcpy(m,new);
gsl_matrix_free(new);
}
@@ -280,7 +280,7 @@ gsl_matrix* generate_flat_kernel(int half) {
gsl_matrix* matrix_expand(gsl_matrix *m, int oldsize, int newsize) {
gsl_matrix *new;
- printf("me: %d->%d\n",oldsize,newsize);
+ //printf("me: %d->%d\n",oldsize,newsize);
new = gsl_matrix_calloc(2,newsize);
//printf("me: calloc(2,%d)\n",newsize);
@@ -354,7 +354,7 @@ gsl_matrix* floodfill(gsl_matrix *m, double threshold, int *count) {
p = gsl_matrix_calloc(2,size);
double com_x,com_y;
- printf("ff: starting loop\n");
+ //printf("ff: starting loop\n");
for (i=0;i<m->size1;i++) {
for (j=0;j<m->size2;j++) {
if (gsl_matrix_get(m,i,j)>threshold) {
@@ -373,7 +373,7 @@ gsl_matrix* floodfill(gsl_matrix *m, double threshold, int *count) {
}
com_x /= com_n;
com_y /= com_n;
- printf("ff: point CoM (%lf,%lf)\n",com_x,com_y);
+ //printf("ff: point CoM (%lf,%lf)\n",com_x,com_y);
gsl_matrix_set(p,0,n,com_x);
gsl_matrix_set(p,1,n,com_y);
n++;
@@ -385,11 +385,11 @@ gsl_matrix* floodfill(gsl_matrix *m, double threshold, int *count) {
}
}
}
- printf("ff: ending loop, found %d\n",n);
+ //printf("ff: ending loop, found %d\n",n);
*count = n;
- printf("pcheck s1=%d s2=%d\n",p->size1,p->size2);
+ //printf("pcheck s1=%d s2=%d\n",p->size1,p->size2);
p = matrix_expand(p,size,n);
- printf("pcheck s1=%d s2=%d\n",p->size1,p->size2);
+ //printf("pcheck s1=%d s2=%d\n",p->size1,p->size2);
return p;
}
@@ -408,35 +408,25 @@ gsl_matrix* iterate(gsl_matrix *m, int *count) {
gsl_matrix *p;
gsl_matrix *kernel;
- mean = image_mean(m);
- sigma = image_sigma(m,mean);
- printf("Iterate: mean=%lf sigma=%lf\n",mean,sigma);
-
-
- printf("Iterate: generating kernel\n");
+ //printf("Iterate: generating kernel\n");
kernel = generate_flat_kernel(1);
printf("Iterate: performing local_sigma_filter\n");
local_sigma_filter(m,10,1.);
- mean = image_mean(m);
- sigma = image_sigma(m,mean);
- printf("Iterate: mean=%lf sigma=%lf\n",mean,sigma);
-
-
- printf("Iterate: starting loop\n");
+ //printf("Iterate: starting loop\n");
while (1) {
- printf("Iterate: smoothing");
+ //printf("Iterate: smoothing");
apply_kernel(m,kernel);
- printf(" (1)");
+ //printf(" (1)");
apply_kernel(m,kernel);
- printf(" (2)\n");
+ //printf(" (2)\n");
mean = image_mean(m);
sigma = image_sigma(m,mean);
- printf("Iterate: mean=%lf sigma=%lf\n",mean,sigma);
+ //printf("Iterate: mean=%lf sigma=%lf\n",mean,sigma);
k = (0.5-mean)/sigma;
- printf("Iterate: applying sigma_filter(%lf)\n",k);
+ //printf("Iterate: applying sigma_filter(%lf)\n",k);
sigma_filter(m,k);
- printf("Iterate: floodfilling\n");
+ //printf("Iterate: floodfilling\n");
p = floodfill(m,0,&cur);
printf("Iterate: %d points found\n",cur);
if (old < 1.05*cur) break;