15 Replies Latest reply on Jan 11, 2013 2:04 AM by c.pfaffenbichler

measuring length and width of objects

I want to use photoshop cs6 extended to measure maximum length and width of objects (like in the picture below).

Does anyone know how to do that? Is it also possible to do it automatically?

Thanks!

• 1. Re: measuring length and width of objects

Do you mean the horizontal and vertical dimensions with »width« and »length« or the maximum distance of two points on the edge and the perpendicular width?

Edit: To make sure could you mark the intended measurements in the screenshot?

You may also want to ask over at

• 2. Re: measuring length and width of objects

I mean the maximum distance between two points (length) with the perpendicular maximum width. In the picture I indicated it with
the red lines.

• 3. Re: measuring length and width of objects

I mean the maximum distance between two points

With the lower left element what you marked is not the maximum distance between two points, but simply the vertical height.

• 4. Re: measuring length and width of objects

The in my opinion best approach for this in Photoshop (that I can think of) involves converting a Selection based on the luminance to a WorkPath, calculating additional points and then evaluating the points.

When »length« is supposed to really mean longest distance of two points the issue gets more complicated, naturally.

• 5. Re: measuring length and width of objects

Sorry, my mistake, I was too hasty.

I, indeed, mean the green line you have drawn, with a perpendicular width

• 6. Re: measuring length and width of objects

Pity, otherwise the Measurement Log would have provided an easy solution.

My trigonometry skills are weak, so I’m not certain yet how to best calculate the perpendicular width, but I think you should post over in the Scripting Forum.

I assume the whole task is connected to some scientific endeavour?

• 7. Re: measuring length and width of objects

Then I will give it another try in the Scripting Forum.

Yes, I was planning to use photoshop for my master thesis. Thanks for helping so far!

• 8. Re: measuring length and width of objects

May I ask if the imagery is of minerals or organic cultures or human-made debris?

• 9. Re: measuring length and width of objects

11ilse11 wrote:

I want to use photoshop cs6 extended to measure maximum length and width of objects (like in the picture below).

Does anyone know how to do that? Is it also possible to do it automatically?

Would a measurement using the Ruler tool accomplish this? Trace over your green line with the ruler then read distance traversed between endpoints of the line in the ruler tool options bar.

You then could determine perpendicular width by rotating the image such that the green line is vertical.*  Then measure width with a horizontal line.

* You can drag out a measure line on an image feature that should be horizontal or vertical, and then choose Image >

Image Rotation > Arbitrary. The correct angle of rotation required to straighten the image is automatically entered into the

Rotate Canvas dialog box.

• 10. Re: measuring length and width of objects

I assumed the original poster wanted to automate this because the number of elements/images might make manual measuring impractical.

• 11. Re: measuring length and width of objects

Well, getting the lengths (in pixels) seems to work with some tolerance, but I could not get it to run especially fast – something like 3 seconds with your image.

The first number in each paragraph is the length, the second the angle and the rest are the coordinates of the two points that make up the line of greatest distance.

Determining the width seems a bit more difficult for me, though.

• 12. Re: measuring length and width of objects

I think I pretty much figured it out, a certain margin of error (+/- 2%) may be unavoidable, though.

One can even avoid the creation of additional points by forcing the Path to conform to the pixels’ corners.

Are the black shapes always solid or can they have white inclusions/holes (which might be a problem)?

Could you provide a couple of sample images?

• 13. Re: measuring length and width of objects

For a general approach one may search:

Axis aligned bounding box (AABB)

Oriented bounding box (OBB)

Convex hull

For serious investigations by author:

Dave Eberly

For programs:

MATLAB

This task is in my opinion far beyond the capabilities of Photoshop.

Best regards --Gernot Hoffmann

• 14. Re: measuring length and width of objects

This task is in my opinion far beyond the capabilities of Photoshop.

A Scripting approach with evaluating the PathPoints of a WorkPath based on a Selection provides the results in upper screenshot for the sample image, which as far as I can tell by manual measuring are accurate (within a tolerance of 1px or thereabouts). The operation runs about 3 seconds on my computer, so depending on the quantity of images and number of »objects« in the images it may not be sufficiently efficient but it still seems doable.

I have no experience with MATLAB, so it certainly may provide for better results and/or performance.

Edit: I guess attempting the task in Photoshop may be a »every problem looks like a nail to a man with a hammer« situation …

• 15. Re: measuring length and width of objects

Single pixels that only connect to other area/s at their corner/s would result in shapes of their own currently – that might be a problem, but without more sample images it seems difficult to judge if this is a likely scenario.

Anyway, to allow for visual checking of the results the Script now creates a Path that indicates the longest side and the longest perpendicular distance to the edge on either side of that and to me the results seem plausible.