From bd26d5745269594647ec79f64fdfb8e750891672 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 8 Jan 2010 15:53:17 +0100 Subject: Zaefferer gradient search --- src/hdf5-file.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/hdf5-file.c') diff --git a/src/hdf5-file.c b/src/hdf5-file.c index 0e9453cf..509147a0 100644 --- a/src/hdf5-file.c +++ b/src/hdf5-file.c @@ -45,6 +45,7 @@ struct hdfile *hdfile_open(const char *filename) f = malloc(sizeof(struct hdfile)); if ( f == NULL ) return NULL; + f->image = NULL; f->fh = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT); if ( f->fh < 0 ) { @@ -149,18 +150,29 @@ int16_t *hdfile_get_image_binned(struct hdfile *f, int binning, int16_t *max) struct image *image; int16_t *data; - image = malloc(sizeof(struct image)); - if ( image == NULL ) return NULL; + if ( f->image == NULL ) { - hdf5_read(f, image); - f->image = image; + image = malloc(sizeof(struct image)); + if ( image == NULL ) return NULL; + image->features = NULL; - data = hdfile_bin(image->data, f->nx, f->ny, binning, max); + hdf5_read(f, image); + f->image = image; + + } + + data = hdfile_bin(f->image->data, f->nx, f->ny, binning, max); return data; } +struct image *hdfile_get_image(struct hdfile *f) +{ + return f->image; +} + + int hdfile_get_unbinned_value(struct hdfile *f, int x, int y, int16_t *val) { if ( (x>=f->image->width) || (y>=f->image->height) ) { -- cgit v1.2.3