From 3bc8a4f7cb300baae082ae5400ff1e8ac133c410 Mon Sep 17 00:00:00 2001 From: Ricardo Zanmar Date: Mon, 27 Jun 2011 14:49:26 +0200 Subject: [PATCH] Fixed a bug in datamin calculation. I expected k == 0 when the mostfreq value ends abruptly (single peak). Instead it got to k = -1 at the end of the loop. This was only visible in some images with strange histograms. --- loader_fits.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/loader_fits.c b/loader_fits.c index ec0a5fa..d090c56 100644 --- a/loader_fits.c +++ b/loader_fits.c @@ -131,7 +131,7 @@ load(ImlibImage * im, ImlibProgressFunction progress, fpixel = 1; nsub = 0; subim = malloc( (w / stepx + 1)*(h / stepy +1)*sizeof( double ) ); - fprintf(stderr, "image: %d %d %d \n", w / stepx * h / stepy, w/stepx+1,h/stepy+1); + fprintf(stderr, "image: %d %d %d \n", (w / stepx + 1) * (h / stepy + 1), w/stepx+1,h/stepy+1); for (y = 0; y < h; y += stepy ) { fits_read_img( f, TDOUBLE, fpixel, nbuffer, &nullval, @@ -147,7 +147,7 @@ load(ImlibImage * im, ImlibProgressFunction progress, fpixel += nbuffer * stepy; } fprintf(stderr, "data min %g, max %g\n", datamin, datamax); - fprintf(stderr, "subimage has %d pixels out of %d... %d %d\n", nsub, w*h, y, x); + fprintf(stderr, "subimage has %d pixels out of %d... %d %d\n", nsub, w*h, x/stepx, y/stepy); nbin = 4 * sqrt( datamax - datamin ); if( nbin > 5000 ) nbin = 1000; @@ -205,11 +205,14 @@ load(ImlibImage * im, ImlibProgressFunction progress, break; } } - if( k == 0 ){ //case were we have one single peak surrounded by 0 + fprintf(stderr, "\n after fwfm log datamin, kmin: %g %d %d ", datamin,kmin, k ); + if( k <= 0 ){ //case were we have one single peak surrounded by 0 kmin = mostfreq; datamin = ( (kmin) + 0.5 ) * binw; } + fprintf(stderr, "\n after fwfm log datamin, kmin: %g %d ", datamin,kmin ); + //Set new DATAMAX when we have 99.5% of the pixels accounted for //ndataok = h * w; ndataok = nsub; -- 2.32.0.93.g670b81a890