# position image combined with other graphics

Is there a way to directly transform an image?

This works but seems klunky :

Graphics[{Translate[ Raster@ImageData@image, {x,y}], .. other graphics objects .. }]


Just wondering if there is a better way..

Per JM.s comment, you can sort of do this with ImageForwardTransformation I actually looked at those before asking the question and didn't think they would work, but now I went back and figured it out..

here is a simple translation:

{w, h} = ImageDimensions[img]
ImageForwardTransformation[ img , (# + {x, y}) &, Background -> 1,
DataRange -> Full, PlotRange -> {{0, w + x}, {0, h + y}}]


This creates a new larger image, large enough to contain the transformed result but still anchored with a corner at {0,0}, so isn't really equivalent to simply translating the image.

-
Look up ImageTransformation[] and ImageForwardTransformation[]. –  Ｊ. Ｍ. May 30 '13 at 20:27
If I understand correctly, all you need is Inset. –  Jens May 30 '13 at 21:28
Thanks, I was not aware of Inset, useful indeed! –  george2079 May 31 '13 at 19:04

Here is a completely random illustration of how to use Inset to place an image into a Graphics:

img = Image[
Show[
ExampleData[{"Geometry3D", "Cow"}],
ImageSize -> 360, Background -> None],
ImageResolution -> 144
];
ListAnimate@Table[
Graphics[{
Darker[Green],
Disk[{.2, .4}, .6],
Inset[Rotate[img, -t^2], {0, 1} + t {.9, -.8}]
},
Background -> Lighter[Gray],
PlotRange -> {{0, 1}, {0, 1}},
ImageSize -> 360
],
{t, 0, 1, .1}
]


The image img has transparent background, and is superimposed on a green circle in a Graphics object. When positioning the Inset inside Graphics, it is useful to always specify an explicit PlotRange, because it allows you to determine the position more accurately in the logical coordinate system of the other graphics objects. Here, I chose to make the left and bottom edges be at 0, and the top and right correspond to 1. In addition, I also included a Rotate command to show that you can add other transformations of the img inset.

-
Thanks for this illustration of "the cow jumped over the (green) moon". –  bill s Jun 1 '13 at 5:48