I wrote the following Matlab implementation of the algorithms we have discussed so far

Figure 1: Choosing a linear combination between two sets of factors
I ran all three scripts on four different test images. The images that you see in-lined with the rest of this page are jpeg-compressed, resized versions of the originals. To download the original tiff files, click on the image labels.
This picture, taken from Bryan Peterson's Understanding Exposure was photographed using the Sony digital camera. Compared to the original picture in the book, the camera's rendition is quite yellowish and somewhat desaturated.
This simulation illustrates the danger of applying the gray world assumption blindly without first checking to see if there is enough color variation in the original image for this assumption to hold. In this case, there is so little blue in the original image that trying to equalize the blue average with the reds and greens results in an image that unacceptably dark. Since digital cameras do not encounter this problem in general, cameras that use the gray world assumption probably survey the color distribution of the raw image to decide if the assumption will hold or not before applying any color-balancing.
The perfect reflector assumption seems to do little for this image because the bright spots along the glossy stalks are almost white.
The hybrid color-balancing scheme suffers from the same problem as the gray world assumption algorithm of trying to boost non-existent blue shades in the original image. However, the mixing with the perfect reflector scale factors makes the effect less severe.
I found this poorly color-balanced image lying around in the class directories and decided to use it as a test image. The original image has a very strong greenish-yellow cast.
Once again, the gray world assumption fares poorly because of the lack of blue in the subject. As a result, it forces the subject to take on an unnatural blue cast. The perfect reflector seems to have little effect on the image because the brightest region, which is the reflection of the fluorescent lighting on the glass, is practically saturated out at white. The hybrid scheme, in my opinion, gives the best results in this case. The yellow cast is gone, and the wall now appears white. However, in removing the yellow from the image, the algorithm has the awful side effect of desaturating the yellow from the subject's shirt as well.
This is another picture we took from Bryan Peterson's Understanding Exposure using the Sony digital camera. The original image used here has a severe magenta cast.
The image corrected using the gray world assumption no longer has the magenta cast. However the algorithm overcorrects at the brighter regions of the image, causing the sky to appear unacceptably greenish. It also suppresses the reds of the tulips to such as large degree that the tulips appear brownish and dull.
Using the perfect reflector assumption, we manage to remove the some of the magenta from the sky; the clouds in the image now look white. Nevertheless the magenta cast still pervades much of the rest of the image.
Again, the hybrid scheme produces the most decent results. The sky is a pretty blue, and the green stalks, overwhelmed by magenta in the original image, now appear distinctly green. The algorithm, unfortunately, performs disappointingly at bringing out the red tones of the tulips. It inherits this defect from the gray world assumption algorithm.