# How can I visualize features found in an image?

I am using Mathematica to explore the face detection feature of Core Image on Mac OS X Lion. To do this I have an Objective-C program which captures images from the iSight camera, runs face detection and logs the coordinates of any detected features, and then saves the image to the clipboard. I then switch to Mathematica and paste the captured image into one variable, and copy-and-paste the logged feature coordinates into another.

I've written a simple Mathematica function that can subsequently produce a "normalized" face image, but it would be helpful to be able to draw graphics on top of an image in order to visualize where features are and how they're oriented. When I naively try this I get the error: "Image is not a graphics primitive or directive."

Is there a simple way to draw (or composite) graphics on top of an image?

Show can combine Image and Graphics:

a = ExampleData[{"AerialImage", "Oakland2"}];
b = Graphics[{Red, Thick, Circle[{400, 400}, 300]}];
Show[a, b]


In this way you can do it in a programmatic way. But you can also do this manually and interactively via right-click menu access to Drawing Tools:

• That torn edge looks suspiciously like Heike's method. :) Apr 13, 2012 at 1:19
• Just what the doctor ordered, thanks! Apr 13, 2012 at 1:24
• @rcollyer nice name haha :) Apr 13, 2012 at 1:43
• @EiyrioüvonKauyf whatever works. :) Apr 13, 2012 at 1:44
• @rcollyer indeed ;-) Apr 13, 2012 at 5:21

You can also achieve the same effects with ImageCompose

a = ExampleData[{"AerialImage", "Oakland2"}];
b = Graphics[{Opacity[0.5], Red, Thick, Circle[{200, 200}, 300],
Circle[{1500, 200}, 200], Circle[{0, 0}, 200]}];

ImageCompose[a, b]


And also with Overlay:

Overlay[{a, b}, Alignment -> {Center}]


Though the co-ordinate system is not consistent between the two.

• Just to note that result produced by Overlay will be neither Graphics or Image. Sometimes people are surprised by that :) Apr 13, 2012 at 2:17
• I'm suitably surprised :) It appears to be ... an Overlay ! Apr 13, 2012 at 2:21