You need to get the resolution of the image first. You can do that by using the function below and then getting the value from the corresponding field of the output structure.
info=imfinfo('x.jpg');
res = info.XResolution;
unit = info.ResolutionUnit;
If you can't see the Resolution fields in the output structure, you have to parse the resolution from the headers of your images manually.
Then you should find the size of a single pixel. For example, if your resolution unit is dpi, then the size of a pixel in millimeters is
p = 1/(res/25.4);
Then you just need to find the euclidean distance between two pixels and multiply it with p
distance = norm([x1 y1] - [x2 y2])*p;
I'm assuming that the vertical and horizontal resolutions are equal and the pixels are square.
Regards