Area Calculation in binary image

3 Ansichten (letzte 30 Tage)
Sehrish
Sehrish am 26 Jul. 2012
I have to calculate the area of an object in binary image. i have used "nnz" for this but it gives result in number of pixels, hw can i convert it to area unit? I want the result in mm, during searching I have found that resolution or dpi can be used for this. But am confused about coding
o=nnz(bw3)
dpi = get(0, 'ScreenPixelsPerInch');
inches = o ./ dpi;
mm = inches * 2.54;
Is that correct?

Antworten (1)

Image Analyst
Image Analyst am 26 Jul. 2012
Bearbeitet: Image Analyst am 26 Jul. 2012
What are your units? Square centimeters? Square kilometers? A pixel image does not know. You have to specify the spatial calibration. Do you know the size of your field of view, or of any object in your image, in real world units?
Regarding your update. No that's not correct. That will get you distance on the screen in cm, not mm (because there is 25.4 mm in an inch, not 2.54), and certainly not area in mm^2. You'd have to multiply by 25.4^2. Plus, o is a horrible letter to pick for a variable name - it looks too much like zero.
Do you want the real world area of your actual object that you took a picture of, or do you want the area that it takes up on your screen monitor?
  2 Kommentare
Sehrish
Sehrish am 27 Jul. 2012
how can i get the area in real world unit?
gargoyle
gargoyle am 2 Aug. 2012
Assuming that you want to measure an object which you took a picture of:
While acquiring your image you will need something of a known distance to set your scale with. Using this as a ruler you can determine (manually) the number of pixels per unit distance. once you know that, and assuming that all your images are taken at under the same conditions, you can apply the pixels to distance conversion. If all your images are not taken under the same conditions you will need that ruler for every image.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by