This trick is also used in other applications, like selecting complex 3D shapes. Sometimes you draw an onscreen image and an offscreen buffer to mark the color zones for checking. That is called “picking.” See for example the Picking Library http://n.clavaud.free.fr/processing/library/picking/