You haven't posted the code you already have, nor a source image so we can reproduce your results (and see where you're stuck), so you won't get a full answer to your question. Consider this a long comment.
Your seem to have 4 separate questions:
- How do I find the cells?
- How do I draw something?
- How do I draw something over my microscope image?
- How do I draw the cell indices at the positions where I found the cells?
As far as I understand, you've already solved the first question. I'll assume you have a list of rules like 1 -> {100,200}, 2 -> {110,250}, 3 -> ...
, and have this list assigned to a variable called e.g. cellLocations
.
The answer to question 2 is the built-in function Graphics
: Graphics takes a list of graphics primitives like lines, circles, text objects, colors, fill styles and so on, and renders them. For example:
Graphics[{Red, Line[{{10, 10}, {20, 20}}], Text["Hello World", {20, 20}]}]
draws a red line and a line of text. Read the documentation on graphics carefully if you want to draw anything more complex than a straight line.
The answer to question 3 is the built-in function Show
: You can use it to render a graphics object in front of an image object, like this:
Show[myImage, Graphics[{ ... }]
Finally, the last question: how do you turn a list of cell locations in some format (as returned by ComponentMeasurements
) into a list of graphics primitives? As @David Carraher explained in a comment: Mathematica's Replace
function (or it's short form /.
) is very useful for that. Be sure to read the documentation, too.
Finally, a word of advice: Mathematica is perfectly suited for what you're trying to do, but piecing it together by trial and error, documentation and stackexchange is bound to be frustrating. (At least, it was for me.) Do yourself a favor and get a good introductory book. It'll save you a lot of time, and possibly a few gray hairs, too.