12 Replies Latest reply on Dec 24, 2011 4:31 PM by m_research

    Measurement of circularity and perimeter




      I'm hoping someone will be be able to answer a question I have regarding the measurement toolbox function of adobe photoshop.


      I need to measure the circularity of particular objects in a photograph and though the analysis->measure function works great for width/height/area etc, it seems to give an incorrect answer for the perimeter and hence circularity (which is measured using the perimeter and area calculated).


      My thoughts are maybe the marching ants selection only picks up on some pixels, so a round object will have less number of pixels and hence perimeter? But resizing the object to smaller or larger doesn't seem to help.


      If anyone has any idea why this might be the case and how to rectify this that would be brilliant. I've been googling for days and you are my last resort!

        • 1. Re: Measurement of circularity and perimeter
          c.pfaffenbichler Level 9

          Could you post an example/screenshot to illustrate the issue?

          • 2. Re: Measurement of circularity and perimeter
            Mylenium Most Valuable Participant

            Pixels are rectangular, so there can never be 100% exact measurement of anything curved just based on a selection, not even beginning to think of thresholding issues and scale issues. If you want an exact measure, you'll probably have more luck be re-drawing circles in a vector graphics program on top of your image and using e.g. Illustrator's Info and Debug palettes to get an idea about the area. Similarly, this would be easy in a CAD program...



            • 3. Re: Measurement of circularity and perimeter
              Semaphoric Adobe Community Professional

              Andromeda Software offers a Measurement Plugin. It's no longer being developed, and does not run under OSX. I could run the demo in CS4 under Vista. The demo only works with a supplied image. I wouldn't have enough use for it to justify the price, but I assume the purchased version will work on one's own images.


              There's also Fovea Pro, from Reindeer Graphics. Looks like development of this stopped with CS2. As I recall, it was very expensive, but I see a lot of sites selling it for less - some of them look pretty shady. I think it's Windows only.

              1 person found this helpful
              • 4. Re: Measurement of circularity and perimeter
                Paulo Skylar Level 4

                Not sure if this is useful information for you as I do no know exactly what you are trying to achieve.


                I am guessing you are probably not really interested in circularity as this is something of a strange measure, a dimensionless quantity typically used to estimate the compactness of a shape.  It seems more useful  for non circular shapes despite it name. The real problem is that while the definition of circularity produces a value of 1 for a precise continuous circle it is not the case for discrete circles, which is what you are dealing with in Photoshop.  Even if you created a vector based circle with say 5,000 pixels in diameter and made the measurement you would still not get a circularity of 1.  This is not a Photoshop problem  it results from the application of a continuous measure to a discrete problem. Even within this limitation the details of the selection  are paramount since the perimeter is derived from the selection and the circularity is related to the square of the perimeter.


                Depending on exactly what you are trying to do the better measure via photoshop is area, which can be quite precise with many pixels in the selection. Another less rigorous approach is to realize the circularity  of discrete circles is close to 0.9  (do your own measurements for the range of pixels you will be using) and make comparative circularity measurements for the selections in your images.



                1 person found this helpful
                • 5. Re: Measurement of circularity and perimeter
                  m_research Level 1

                  Huge thankyou to everyone for your replies!! It was a shot in the dark for me to post here, so I am really grateful for all your suggestions!


                  I've attached a screen shot of what i'm trying to do. The image is a photo (taken from an operating microscope) of a human eye during a cataract operation. There is an artificial lens in the eye (which i have selected using magic wand) and a darker shape of a circle within it which is the incision.


                  << medical image of eye and replacement lens removed at request of the squeamish >>


                  I am trying to measure for a research study how circular my incision is with the artificial lens as a reference. The lens should be perfectly circular (based on the manufacturer's product detail) however when i was testing it, the circularity measure (down below in the measurement display box is 0.897753). I know that my selection using the magic wand isn't perfect, however when I draw a perfect constrained proportion perfect circle using adobe, the best it has is also around 0.901.


                  Paulo, thanks for your explanation above. Is this what you mean by discrete circle versus continuous circle??

                  • 6. Re: Measurement of circularity and perimeter
                    PECourtejoie Adobe Community Professional

                    If the plane of the sensor and the plane of the artificial lens are not perfectly parallel, you might not capture a perfect circle...

                    • 7. Re: Measurement of circularity and perimeter
                      Level 7

                      Yes, circularity is calculated from  4pi(area/perimeter2).

                      But the perimeter and area are quantized by the pixel grid.  So you may only reach a calculated circularity of 1.0 at a very high resolution.

                      • 8. Re: Measurement of circularity and perimeter
                        Paulo Skylar Level 4

                        Yes, the pixelated nature of shapes in Photoshop is what I was referring to as being discrete. Below is  shown a small portion of a circle created with the shape tool. In it you can see the vector path of the continuous shape (black line), the pixels making up the fill of the circle (including antialiased pixels to make the circle appear smooth ) and finally the selection obtained by Ctrl clicking on the vector mask. You will note the perimeter, which is derived from the selection , is always going to be larger than the continuous line perimeter and that error is going to be squared in the circularity calculation.



                        Your image  for the kind of analysis you are attempting is low resolution, the areas of interest are less than 200 pixels in diameter. This means your precision is going to be low even with ideal selections. And you will not have ideal selections given the details of your image.  So first you need to specify your required precision.


                        What I would probably try is to enhance you image to make your areas of interest as prominent as possible. Then I would use the pen tool to define the path around your shape of interest and from that I would generate a selection, rotate it if necessary to align the axes vertically & horizontally and then record  a measurement and look at the height and width values. If equal the shape is nominally circular. If not the values will be different (an elliptical shape) and this can be the basis of your measurement. For the image you provided, my quick estimate is that the lens is elliptical having a width of 179 and a height of 185 pixels. So for reasons that you probably know better than the rest of us, the image of the lens on the eye is not circular and is therefore not a good reference.


                        I think the best thing you can do for good results in this kind of work, if possible, is to get more pixels in the regions of interest - higher res camera, higher magnification, .....



                        • 9. Re: Measurement of circularity and perimeter
                          Level 7

                          He could also treat circularity as a relative measure instead of absolute.

                          And verify the circularity of the replacement lens by measuring width vs. height to account for possible perspective distortion of the camera.

                          Though, at some point you'll have to validate the accuracy of the camera lens -- does it have barrel or pincusion distortion that would throw off the measurements?  Can those be corrected adequately?

                          • 10. Re: Measurement of circularity and perimeter
                            Paulo Skylar Level 4

                            Chris Cox wrote:


                            So you may only reach a calculated circularity of 1.0 at a very high resolution.

                            It's been a while since I looked at this stuff, but I believe that regardless of pixel count the circularity of discrete circles will never reach 1.  At any resolution you will get an image similar to the one shown above and the "digital perimeter" will always be greater than the continuous one. That is, at any scale the perimeter evaluation will be in error even though the area evaluation will continue to improve with increased resolution; discrete circularity with therefore always be in error.



                            • 11. Re: Measurement of circularity and perimeter
                              Paulo Skylar Level 4

                              Chris Cox wrote:


                              He could also treat circularity as a relative measure instead of absolute.


                              Indeed! That is what I was suggesting in the last sentence of my original response.



                              • 12. Re: Measurement of circularity and perimeter
                                m_research Level 1

                                Thank again everyone for all your considered thoughts. 


                                The explanation makes complete sense now and I appreciate all the helpful tips along the way. I'm sure this will make it a more robust and meaningful study.