Click here to Skip to main content
13,550,805 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hai guys..
I was count white pixels as an area detection, for example 2500 pixels. I was tried using this formula to convert pixels to Cm :

area detection (cm) = 1 / pixels area detection * 2.54

But the result indicate the size of each pixels and it isn't what i need.
What i need is to convert size of area detection in pixels to Cm or Mm.
So, how to convert size of area detection from pixels to Cm or Mm?
Thank you.. :)
Posted 10-Nov-12 4:18am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

To convert from pixels to mm, or cm, or inches, or any other physical measurement, you need to how many pixels there are to the inch in the image as taken. Assuming you have your image in an instance of the Image class, have a look at the HorizontalResolution[^] and VerticalResolution[^] properties.
zaenal arifin 10-Nov-12 10:39am
Hai OriginalGriff, can you explain it with example or something else? where can i find how many pixel in inch?from camera resolution or image from camera capture? sorry for my bad English.. :D
OriginalGriff 10-Nov-12 10:41am
What exactly are you trying to do? Where does you image come from? It may be that we are talking at cross purposes.
zaenal arifin 10-Nov-12 10:51am
i was count white pixels in binary image from camera capture (call it area detection). For example i have 2500 white pixels and i need to convert from 2500 pixels to cm or mm. So, i need formula or some trick to convert it..
OriginalGriff 10-Nov-12 11:15am
There is no trick - you can't measure anything without a frame of reverence.
If you camera is at a fixed position, and a fixed distance from the target, then you can work out how far 100 pixels are in the real world - but only if you know the distance from the camera and the magnification power of the lens (and a few other details). There is no absolute correlation between pixels and physical size - for example, you monitor may show 100 pixels as 25mm, where as mine might show them as 15mm or 50mm, depending on the relative sizes of the monitors, and the resolution we have them set at. Just changing your monitor from 800x600 to 1680x1050 will change the size that 100 pixels appears to be without changing the monitor in any way!

The easiest way to do this is to take a "reference" picture - of a ruler or other known length object and use that to calibrate your camera / software.

If your camera can move in relation to the target, then you need the reference length in every picture to stand a chance of working out the physical dimensions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.180515.1 | Last Updated 10 Nov 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100