Calculate the Area of a Selection.

P
Posted By
pjmacjr
Sep 7, 2003
Views
22439
Replies
12
Status
Closed
I have a number of photos in which I need to calculate the area (in millimeters) of a selection. I was told that you can get the area of a selection by dividing the number of pixels by the resolution squared. Is this true? Does anyone know of another way to calculate the area?

For my research I am looking at a number of tooth photos and need to measure their surface area. In each photo I included a centimeter scale. So in photoshop I am able to calibrate the measuring tool to reflect the size of this scale and thus the actual size of the object. I know the calibration works because I am able to get the same linear measurement in photoshop as I did on the tooth itself.

I am then able to use the lasso tool to encircle the area I need to measure. Once this is done I can look at the image histogram and get the total number of pixels. The resolution is given in the image size box, and this number can be viewed as pixels/inch or pixes/cm. By using these numbers I should be able to calculate the area by dividing the number of pixels by pixels/inch or pixels/cm squared. Because I calibrated the image to a centimeter scale I think I should use the pixels/cm to calculate the area. However, the number I get for using this figure is not correct and actually using the pixels/inch is closer to the expected range for area size.

Any input on why this may be the case? It doesn’t seem logical. Or another way to calculate area of a selection?

Must-have mockup pack for every graphic designer 🔥🔥🔥

Easy-to-use drag-n-drop Photoshop scene creator with more than 2800 items.

B
Bernie
Sep 7, 2003
James,

I was told that you can get the area of a selection by dividing the number of pixels by the resolution squared. Is this true?

That would apply to the area of the printed image (if you printed it), and not to the area of the physical object that was photographed.

You need to establish a relationship between pixels and physical object dimensions, which your photographed centimeter scale should give you.

— Burton —
P
Phosphor
Sep 7, 2003
A = N/r^2

A = Area of selection in square cm

N = Total number of pixels within selection as read from histogram

r = resolution in pixels per cm

r^2 = resolution squared

If you prefer the area in square inches, enter resolution in pixels per inch rather than pixels per cm.

You are hung up on the fact that resolution is expressed in pixels per LINEAR cm (or inch), whereas you need pixels per square cm (inch). You derive pixels per square cm (inch) by squaring the linear resolution.

Believe me, you are not alone in this. I have seen an entire roomfull of intermediate-level adult computer students stumble on the same issue, simple and basic as it may seem.

George
PH
Photo Help
Sep 7, 2003
Burton why do you say only if it is printed? There is no need to print the image to find the area.

"You need to establish a relationship between pixels and physical object dimensions, which your photographed centimeter scale should give you."

It sounds like he did that by calibrating to the rulers on screen. You can’t get much more accurate than that.

James,

If the image resolution is calibrated to the rulers in photoshop then yes your method will work fine. As for accuracy that will depend on resolution. If your images are at a low resolution and your selection is between pixels it will round up or down a pixel. You could always resample your image before making the selection to create more pixels and that should give you a more accurate reading.

What resolution are you averaging with your calibrated images?
B
Bernie
Sep 8, 2003
Photo Help,

Burton why do you say only if it is printed? There is no need to print the image to find the area.

True, there is no need to actually make the print, but the area referred to in the statement,

I was told that you can get the area of a selection by dividing the number of pixels by the resolution squared. Is this true?

is in no way related to the physical object area that James is attempting to measure. It is, as I said in my previous message, the area of the printed object, whether you print it or not. The A in George’s message is also just this area on the print, whether it is printed or not. It has nothing to do with the physical area of the tooth outlined in the Photoshop selection.

To get the physical tooth area, James needs to measure the number of pixels in a centimeter on the centimeter scale included in the photos. This will vary from photo to photo unless there was very precise positioning of the camera in each photograph. It is highly unlikely that the distance from the lens to the tooth was exactly the same from one photo to the next. For a given photo, lets call this measured number of pixels per physical centimeter S. Note that S has nothing to do with the Photoshop image resolution, r. S is a measured scale factor and subject to an inherent measurement error due to rounding the actual physical distance of the centimeter rule image to an integer number of pixels. This measurement error can be reduced by increasing the number of pixels in the total image by upsampling. If more pixels are involved, a roundup error of half a pixel amounts to a smaller physical length error.

Photoshop, in all of its versatility, gives James several ways to make the measurement of S pixels per physical centimeter.

Following George’s lead, to use algebra, the tooth area, T, is given by the expression:

T = N/S²

N still represents the measured number of pixels in the selection. Notice that the image resolution, r, is not relevant to the physical tooth area.

— Burton —
PH
Photo Help
Sep 8, 2003
Burton,

It was my understanding that each picture was taken with the scale. Each photo can then be calibrated according to that scale by simply changing the resolution of the image under Image -> Image Size without resampling. To get more accurate results he can upsample the images first so there are more pixels per centimeter.

I don’t know how you can say the image resolution is irrelevant since it is the basis of the calibration to the rulers in photoshop. Without using the image resolution you have no way of calculating how many pixels per centimeter you have. Or do you plan on counting them each manually 🙂

You all have a remarkable ability to make a very simple task seem very complex. It looks to me like james was doing everything correctly except the initial image resolution may have been too low meaning that after calibration he may not have very many pixels per centimeter.

My guess is that he started out with a low resolution that may have become even lower after calibration. For instance if the images were only 72 PPI that converts to only 28.346 PPC meaning James would have an accuracy of only 1/28 cm which isn’t very accurate.
P
Phosphor
Sep 8, 2003
Since James has included a cm rule in the photo, he can measure the photo’s scale (inches per inch) and square it. The square of the linear scale is all he needs to convert the selected area of the image to the real area. QED
GH
Gernot Hoffmann
Sep 8, 2003
George,

I would make a square selection with unit edge length.
1cm, 1 inch, whatever is available, but inch is more accurate for teeth ) and count the pixels.
This delivers Po=pixels per area of unit square.
Everything else as above:

P=measured pixel number in tooth selection.

Area A = P/Po in square-units

Best regards –Gernot
P
Phosphor
Sep 8, 2003
Gernot,

That’s better yet!

George
PH
Photo Help
Sep 8, 2003
Gernot,

To find the number of pixels between two points (Marks on the scale) in the photograph you would use the measure tool. Using a selection is not as accurate. The number of pixels is obviously what you would set the resolution to (per decided unit of measure).

Unless I misunderstood your intentions.
W
wes
Sep 8, 2003
You can find the true number of pixels in the selection of the tooth by using the Image>Histogram after the selection has been made. Where would this number enter into the equation that has been suggested? This whole thread has piqued my curiosity.

"Photo Help" wrote in message
Gernot,

To find the number of pixels between two points (Marks on the scale) in
the photograph you would use the measure tool. Using a selection is not as accurate. The number of pixels is obviously what you would set the resolution to (per decided unit of measure).
Unless I misunderstood your intentions.
GH
Gernot Hoffmann
Sep 8, 2003
Photo Help,

yes and no. I think the selection of the unit square should be measured as you say and eventually corrected.
The suggested method doesn´t need the knowledge of the
resolution (but this wasn´t my idea).

I SEE an image – a big mouth with a 1 inch square calibration target. This should be accurate enough !

Best regards –Gernot Hoffmann
P
pierre
Feb 24, 2015
hi all

if i use the magic wand tool and get a selection and write down the # pixels i get in the histogram how can i get the area of the selection in cm or in mm ?

How to Improve Photoshop Performance

Learn how to optimize Photoshop for maximum speed, troubleshoot common issues, and keep your projects organized so that you can work faster than ever before!

Related Discussion Topics

Nice and short text about related topics in discussion sections