Create a segmentation picture with each object class rendered in different color ?
Give each object a unique 'pass index'. You can use the compositor, the Object Info node, and some math nodes to convert it to a colour.

This happens when you divide the object index by the maximum index you're using (to get it to a 0-1 value), and apply it to a diffuse material:



By using a Colour Ramp you can take that 0-1 value and map it to discrete colours:



By swapping out the Diffuse shader with an Emission shader, you just get the straight colour values:



This is the final material:



This is the blend file I used:


See the manual for more info.