8
$\begingroup$

I know how to import an image into Mathematica using the Import command. The original image can come from anywhere, but call this image "myimage" after importing into Mathematica

Now my problem is how to insert this image at the point with coordinates (2,3) in the XY-plane. I know how to insert certain text at a prescribed place, but with imported images, I am not sure how to do it.

Any help will be greatly appreciated!

$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! Please consider registering your account. It'll open up the way to using many features of this site, such as editing your question at any later time and commenting on answers for clarifications. $\endgroup$ – Szabolcs Jul 3 '12 at 18:31
10
$\begingroup$

In Graphics expressions, you can use Inset in a very similar way to Text:

img = Import["http://i.stack.imgur.com/GDnKs.png"]

Graphics[Inset[img, {2, 3}], Frame -> True]

Mathematica graphics

The third argument of Inset will control which point in it will be positioned at the given coordinates.

For more precise control, you can use Raster:

Graphics[
 Raster[ImageData[img, DataReversed -> True], {{0, 0}, {1, 1}}], 
 Frame -> True]

Raster is just like Rectangle, but it renders an image inside. Don't forget to use DataReversed -> True in ImageData to get the image data in a format compatible with Raster.

$\endgroup$
  • $\begingroup$ Thnak you very much to all of you! I will try and let you know. $\endgroup$ – tim Jul 3 '12 at 18:37
7
$\begingroup$

You need Inset:

im = Image@Graphics[{Circle[{0, 0}, 0.1]}];
Plot[x, {x, 0, 20}, Epilog -> Inset[im, {15, 15}]]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Adjust size of inserted image: Inset[Show[im, ImageSize -> 50], {15, 15}] $\endgroup$ – axsvl77 Jun 10 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.