I thought of a way to improve the performance on flat images where the
maximum bin is towards the end of the histogram. Bi-search. Images where
the minimum is towards the end of the minum take less than a second to
load. Flat images take one second more (100%) worst.
#include <loader_common.h>
#include <fitsio.h>
#include <loader_common.h>
#include <fitsio.h>
-//TODO: add a color table.
-//invert gray scale, Check if feh or qiv can do this.
+//TODO:
+// - read the image only once and recycle the ptr array if the image is not
+// double
+// - biseearch for the lower limit. Would converge faster in flat images where the max is towards the end of the histogram. this images take a second more.
// add option to check for datamin and datamax on the header
// make it more robust. datamax > datamin
// write the fits writer!
// add option to check for datamin and datamax on the header
// make it more robust. datamax > datamin
// write the fits writer!
(((x) & 0x00ff0000 ) >> 8) |\
(((x) & 0xff000000 ) >> 24))
(((x) & 0x00ff0000 ) >> 8) |\
(((x) & 0xff000000 ) >> 24))
+ /* return the difference in time, in milliseconds */
+double timediff_ms(const struct timeval *start, const struct timeval *stop)
+{
+ return (stop->tv_sec - start->tv_sec)*1000.0 + (stop->tv_usec - start->tv_usec)/1000.0;
+}
+
void getRGB( double, double, double, short, short, DATA8 *, DATA8 *, DATA8 * );
char
void getRGB( double, double, double, short, short, DATA8 *, DATA8 *, DATA8 * );
char
char *envdmin, *envdmax;
short color, inv, stepx, stepy;
char *envdmin, *envdmax;
short color, inv, stepx, stepy;
+ struct timeval start, end;
+ double delta_t;
+
+ gettimeofday(&start, NULL);
+
fprintf(stderr, "%s\n", im->real_file );
/* must set the im->data member before callign progress function */
ptr = im->data = malloc(w * h * sizeof(DATA32));
fprintf(stderr, "%s\n", im->real_file );
/* must set the im->data member before callign progress function */
ptr = im->data = malloc(w * h * sizeof(DATA32));
fprintf(stderr, "\ndata min %g, max %g\n", zscalemin, zscalemax);
//free( buffer );
//free( ptr );
fprintf(stderr, "\ndata min %g, max %g\n", zscalemin, zscalemax);
//free( buffer );
//free( ptr );
+
+ gettimeofday(&end, NULL);
+ delta_t = timediff_ms( &start, &end );
+ fprintf(stderr,"\n --> Used %.2f msec.\n", delta_t);
}
//fclose(f);
fits_close_file(f, &status);
}
//fclose(f);
fits_close_file(f, &status);