Houdini: COP Whitebalance

During the Grass Stuff, I needed to sample colors. Sure, there are color profiles and all that, but what's it gonna help if you have some pictures of different speciments taken under different light conditions?
I initially thought about writing a python COP to do it, which I eventually will, but I was unable to get any examples to work. So this is what I came up with:

The image is converted to 32 bit float first. Then, you crop out what should be white (you need to photograph a white card with your sample), blur the hell out of it and do the math in a pixel COP. Wikipedia: Color Balance