There is an alternative color space called YIQ that deals with perceived luminescence. I wrote a small function that can tell you given an arbitrary background color, whether white or black text would be most readable. You can checkt it out here: http://blog.nitriq.com/BlackVsWhiteText.aspx
http://en.wikipedia.org/wiki/YIQ