# How to guarantee the point's position is fixed in the Graphics and Image

SeedRandom
plot = ParametricPlot[
Evaluate@BezierFunction[temPoint = RandomReal[{-50, 50}, {5, 2}]][
t], {t, 0, 1}, AxesOrigin -> {0, 0}] We can hightlight a random point in this graphics.

SeedRandom
Show[plot,
Epilog -> {Red, AbsolutePointSize,
Point[randomPoint =
RandomReal /@ RegionBounds@DiscretizeGraphics[plot]]}] We can change the plot to image.

Image[plot]


Then its coordinate system will be a image coordinate system.To guarantee the randomPoint be the original graphics' position in the new coordinate system,I use RescalingTransform try to implement this target.

HighlightImage[
Image[plot], {Red, PointSize[.03],
Point[RescalingTransform[
First@Values[AbsoluteOptions[plot, PlotRange]],
Transpose[{{0, 0}, ImageDimensions@Image[plot]}]]@randomPoint]}] But as you see,there is a error in this method obviously.

• These seem related in concept if not application: (18034), (73522), (83636) – Mr.Wizard Apr 25 '16 at 10:02
• @Mr.Wizard Wow,Thanks for your links.I'll learn that one by one. – yode Apr 25 '16 at 10:08

This isn't elegant, but I think it should work pretty reliably.

plot = ParametricPlot[
Evaluate@BezierFunction[temPoint = RandomReal[{-50, 50}, {5, 2}]][
t], {t, 0, 1}, AxesOrigin -> {0, 0}]


Create a version that has the point, but wrap the point in Annotation, with type "Region":

plot2 = Show[plot,
Epilog -> {Red, AbsolutePointSize,
Annotation[
Point[randomPoint =
RandomReal /@ RegionBounds@DiscretizeGraphics[plot]], "Point",
"Region"]}]


Rasterize the second one, and extract the regions, converting to the center of the point:

{px, py} = Mean[{"Point", "Region"} /. Rasterize[plot2, "Regions"]];


Convert the main plot to an image:

image = Image[plot];


Get the dimensions of the image:

{ix, iy} = ImageDimensions[image];


Highlight the image, keeping in mind that the region annotations use a coordinate system that is flipped vertically from the usual one used by Image:

HighlightImage[
Image[plot], {Red, PointSize[.03], Point[{px, iy - py}]}] • Wow.It's a surprise to me about the Rasterize can do this.Just a little suggestion for Point[{px, iy - py}] should be Point[{px-0.5, iy - py-0.5}] or I miss something. – yode Apr 25 '16 at 6:00