OK. I can break it.
testimage.png:
This pipeline operating on testimage.png
generates an image with NAN pixels:
$ gmic -run '-input testimage.png -name. testimage +ac[testimage] \"gcd_tonemap\ 34.375\",lab_l,2 +fill. isnan(i(x,y))?255:0
34.375 seems to be a killer area. Found it with a script that steps the area argument. In looking for sudden changes of brightness, I took pairwise differences of the the average intensities of successive evaluations of the test image. Didn’t quite get sudden changes in brightness. Got NANs instead.
Here’s the testbed script that exercises gcd_tonemap
:
test_gcd_tonemap.gmic
test_gcd_tonemap : -check isint(${1=1024})" && "\
${1}>0" && "\
isnum(${2=0})" && "\
${2}>=0" && "\
isnum(${3=200})" && "\
${3}>=0" && "\
${2}<${3}
foreach {
=>. testimage
size,lo,hi=${1-3}
1,$size,1,2
=>. diffave
note="Delta area\ per\ step:\ "{($hi-$lo)/$size}
e $note
repeat {$size+1} {
area:=($hi-$lo)*($>/($size))
+ac[testimage] "gcd_tonemap "$area,lab_l,2
if $>
=[diffave] {ia#-1-ia#-2},0,{$>-1},0,0
if isnan(i(#$diffave,0,$>-1))
=[diffave] 0.5,0,{$>-1},0,1
else
=[diffave] 0,0,{$>-1},0,1
fi
rm..
e "Area,\ Diff\ "{$>-1}"–"{$>}"\ :"$area", "{i(#$diffave,0,$>-1)}"."
fi
}
k[diffave]
replace_infnan[diffave] 0
display_graph[diffave] 1000,800,1,0,$lo,$hi,-1,1,"Cumulative Area, "$note,"Delta\ ia"
}
gcd_tonemap
, I’m sure you will recognize, is one of the kernels of Auto Balance (the memory pig one). I didn’t torment gcd_tonemap_inplace
because @roydenyates left Reduce RAM unchecked.
Using the script this way:
gmic -m test_gcd_tonemap.gmic testimage.png test_gcd_tonemap. 1024 o. /dev/shm/diff_1024.png
produces a graph of pairwise Δia
between successive output images as Area ranges from [0,…,200].
Where there are green spikes, one of a pair of images has NAN pixels. So pairs of NANs in the data set indicates that only one image is outlier, since that outlier gets used in the taking of two successive differences. Isolated areas in the range [15.5,…,38] seem problematic.
diff_1024.png:
That’s it for now. Can’t play with toys anymore, so I haven’t stepped through gcd_tonemap
to see why it spits out NAN pixels in that area range. Ah me. I have to dress up, make my hair look like it’s been combed, go to dinner, then Carnegie Hall. Or maybe the other way around. Probably I’ll wind up in the wrong place. But at least you’ll have mysteries to mull over, come Sunday morning after breakfast.