1 | initial version |
Could it be that your background(x,y) luminance gets a value of zero for a certain pixel in the loop where you accumulate contrast. I do not see you checking for that. Thus, if there is a single pixel with a luminance of zero in the image, you will get the exception.