This takes me back to my Graduate Computer Science days! Depth ordering objects!
But I have a lot more skills, and techniques up my sleeves since then!
There is a mode that may be of use on a per pixel bases. LightenIntensity.
http://www.imagemagick.org/Usage/compos ... nIntensity
If the input is the depth map of the two images you can use this compose to generate a mask of which object is 'closer' based on those two depth maps. The alpha map can be anything, but specifically it can be the 'object' index, so at the end the alpha channel contains the index of the closer object.
That gives you which object is 'in front' at every pixel location. for the two objects. But object edges tend to be semi-transparent, so you can not just pick a pixel from the appropriate object image.
What you need is instead to pick pixels from two images. One with the object composed over the other, and visa-versa. That way you get the right color 'blending' along the edges. It is from these two images that you would use the mask to 'pixel pick' the right color.
This method even allows you to even have two objects the overlap each other, such as a torus that has a cylinder though the middle. some parts will have the torus in frount, in others the cylinder will be in front.
It will even handle objects that pass through each other, BUT will not provid proper anti-aliasing of the pixels at that join, Not without a lot more work!
If you have an example of two objects (with anti-aliased edges), preferably overlapping just as I suggested. I can try to work out the exact commands needed.
The Gimp example it rather useless and not very clear. Some small, scaled down examples from your openGL environment will be much more useful!