What type of setup is needed to get good color readings from the Mindstorms EV3 color sensor:
- Shape of object?
- Size of object?
- Distance to object?
- Color of background?
The color sensor works pretty well as long as the object is about 1 1/2- 2 modules from the object.
The sensing is best when the object is flat.
The object is large enough to be fully contained within the "spotlight" that the sensor emits. As long as this is true, it doesn't really matter what the background color is.
Another thing to consider is that the color sensor has different modes (active vs. passive). In "active" mode the sensing is affected much less by the ambient lighting conditions.
Pro tip: if you are using EV3-G or RobotC without Xander's drivers, the color detection works best on LEGO's colors (the color the bricks are in). This is especially noticeable for the "green" color.