1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
From: Ole Streicher <[email protected]>
Date: Thu, 14 Mar 2024 17:35:32 0100
Subject: Avoid NaN in asinh calculation.
Also, ignore NaN in histogram creation.
---
histogram.c | 4 -
image_scale.c | 7 --
2 files changed, 8 insertions( ), 3 deletions(-)
diff --git a/histogram.c b/histogram.c
index e8f01db..a3b6cc3 100644
--- a/histogram.c
b/histogram.c
@@ -83,8 83,10 @@ compute_histogram (float *arrayp, int length, float dmin, float dmax, long nrows
ind = 0;
else if (value > dmax)
ind = length-1;
- else
else if (isfinite(value))
ind = ceil ((value-dmin) / binsize);
else
continue;
hist[ind] = 1.0;
}
}
diff --git a/image_scale.c b/image_scale.c
index 5eb737e..15a0bbf 100644
--- a/image_scale.c
b/image_scale.c
@@ -326,8 326,11 @@ asinh_image (FitsCutImage *Image)
if (t > maxval)
maxval = t;
}
-
- weight = asinh (sum * nonlinearity) / (nonlinearity * sum);
if (sum * nonlinearity == 0.0) {
weight = 1.0;
} else {
weight = asinh (sum * nonlinearity) / (nonlinearity * sum);
}
for (k = 0; k < Image->channels; k ) {
if (Image->data[k] == NULL)
continue;
|