blob: be5c3a1c2309464850e25a0c024c84ad91a57a8e (
plain)
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
|
Author: Ole Streicher <olebole@debian.org>
Description: Avoid NaN in asinh calculation.
Also, ignore NaN in histogram creation.
--- a/histogram.c
+++ b/histogram.c
@@ -83,8 +83,10 @@
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;
}
}
--- a/image_scale.c
+++ b/image_scale.c
@@ -326,8 +326,11 @@
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;
|