Improved algorithm response to different images by calculating median
value separately for four different regions of the image, rather than
one median for the entire image.