diff options
author | Thomas White <taw@physics.org> | 2010-04-16 17:13:46 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2010-04-16 17:13:46 +0200 |
commit | 78746ef335facbab77765ecda7113b7a18417f91 (patch) | |
tree | 4307738daf6bb303e4f358bf28d4006d20e5a996 | |
parent | 3cab0da059c78b758fb9d248a8f80220975d9d87 (diff) |
Fixes and improvements to saturation correction
-rw-r--r-- | src/hdf5-file.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/hdf5-file.c b/src/hdf5-file.c index 5305dc33..d76f2bd4 100644 --- a/src/hdf5-file.c +++ b/src/hdf5-file.c @@ -225,9 +225,10 @@ static void debodge_saturation(struct hdfile *f, struct image *image) } if ( H5Sget_simple_extent_ndims(sh) != 2 ) { + ERROR("Saturation table has the wrong dimensionality (%i).\n", + H5Sget_simple_extent_ndims(sh)); H5Sclose(sh); H5Dclose(dh); - ERROR("Saturation table has the wrong number of dimensions.\n"); return; } @@ -241,6 +242,12 @@ static void debodge_saturation(struct hdfile *f, struct image *image) } buf = malloc(sizeof(float)*size[0]*size[1]); + if ( buf == NULL ) { + H5Sclose(sh); + H5Dclose(dh); + ERROR("Couldn't reserve memory for saturation table.\n"); + return; + } r = H5Dread(dh, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); if ( r < 0 ) { ERROR("Couldn't read saturation table.\n"); @@ -268,6 +275,7 @@ static void debodge_saturation(struct hdfile *f, struct image *image) if ( (v1 != 32767) || (v2 != 32767) || (v3 != 32767) || (v4 != 32767) || (v5 != 32767) ) { STATUS("Cross not found for saturation %i,%i\n", x, y); + STATUS("%i %i %i %i %i -> %f\n", v1, v2, v3, v4, v5, val); } else { float v = val / 5; image->data[x+image->width*y] = v; @@ -279,7 +287,8 @@ static void debodge_saturation(struct hdfile *f, struct image *image) } } - STATUS("Corrected %i saturation values, %i failed.\n", n, size[0]-n); + STATUS("Corrected %i saturation values, %i failed.\n", + n, (int)size[0]-n); free(buf); H5Sclose(sh); |