1
$\begingroup$

I need to position a certain part of a photographic image at the origin of a plot in Graphics. I am currently using Inset[image, {0,0}, {xpos,ypos}, size] and varying xpos and ypos until it looks right. This is time consuming considering the number of images I am adding. Is there a way to select the desired point on each image and then obtain its coordinates within that image so that I can determine xpos and ypos exactly. Any advice would be welcome.

$\endgroup$
  • $\begingroup$ Maybe setting Axis->True so that you can determin the position on one glimps. $\endgroup$ – Wjx Sep 13 '16 at 4:44
  • 1
    $\begingroup$ You might want to use Raster. Unlike Inset, it uses standard graphics coordinates and makes it possible to align an image with other graphics elements with perfect precision. $\endgroup$ – Szabolcs Sep 13 '16 at 9:58
1
$\begingroup$

I'm not 100% sure what you're looking for, but it can probably done using LocatorPane and Dynamic, e.g. like this:

img = ExampleData[{"TestImage", "CarAndAPC"}];

pt = {0, 0};
Row[{
  LocatorPane[Dynamic[pt], img], 
  Dynamic[Plot[Sinc[x], {x, -10, 10}, 
          Prolog -> {Inset[img, {0, 0}, pt]}, ImageSize -> 300]], 
  Dynamic[pt]}]

enter image description here

$\endgroup$
  • $\begingroup$ That is what I need, nikie. I will also try Szabolcs' suggestion to use Raster for greater precision with the alignment. This was very helpful. $\endgroup$ – JCF Sep 13 '16 at 19:33

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.