# Getting Mathematica to consider the scale of an image

This question may not be well describe, but I will try to explain as best as possible.

Suppose somebody gives me some image (say of a plot on the complex plane), and also describes the dimensions of it, say the boundary of the picture vertically is from the origin to the point $$2i$$ and horizontally from $$-1$$ to $$1$$.

Now suppose I want to add some graphic elements such as a line or a Bezier curve using Mathematica. Is there some way to tell Mathematica the scale of the image so that the defining points of graphic elements are consistent with the coordinates of image?

(Apologies if this has an obvious solution, I am currently running a large piece of code so I cannot experiment with this, but I think in past experience this is not an obvious thing one is able to do.)

You can use RegionPlot to fit the texture of the image onto a rectangle of the right dimensions, then use Show to combine the rectangle with the Graphics:

(* The image you've been given. I make up a fake one here: *)
img = Image[
ComplexPlot[Gamma[1/z], {z, -1 - 2 I, 1 + 2 I},
PlotRangePadding -> None, Frame -> None]]

Show[
RegionPlot[Rectangle[{-1,-2}, {1,2}], BoundaryStyle->None, PlotStyle->Texture[img]],

Graphics[{White,
BezierCurve[{{0, 3/2}, {3/2, 1}, {1/3, 1/2}, {1/3, -1}}]}]
]


• Thank you for this! Related, is there some way to draw directly say a point or curve on an image and have Mathematica gives the coordinates of this point or (an approximation of) the curve? I would experiment with this but I still have the large program running so I can't...
– math
Commented Aug 13, 2020 at 15:19
• You mean like editing the image in ms paint and then using image processing to figure out the positions ? Maybe - it would depend on the image and how cluttered it is. I cannot say without the image though, and you should ask this in a separate question, though it has likely already been answered. Commented Aug 13, 2020 at 15:33
• Thanks for this, I've asked it as a new question here mathematica.stackexchange.com/questions/228469/…
– math
Commented Aug 13, 2020 at 18:23
• @math will you upvote/accept this answer or did you have difficulty getting it to work? Commented Aug 15, 2020 at 12:44