0

I have a digital image, and I want to make some calculation based on distances on it. So I need to get the Milimeter/Pixel proportion. What I'm doing right now, is to mark two points wich I know the real world distance, to calculate the Euclidian distance between them, and than obtain the proportion. The question is, Only with two points can I make the correct Milimeter/Pixel's proportion, or do I need to use 4 points, 2 for the X-Axis and 2 for Y-axis?

Raúl Otaño
  • 4,326
  • 3
  • 24
  • 59

2 Answers2

1

If your image is of a flat surface and the camera direction is perpendicular to that surface, then your scale factor should be the same in both directions.

If your image is of a flat surface, but it is tilted relative to the camera, then marking out a rectangle of known proportions on that surface would allow you to compute a perspective transform. (See for example this question)

If your image is of a 3D scene, then of course there is no way in general to convert pixels to distances.

Community
  • 1
  • 1
Russell Zahniser
  • 15,480
  • 35
  • 29
  • In fact, I suppose the image is on a "flat surface and the camera direction is perpendicular to that surface". So with with 2 points will be enought? – Raúl Otaño Mar 04 '13 at 21:22
  • Then where enter the Pixel Aspect Ratio?, The screen resolution of the current display doesn't affect that proportion? – Raúl Otaño Mar 04 '13 at 21:35
  • Sorry, I think I misunderstood your question. I was assuming you had taken a picture of a real-world object and were trying to compute distances in it. Are you actually just holding a ruler up to the screen to measure a distance, and then using that to compute the real-world size of an object displayed on the screen? In that case, the simplest way to do calibration would be to display a vertical line and a horizontal line and ask the user to measure them with a ruler. – Russell Zahniser Mar 04 '13 at 21:40
  • Maybe the one is confused is me, in fact I had a real world object picture, and I know the real distance for two poitns. In fact, the first implementation what I have done is using just two points. Just I don't know if I need to take in count the Aspect Ratio, I personally think that is not necesary but I need other criterias. – Raúl Otaño Mar 04 '13 at 21:50
  • The pixels in your camera should be nearly square. The aspect ratio of your display would not affect the correspondence between camera pixels and object size. So, again it should be fine to use a single ratio for any direction. – Russell Zahniser Mar 04 '13 at 21:54
1

If you know the distance between the points A and B measured on the picture(say in inch) and you also know the number of pixels between the points, you can easily calculate the pixels/inch ratio by dividing <pixels>/<inches>.

I suggest to take the points on the picture such that the line which intersects them is either horizontal either vertical such that calculations do not have errors taking into account the pixels have a rectangular form.

niculare
  • 3,521
  • 1
  • 22
  • 36