How do I replace RED with 1, BLUE with 2, and GREEN with 3 automatically?

http://img96.imageshack.us/img96/993...4234234led.jpg