There might be a way to divide the image into sub blocks to eliminate the light effect. So high illuminated parts will be quantized alone; this will alleviate the highly illuminated parts and decrease the affect on the other less illuminated parts.
If you are trying to do it in software, then a simple solution is to use thresholding, which is pre-processing. There are other such techniques also. It depends on what your end result is.
Yes, post-CCD yet pre-JPEG, most acquisition devices will adaptively assess the CCD quanta signal before assigning color or greyscale values to pixels. But I doubt you'll have access to the hardware so you'll probably want to apply a post-process algorithm like adaptive histogram equalization on an existing color image in HSV space (or another comparably amenable representation for your algorithm).
For more on this, look to Anil Jain's book "Fundamentals of Image Processing" or just search for "Image quantization" or "color quantization".