Area, pixel to metre conversion

31 views (last 30 days)
Benjamin Dempsey
Benjamin Dempsey on 19 Mar 2016
Answered: Image Analyst on 20 Mar 2016
I have an image which i have opened in matlab, i found the area of that image in pixels. I know each pixels dimensions by having something else in the background.
would i do the square root of the matlab area value then mutiply it by (my real world factor)^2 ?
Thanks i hope ive explained this well enough

Answers (2)

Walter Roberson
Walter Roberson on 20 Mar 2016
Suppose you had 7 square inches and wanted that converted to square centimeters. Then since 1 inch is 2.54 cm then 1 square inch is (2.54 cm)^2 = 2.54^2 cm^2 . So 7 square inches would be 7 * 2.54^2 = 45.1612 square centimeters.
Your proposal would have been for sqrt(7) * 2.54^2 = 6.7202 cm^2 . That is obviously wrong as a cm is smaller than an inch so 7 square inches cannot convert to less than 7 square centimeters.
What you can do is (sqrt(7) * 2.54)^2 which includes squaring the entire value not just the conversion factor. That will work fine (at least for positive areas ;-) ) But look again at the expression and expand it and you see that the sqrt(7) is going to get squared and multiplied by 2.54^2, so that is going to be the same as just taking the original 7 and multiplying it by the square of the conversion factor. You therefore might as well not bother taking the square root, and doing will at best be a waste of time and at worst will introduce numeric error for no benefit.

Image Analyst
Image Analyst on 20 Mar 2016
A few years back I developed an application where to spatially calibrate we would put in a 4 inch by 4 inch filter paper into the scene. I found the paper and got its area in pixels. Then I assumed the pixels were square, which they were according to the camera manufacturer. So I found the calibration factor. Let's say that the 4x4 region was 50,000 pixels. Well 4x4" is 10,322.56 mm^2 so the square mm per pixel was 10,322.56/50000 = 0.2064512. That is the factor to multiply area in pixels by to get the area in square mm. To get distances, you'd multiply the length in pixels by sqrt(.2064512) = 0.454369013027957.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!