# Overlaying location pointer on to a png file

So I have started off with importing a png image of size $512\times 1024$ px. I have then created two locators as demonstrated on the Wolfram tutorials:

length = DynamicModule[{p1 = {0, 0},
p2 = {1, 1}}, {Dynamic@
Graphics[{Arrow[{p1, p2}], Locator[Dynamic[p1]],
Locator[Dynamic[p2]]}, PlotRange -> 1024],
Dynamic[Grid[{{"Length:", EuclideanDistance[p1, p2]}, {"Slope:",
1/Divide @@ (p2 - p1)}}]]}]


I would like to be able to overlay these locators on to my png image and move them around, in order to measure the distance between two points on the image. I'm sure this should be possible but I really can't see how! Thanks for looking :)

-

Is this what you are looking for?

pic = Image@RandomReal[1, {5, 10}]
x = {1.5, 1.5}; y = {2.5, 3.5};
max = Dimensions@ImageData@pic - .5;

Column[{
LocatorPane[Dynamic@{x, y},
Colorize@Image[pic, ImageSize -> 1000],
{{0.5, 0.5}, max, {1, 1}}],
Dynamic@x,
Dynamic@y,
Dynamic@EuclideanDistance[x, y]
}]


There is always a question about coordinates but if you only need the distance between those points it does not matter.

Edit max added in order to make it more handy.

-
Thank you very much! I have replaced your code '"Colorize@Image[pic, ImageSize -> 1000], {{0.5, 0.5}, {9.5, 4.5}, {1, 1}}]' with the image I need to analyse and it has worked perfectly. Thanks again :) Jade – Jade Jul 29 '13 at 16:20
@Jade {{0.5, 0.5}, {9.5, 4.5}, {1, 1}} those are domain intervals, take a look at LocatorPane in documentation. It is not crucial but without those .5 endings Locators are constraind to the mesh not to the center of pixels. – Kuba Jul 29 '13 at 16:30
Ahh okay that makes sense - explains why I couldn't get the image to be displayed at its normal size even when using 'ImageSize'. All working fine now though - at least for what I'm doing :) Thanks again. – Jade Jul 31 '13 at 12:07