How to convert pixels to cm?
显示 更早的评论
How to convert pixels into cm for the area and major axis length?
results =
Area: 16414
MajorAxisLength: 213.8713
采纳的回答
更多回答(2 个)
Walter Roberson
2013-10-26
0 个投票
You can't tell if that is the only information you have.
8 个评论
MOUNA RAHAL
2021-4-8
Hi Walter, as i understand from what you said, i can take an image with known length for calibration and it is not at the same distance as the desired object. and i have another question, is it necessary to take both of them with the same resolution, the same zooming and the same lens aperture or not? thank you
Image Analyst
2021-4-8
@MOUNA RAHAL, if you have a second image with known length (width of the field of view) then you can use it for calibrating that particular image for objects in that particular image that are at a distance for the object you know the length of. But you cannot (unless you're using a telecentric lens, which is fairly rare) use that calibration for objects at a different distance. So, for example, if you and I were holding a tape measure that spanned the field of view, things at that distance (of the tape measure) can be measured accurately. If however there was the moon in the sky over my shoulder above the tape, you cannot say that the true diameter of the moon is one inch. because the moon is not where the tape measure is.
When you say "both of them", exactly what does the "both" refer to? Two different images? Unless the images were taken with the same camera (lens, zoom, number of pixels, etc.) and at the same distance you will have to calibrate each image separately. If the imaging conditions are identical (like you're shooting objects from your little lightbox with your camera on a tripod for sale on EBay), then you can use one calibration for all the images.
MOUNA RAHAL
2021-4-8
thank you.So first of all, i mean by 'both' the image of the ruler used for calibration with known length and the real object that i would like to know its length (N.B: it is not at the same position as the ruler).
So as i understand from you, if i put a ruler with a known length at a position x and i want to use its image for calibration to know the unknown length of a real object installed at position x+ y (for example y= 4 cm or 2 or 3 cm), i can't use this ruler 's image of calibration? if yes, it comes my second question where i said 'both' about the specifications of the camera if they should be the same for the two images at position x and position x+y. thank you
Image Analyst
2021-4-8
If you take a photo of a ruler at a distance from the lens of 1 meter, then you find the spatial calibration factor in terms of cm per pixel, then that is valid for any object at a distance of 1 meter, regardless where in the x-y plane it is, because it's at the same z distance of 1 meter. If you have another object with a z distance of 50 meters from the camera, then you cannot apply the same spatial calibration factor to that distant object at 50 meters away. You'd need a calibration that is valid for objects at that 50 meter distance.
MOUNA RAHAL
2021-4-8
thank you it is clear for me now.
MOUNA RAHAL
2021-4-8
sorry Walter but i 'm really confused in this part of your previous comment "Or something in the image that is of known length, and the distance to both that reference object and the target object are known". what do you men by that becaust it seems that the reference object and the target object don,t have the same distance. i'm asking so much because i have a project based on that. thank you
Image Analyst
2021-4-8
I said that, not Walter, and I gave you an example already, with the moon. Let me paraphrase it and maybe you'll understand it better.
Let's say you had your camera in your front yard on a tripod, and in the field of view you could see a ruler standing on its edge on a table. And let's say just above that you could see the moon in the sky just above the ruler. Now we know the ruler is 12 inches and let's say you measure it some how, like with imdistline() or improfile(), and found out the ruler is 1200 pixels. The spatial calibration factor is therefore (12 inches) / (1200 pixels) = 0.01 inches / pixel. So now we know that for things at that distance of the ruler, they can be measured accurately. If I measure, say, a water bottle that is also standing on the table and find that it is 400 pixels wide, then the real world width of the water bottle would be 400 * 0.01 = 4 inches.
Now let's consider the moon, which is not on the table at a distance of 10 feet, but is actually 239,000 miles away. Let's now measure the moon in the photo, and let's say it's 100 pixels. So now, can we say that the real world diameter of the moon is only 100 * 0.01 = 1 inch? Of course not. We know that the moon is actually 2159 miles in diameter! Why is it not one inch???? The answer is because it is not in the same plane as the ruler where we made our spatial calibration so the magnification is different.
Does that explain it better?
MOUNA RAHAL
2021-4-9
Sorry i thought that it 's Walter.That is clear for me.thank you. So i need another calibration in that position.
Epah
2013-10-26
0 个投票
1 个评论
Walter Roberson
2013-10-26
Lens aperture and distance to the object. Or, something in the image at the same distance as the object and which is of known length. Or something in the image that is of known length, and the distance to both that reference object and the target object are known.
That is, you can use optical properties to determine the true size of the target object, or you can use trigonometry.
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB Support Package for USB Webcams 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!