0

enter image description here

I am trying to calculate the distance between 2 points using a picture.

The trapeze above represents a rectangle of 100 meters by 50 meters (the trapeze is due to the angle which I took the picture - actually a drone).

So using this picture I would like to calculate the distance between the left corner (0,0) and the red cross (654,96 - pixel coordinates). My first idea was to create a scale pixel/meters but as you can see the length of the rectangle has a different scale : 100 meters for 900 pixels (top) and 100 meters for 1400 pixels (above).

So it's quiet complicated to calculate the scale and to calculate the distance.

Then when I will succeed it, I will try to calculate many different distances (the red cross will change of position).

Someone has ideas ? Thank you!

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
YLM
  • 335
  • 6
  • 17
  • 1400 px (100 meters) is by NO way equal to 900 px (100 meters). Please reconsider/re-frame your question. You have to fix a certain number of meters for one pixel and only then proceed. In your case, if `1400 px = 100 m`, then in the line above `900 px MUST BE < 100 m`. – Jeru Luke Jan 09 '17 at 20:40
  • Do you have the height at which the picture was taken by the drone? Using that you can actually calculate the distance covered in one pixel and find the approximate distance to an (x,y) coordinate in real world dimensions. – Atif Anwer Jan 10 '17 at 05:43
  • @JeruLuke - Because of the oblique view I have 100m = 1400px and 100m = 900 px. That's whay I am asking this post... – YLM Jan 10 '17 at 09:06
  • @AtifAnwer yes I have the height of the picture. Do you konw how I can calculate the distance on the ground, knowing that 1 pixel is not always equal to the same distance... ? – YLM Jan 10 '17 at 09:07

2 Answers2

2

You need to rectify the image, i.e. to undo a projective transformation. This post of mine on Math SE or this post on Stack Overflow describe how such a transformation can be computed if you know the coordinates of four points and their images. As you do: you have the in-picture coordinates and you have the real world dimensions, so you can pick a real world coordinate system any way you like. Then compute the projective transformation, apply it to the picture coordinates of the red point and obtain its real-world coordinates.

Community
  • 1
  • 1
MvG
  • 57,380
  • 22
  • 148
  • 276
  • Thanks for the answer! Actually I know the coordinates of the four points (using impixelinfo on matlab). What do you mean by knowing the 4 images ? @MvG – YLM Jan 10 '17 at 09:31
  • You have a transformation which maps one point to another. The input is called the preimage, the result is called the image. This has little to do with “image” in the sense of “picture”. – MvG Jan 10 '17 at 09:39
  • Ok so I have the preimage and I will calculate the image using the post you gave me, right ? @MvG - thank you ! – YLM Jan 10 '17 at 10:12
0

In addition to what @MvG posted, if you know the height that the image was taken, then you can calculate the distance that is covered by each pixel (and incorporate the linear perspective in the pixels), and then simply sum them up to find the exact distance to the pixel in real world units using these formulae:

enter image description here

enter image description here

Due to linear perspective, the area of the scene captured in a pixel is proportional to the distance of the object from the camera. So, the pixels closer to the camera will capture a smaller area 'a' as compared to the pixels representing objects further away capturing larger area 'b' , as explained in figure in the paper below.

For more details, you can check the paper here (or here)

Atif Anwer
  • 450
  • 5
  • 13