I get the basic idea of using ImageCompose[], but I seem to be missing something, making me wonder if there's a better way.
The first thing that's a little confusing is that if I make a graphics object, apparently neither the size nor position I give to Graphics has any effect on where the Graphics object ends up in the image when I use ImageCompose:
img = Import["ExampleData/lena.tif"]
ImageDimensions@img
a = Graphics[{Green, Disk[{5, 5}, .1]}];
ImageCompose[img, a]
though I guess that kind of makes sense because it's relative. So I know I can used scaled, like so:
img = Import["ExampleData/lena.tif"]
imgdim = ImageDimensions@img
a = Graphics[{Green, Disk[{5, 5}, .1]}, ImageSize -> First@imgdim/10];
b = Graphics[{Green, Disk[{5, 5}, .1]}, ImageSize -> First@imgdim/10];
ImageCompose[img, {a, b}, {Scaled[{0, 0}], Scaled[{1, 1}]}]
But I get a little confused when I want to put a line on the image. I can't figure out a way of doing it that doesn't involve creating the line and then awkwardly scaling it, something like:
img = Import["ExampleData/lena.tif"];
imgdim = ImageDimensions@img
a = Graphics[{Green, Disk[{5, 5}, .1]}, ImageSize -> First@imgdim/8];
b = Graphics[{Green, Disk[{5, 5}, .1]}, ImageSize -> First@imgdim/8];
c = Graphics[{Red, [email protected], Line[{{0, 0}, imgdim}]},
ImageSize -> First@imgdim];
ImageCompose[img, {a, b, c}, {Scaled[{0, 0}], Scaled[{1, 1}],
Scaled[{0, 0}]}]
(to be honest, I don't even fully get what's going on here, since it seems like I made the Line c the same size as the Lena image, but it only goes halfway across...)
Anyway, is there a less awkward way of doing this? I thought maybe Epilog would be the way but I can't see where I'd put it... I'd like to just be able to use the same coordinates as the image and directly plot Graphics[] objects onto the image. How can I do this?