Line 79:
n=((0.23881) * R+(0.25499) * G+(-0.58291) * B) / ((0.11109) * R+(-0.85406) * G+(0.52289) * B)
'((0.11109) * R+(-0.85406) * G+(0.52289) * B)' will sometimes evaluate to zero. An exeption has to be made. The math is very abstract, but I suspect it happens when an attempt is made to calculate the temperature of a pure black pixel.
From: http://dsp.stackexchange.com/questions/8949/how-do-i-calculate-the-color-temperature-of-the-light-source-illuminating-an-ima