egg shape modelling

Measure egg volume and surface area

Our research into egg camouflage resulted in hundreds of egg photographs that needed cutting out from their backgrounds. I searched for a simple tool or equation that would let us do this easily, but the equations didn’t fit our eggs very well, or were difficult to solve from a few points. So I came up with a new mathematical formula that describes the shape of an egg, and can be fitted to a few anchor points. The tool fitted egg shapes so well that I developed the script to work out the surface area and volume of the eggs with a greater precision than the traditional length and breadth method. This tool is described and tested in my publication (download PDF).

Installation

  • Make sure you’ve got ImageJ (a great open source image editor).
  • Download the zip file here
  • Unzip and copy the “Egg Tools” folder into your imagej plugins folder (e.g. C:/Program Files/ImageJ/plugins for windows).
  • Restart ImageJ and the tool will be loaded.
Egg shape modelling tool - the egg's curvature can be calculated from a few points around the edge of the egg and then the egg's surface area and volume can be calculated.
Egg shape modelling tool – the egg’s curvature can be calculated from a few points around the edge of the egg and then the egg’s surface area and volume can be calculated.

Instructions

  • Photograph your egg(s) side-on with a scale-bar in the photo at the same height as the centre of the egg. Make sure there is no lens distortion (e.g. when you photograph a flat chequerboard all the lines come out straight in the photo. If you do have barrel or pincushion distortion you can correct it (e.g. with RAWTherapee or Photoshop).
  • Open the image in ImageJ, select the multi-point tool. Place a point on the tip and base of the egg, and three or more extra points around the edge on each side (8 points in total, as in the above photo).
  • Go Plugins>Egg Tools>Egg Measurement and follow the instructions, or see the video below.

Why is this useful?

The geometrical properties of eggs – such as volume and surface area – have uses ranging from ecological, physiological and morphological studies in birds, to predictions of chick condition in the poultry industry. Although measurements of an egg’s length and breadth can be used to approximate an egg’s geometry, the coefficients used in these models are specific to the original test population, and within-species variation in egg shape means these methods cannot be used reliably outside of that original test population. The mathematical formula here describes the curvature of a bird’s egg, and it can be used to calculate the shape, volume and surface area of an egg precisely from digital images. Using data from a number of species I demonstrated that the model has a greater level of accuracy than length and breadth-based methods.

 

egg equation black

How it works

The equation is essentially an ellipse that has a normal distribution added. The variable a describes the width of the ellipse, b describes where the centre of the ellipse bulge sits, and c describes how acute/pointed that bulge is.

Egg shape examples

Video walk-through

36 Comments

  1. Jana
    October 1
    Reply

    Nice tool- but why are all the measurements displayed with NA? Width:NA, Length:NA- bascically everything!

    • jolyon
      October 2
      Reply

      Thanks for getting in touch Jana. The problem was caused by inputting “mm” in the scale bar length. You should only put in the numbers when asked for the scale bar length (no letters). I’ll update the code to catch this error when I get some time.

  2. Lee
    February 1
    Reply

    I wonder this tools can use for any eggs like duck and chicken ..

    • jolyon
      February 1
      Reply

      yes the tool should work well with almost any bird species’ eggs, and even a lot of other species. Pretty much any elliptical object that is squished length-ways in one place should work.

  3. lee
    February 5
    Reply

    thank you so much for your suggest, and do you have any tools that can mesurement of grain like rice grain or any grains …..

    • jolyon
      February 5
      Reply

      I’ve never tried modelling grains of rice. You could give this tool a go and see how well it maps the outline. However, I guess many grains are slightly flattened rather than having a circular cross-section, in which case this egg tool won’t predict the volume well. For measuring grains I imagine you’d need an image taken from above and from one side, then assume an elliptical cross-section. Alternatively you could use full 3D scanning (e.g. laser scanning might work well).

  4. Lee
    February 12
    Reply

    Thank you again

  5. manzar
    April 4
    Reply

    Thank you for the tool, but I cannot use it for my own samples images, it draws a line around the egg but doesn’t show the Accept and Adjust buttons and therefore no measurement is possible. How can I fix the problem? It works with your sample image and my images are also in jpg format.

    • jolyon
      April 12
      Reply

      The buttons are placed below the egg, so if there’s not enough image below the egg they might not be full visible. You could try copying your image into a larger image, or rotating it so there’s more space below the egg?

  6. Jallal Gnaim
    April 25
    Reply

    Please can you provide us with more information about the protocol of taking pictures of the egg.

    • jolyon
      April 25
      Reply

      Thanks for your question, you can follow the brief instructions above (take photos side-on etc..) The accuracy will depend on you getting the eggs positioned so that their long axis is at right angles to the camera. I used a plastic washer or sheet of foam with a hole in it to position the eggs. Then just photograph with a scale bar at the same height as the centre of the egg, and also at right-angles to the camera. The egg doesn’t need to fill the whole photo, though shouldn’t be too low resolution. You can fit quite a few eggs into one photo if that’s easiest too.

  7. alison
    August 28
    Reply

    Hi Jolyon! I was wondering if you could perhaps explain the proof of your equation a little further? I’m struggling to understand where you’re coming from.

    • jolyon
      September 13
      Reply

      Hi Alison, I’m afraid I’d have to rework the post to explain the process. However, the equation is essentially just an ellipse where x1 = a*COS(2*PI()*x)+b, y1 = b*SIN(2*PI()*x), then this is modified by multiplying y1 with a normal distribution: y2 = 1/(alpha*(2*PI()))*EXP(-0.5*((x-mu)/alpha)^2). I hope that makes sense!

      • Matt
        November 9
        Reply

        Hi, I wasn’t sure if you’d be willing why you added the normal distribution into the equation? I get the ellipse, but how does the normal come into play?

        • jolyon
          November 9
          Reply

          Hi Matt,

          Some eggs do have an elliptical shape, which is the default if a sphere is squeezed into a tube (such as the bird’s oviduct). But most eggs have a ‘blunt’ end and a ‘pointed’ end. There are various ways in which an ellipse could be deformed to fit this egg shape, but it makes sense that whatever shaping pressure is being applied from the tube does so according to some gradient or other (it’s unlikely to be perfectly linear, for example). The normal distribution squeezes the pointed end of the egg in a nice smooth way, that happens to match real egg shapes very well.

          Cheers,
          Jolyon

  8. Estefania
    October 29
    Reply

    Thank you for the tool! is there a way of measuring other objects?
    I am trying to measure lung volumes. Thank you!

    • jolyon
      October 31
      Reply

      Hi Estefania, What kind of images are you using to calculate lung volume? The nice thing about eggs is that they’re spherical in sections taken through the long-axis, whereas things like lungs will have more complex shapes. However, there is likely to be a good correlation between the area covered by lungs in two dimensions with their overall volume. You could therefore wok out the area covered by the lungs in pixels and convert this to square centimetres. There will much more error associated with this method than the egg methods though.

  9. JC
    November 27
    Reply

    Hello, thank you for this tool. I am having trouble getting the plugin to work because it seems like imageJ only reads plugin in either .class or .jar format. I see that the plugins you made are in .txt files and imageJ is unable to recognize them after placing them in the plugins folder. I was wondering is there a solution to this? Thanks.

    • jolyon
      November 27
      Reply

      Hi, are you trying to use the plugin with FIJI rather than normal ImageJ? If so, you just need to rename the script with “.ijm” instead of “.txt” so that FIJI recognises it as a macro script.

      • JC
        November 27
        Reply

        It works now, thank you very much again!

  10. Mike
    June 9
    Reply

    Hi Jolyon. I just wanted to say thanks not only for the well-developed tool, but also for communicating its use so well. Nice webpage, tutorial video – the whole thing. So thanks!

  11. Clint
    January 15
    Reply

    Can you clarify what the units are for surface area? Are they square mm? Thank you for a great tool.

    • jolyon
      January 15
      Reply

      The units are in whatever length unit you use for the egg length. So if you specify the length in mm, the surface area is in mm^2.

  12. Rafal
    February 19
    Reply

    Hello,

    I am wondering how calcuate egg shape coefficient using your method. You mentioned in your article that you calculated such coefficients for eggs different species but there is no explaination how to do it. Mayby my question is trivial but if you could explain how calculate egg shape coefficient I would be greatful for your help.

    Best regards,

  13. Carlos Alfonso-Gonzalez
    March 8
    Reply

    Hi,
    The software is fantastic, the thing I would improve is that the scale has to be set every time you measure a single picture is a bit difficult to establish the scale If you have lots of pictures.
    Thank you!

    • jolyon
      March 26
      Reply

      Yes that would be a handy tool for cases where the camera doesn’t move. To get around this you can simply measure the first scale bar and save the ROI with the mspec image. Then, when you open another mspec image load that first ROI (zip file) in that image. This will save you some time.

  14. Adam
    March 19
    Reply

    Hi
    I’m having a problem with a Condor egg. It seems that the software thinks it should be rounder. Any suggestions on how to get it to keep to the egg shape?

    Many thanks

    • jolyon
      March 26
      Reply

      How interesting – It’s worked on pretty much all eggs I’ve ever found (including google image searches for condor eggs). Do email me a sample photo and I might be able to diagnose the problem.

  15. Mark Krebs
    July 24
    Reply

    Very nice plugin. I wondered if it assumes that the longitudinal axis of the egg is parallel to the focal plane (or the plane of the imaged grid behind the egg). If the egg were tipped, perhaps due to a weird center of mass, mightn’t this cause the shape to appear more circular? In this regard, would it be possible to tweak the algorithm so that any orientation of the egg in 3D could be accommodated?

    • jolyon
      August 23
      Reply

      Yes you’re correct, it does assume you’ve photographed the egg perfectly side-on (this is obviously a very important assumption). So you need to position eggs in holders before photographing, not just allow them to roll around on a flat surface! See the paper for more details if you’re interested.

  16. joung
    January 5
    Reply

    hi, I am a macbook user and I have tried this with other people’s computer just to check if it’s my computer’s problem and all of them had this issue. When I am done with egg measurement step, then to drawing a line at the scale bar and press okay, it doesn’t show the table that you have in the youtube video, but instead has a message titled “ROI writer” then it ends with “Egg_Mesuarement (Read only system)”. What is the problem? I really need to solve this problem as quickly as possible, so I will be glad if you can reply to me as soon as possible.

  17. Brian
    February 23
    Reply

    Hi Joylon!
    Loving the software. How do I graphically plot the profile of the egg in its entirety?
    Brian

    • jolyon
      February 24
      Reply

      Hi Brian, the software creates a plot and you’ll notice a little option to save the data at the bottom right. This gives you access to the egg’s shape coordinates so you can plot them yourself.

      Cheers,
      Jolyon

  18. Mia
    September 8
    Reply

    Also, I really want to know how to put egg tool on image j on MacBook! I cannot use it with apple system? please give me a detailed instruction, please ?

    • jolyon
      September 9
      Reply

      On a mac you just need to download the latest ImageJ version from the NIH website. This will be a zip file, which turn into an app automatically (e.g. drag it to your documents directory). You can run ImageJ by double-clicking ImageJ.app. control-click the Imagej.app file and select “show package contents”. From there just make a new directory e.g. “imagej/plugins/egg tools” and drop the egg measurement script into that.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.