|
AVIAN
ECOLOGY LAB : Measuring Egg Size |
|
home | index | research | avian ecology lab |
|
Bridge, E.S., R.K. Boughton, R.A. Aldredge, T.J.E. Harrison, R. Bowman, and S.J. Schoech. 2007. Measuring egg size using digital photography: testing Hoyt's method using Florida Scrub-Jay eggs. Journal of Field Ornithology 78:109-116. |
Egg size is an extremely useful parameter in studies of avian reproduction. However, it can be difficult to collect egg size data in the field with a high degree of accuracy. Methods for measuring egg size range from taking weights and linear measures to observing water displacement, and all have their advantages and disadvantages. One little-used approach is to estimate egg parameters from photographs. Estimating egg size from photographs was first pioneered Paganelli et al . (1974), who traced the outlines of eggs using a planimeter to calculate volume and surface area. The technique described here is basically a modification of this earlier technique. The primary difference is that we use an automated computer analysis procedure to read in data directly from digital photographs, eliminating the need to trace each egg. There are also some other modifications to the methods of Paganelli et al . (1974) that are necessitated by the nature of digital photography.
Egg shapes do not conform to any single mathematical function, and it is not possible to precisely predict parameters such as volume or surface area based on simple linear measurements alone (Preston, 1974). There are, however, methods that use linear measurements alone and sometimes linear measurements along with shape variables that will often generate serviceable volume estimates depending on the general size of the eggs (Preston, 1974; Tatum, 1975; Hoyt, 1979). Eggs have circular symmetry about the long axis. Hence all the information regarding the shape and size of an egg is contained in a cross section through the long axis. If we view an egg perpendicular to the long axis, the outline we see is equivalent to such a cross section. Hence, for any normal egg, we can determine all size and shape characteristics from a good outline of the egg seen from the side. We use digital photography to record these outlines.
A digital photograph consists of individual color units or pixels. In almost all digital images, pixels are arranged in a Cartesian system of rows and columns, which makes each pixel square or (occasionally rectangular) in shape. Because of this constraint, the pixels in a digital photograph only provide an approximation of the true shape of an object. A smooth curve, such as the edge of an egg, is approximated by square pixels, many of which will be a color that is intermediate between the egg and the background.
The first step in deriving egg-size parameters from a photograph is to define the outline of the egg as accurately as possible given the limitations associated with pixel-based images. One means of improving accuracy is to increase the resolution (or the overall number of pixels) of the photograph. However, the improvement brought about with increased resolution quickly becomes negligible once the digital height of an egg exceeds about 300 pixels. Assuming we have sufficient resolution, the next problem to deal with is the fact that the edge of the egg in the digital photograph is often approximated by pixels that are intermediate in color between the egg and the background. To calculate egg parameters from pixels, we need to have a precisely defined edge that allows us to determine whether a pixel is egg or background. We accomplished this by using the gthresholdh feature in GraphisConverter. This feature converts all pixels in an image to black or white according to whether a pixel's brightness is above or below an adjustable threshold value. The threshold value used should be just high enough to render the egg as a white silhouette with the outline of the egg intact.
Once we have a monochromatic egg silhouette to work with, we can calculate egg size parameters by evaluating the distributions of black and white pixels in the image. The length and width are quite easily calculated as the height and width of the trimmed image. Volume can also be calculated quite easily by regarding each row of pixels as a thin cross-sectional slice of egg. Each of these slices will be I pixel thick, and are approximately equivalent to a thin disc or cylinder with a radius (r) equal to half the number of egg pixels in the row. The volume of each cylinder is simply ?r 2 (remember that the height of the cylinder is 1 pixel). Summing all of the cylinders gives a highly accurate measure of egg volume.
The calculation of surface area is slightly more complicated. Because the edge of the egg in the digital silhouette is a blocky composition of pixels, the surface area an egg cannot be calculated by simply summing the surface areas of the perimeters of the cylinders used to estimate volume. Instead, each cross section was regarded as a right frustrum of a cone, and the surface areas of the perimeters of these frustra were then calculated as in Paganelli et al. (1974) and summed to give a total surface area. An important consideration in calculating surface area is the number of cross-sections used. As stated above, the pixels in a digital image cannot perfectly trace the outline of an egg. Each row of pixels is only a close approximation of the width of the egg at a given point, and using each row of pixels to generate a frustrum would inflate egg surface area because it would create a topology considerably less smooth than that of the real egg (See figure 1). Hence, for surface area estimation, the optimal size for the cross sections must be small enough to accurately capture the curvature of the egg, but large enough that it does not allow pixel resolution error to create an artificially convoluted topology. By experimenting with the surface area of a sphere of known diameter, we found the optimum number of cross-sections to be about 80 for a picture that is about 500 pixels in height. In other words, the optimal cross-section height was about 6 pixels.
![]()
Of course, egg volumes based in pixels are useless by themselves. Lengths, volumes, and surface areas based on pixel units will depend greatly on the size and resolution of the photograph. Hence, it is necessary to standardize all digital photographs by incorporating into each photograph two calibration points separated by a known distance. These calibration points can be used to derive the number of pixels in a given metric unit, say centimeters. This scale factor can then be used to translate all egg parameters into measurements in SI units.
Our egg measurement system uses the shareware program GraphicConverter (Lemke Software, Peine , Germany ) in conjuction with Applescript, a component of Macintosh OSX system software (Apple Com puter, Cupertino, CA) . These two software components were integrated into a single egg-analysis procedure wherein GraphicConverter performed all necessary image manipulations while the user interface and mathematical calculations were handled by a set of Applescript instructions (henceforth referred to as the script). What follows is both a set of instructions for using the egg measurement system and full explanations of what the software components do.
1. Preliminary set-up.
Save egg photos in a single folder on a writable storage device. All egg photographs to be analyzed should be in a single folder on a hard drive or some other writable storage device. When data from the egg photos are generated, the script will attempt to save the results in the same folder that contains your folder full of photographs. Hence, the photos cannot be on a CD or any other read-only media.
Establish a threshold value. Before processing eggs, it is important to establish what threshold value will work best for your particular egg photographs. To do this, open several typical photographs in GraphicConverter, and apply the threshold function until you get a threshold value that creates a good egg silhouette for a wide range of photographs. The default threshold value is zero. If you need to change it, you can do so using the Applescript editor. Open the script in Applescript editor and find the line that defines the threshold value variable (gSet threshold to 100h). Change the number to your optimal threshold value, and save the script (command S or use pull-down menus).
2. Open and run the script.
Double-clicking on the script icon should open it in Appscript editor. To run it, click the gRunh button in the top right corner of the script editor window.
3. Open a photograph file.
The first thing the script will do is prompt you to choose a file to open in graphic converter. Simply browse to the first photo you want to analyze and click g Choose .h This file with then open in GraphicConvert and will be sized to nearly fill the available space on the screen.
4. Calibrate the image.
After the digital photograph is opened, the script will generate a window with instructions for defining the calibration points in the image. If this window does not appear, it is probably because the photograph is covering it up; to reveal it select the Applescript Editor in your dock or press (WHAT!?!?!?). With the digital image the foremost on the desktop, follow the instructions to record mouse clicks with GraphicConverter and save these coordinates to the clipboard. Then click the gOKh button in the script window.
The script then sends up a dialog box that asks for the distance between the two calibration points in the photograph. Enter this value in whatever units you wish, with the understanding that the output from the script will be in these same units (squared for surface area, and cubed for volume). The script takes the coordinates of the calibration points from the image and calculates the distance between them in pixels. This value is then divided by the length value you entered to generate a scale factor (e.g. pixels per centimeter).
5. Select the egg.
In the next step, the script will direct you to draw a rectangle around the egg you wish to analyze. Do not click gOKh until you have selected the egg. After selecting the egg and clicking gOK,h the script will direct GraphicConverter to threshold the image and isolate the selected area in its own window. This new image is then trimmed such that the top, bottom, and sides of the egg define the borders of the image. Finally, the images is inverted to show a black egg outline on a white background. The remaining steps will be performed on this isolated egg silhouette.
6. Enter the egg number.
Next the script brings up a dialog box asking you which egg you have selected. As many egg photographs will contain multiple eggs from a single clutch, you must tell the script which egg it is about to analyze. Numbers or letters will work here. This user-interface window also allows you to confirm that the egg silhouette looks as it should prior to analysis. If there are black or white pixels in the wrong part of the image, the analysis will be seriously compromised. Look closely at the image. If there are problematic areas, you can either quit the script and start over or you use GraphicConverter to fix the erroneous pixels by painting over them in either black or white.
7. Hit OK and wait.
Once you enter the egg number and hit OK, the script begins working with the egg image. First, the script directs GraphicConverter to save the image in a special text format called XMP. In an XMP file a letter is assigned to each color that appears in the image, and the letters are arranged in an array of rows such that the location of each letter corresponds to the location of each pixel. In this situation, white pixels are assigned to the letter gAh, and black pixels gB.h
When the XMP file is created and the text data are read, the script first finds the degree to which the egg must be rotated to make the long axis vertical. To to this, the script samples lines of XMP file near the top and bottom of the image. It compares the numbers of white and black pixels on the left side of the image to those on the right side. If the numbers are the same, then no rotation is necessary. But, more likely the egg will be slighty to one side of vertical, and it will be necessary to rotate the image. The script predicts how much rotation will be needed based on the difference in the pixel counts from the right and left sides of the image. The script directs GraphicConverter to rotate and trim the margins of the image to generate a new egg silhouette. The process is then repeated with this new image until the egg is extremely close to vertical.
The resulting image has, by this point, gone through an unknown number of rotations, each of which is likely to have distorted the image to some small degree. Therefore, rather than performing the size analyses on the potentially distorted image, the script, having stored all the information as to how the egg was rotated, calls up the original egg silhouette image, and commands a single rotation in GraphicConverter to provide a rotated egg with as little distortion as possible. This image is then trimmed to the size of the egg and saved as an XMP file.
The script reads in the data from the XMP file and calculates the height and width of the egg as simply the height and width of the trimmed image. Volume is calculated as described above, by summing the volumes of cylinders with diameters equal to the number of black pixels in each row. Surface area is calculated similarly by theoretically slicing the egg into 80 cross sections and regarding each as a right frustrum of a cone. The radii of the circles that make up the top and bottom of the cone (rt and rb) are equal to half the number of black pixels in the corresponding rows, and the height (h) of the frustrum is calculated as 1/80 times the total height of the egg. The surface area of the perimeter of each frustrum is calculated as in Paganelli et al. ( 1974 ) as shown in figure 2.
After calculating linear measurements, volume, and surface area, the script applies the scale factor calculated earlier to present all the measurements in the units applied to the actual distance between the calibration points.
In addition to these unit-based measures, the script calculates a simple shape variable, which we refer to as the shape index. The shape index is simply the total number of black pixels in each egg silhouette divided by the total number of white pixels. In other words, it is the proportion of the two-dimensional egg image not occupied by the egg. Round or barrel-shaped eggs will tend to have a low shape index value, whereas pointed or diamond shaped eggs have relatively large shape index values.
When all of these variables are calculated (this could take up to 20 seconds depending on the speed of your computer), the data are output to a text file named gmonth_egg_datah where month is the month in which the data were analyzed. If this file does not already exist in the same directory as the folder of egg photographs, it will be created and saved there. If the file already exists, the data will be appended to the end of the file.
8. Go on to the next egg.
When the script has finished with the first egg, it will ask you if you want to process another egg from the same photograph, open a new photograph, or quit the script. If you choose to analyze another egg from the same photograph, the calibration steps will be bypassed and you can begin at step five by selecting an egg. If you choose to open a new photograph, the calibration process must be performed again.
GraphicConverter is a shareware program available HERE for $30.
The egg compiler applescript is available HERE.
Hoyt, D.F. 1979. Practical methods of estimating volume and fresh egg weights of bird eggs. Auk 96:73-77.
Paganelli, C.V., A. Olszowka, and A. Ali. 1974. The avian egg: surface area, volume, and density. Auk 76: 319-325.
Preston, F.W. 1974. The volume of an egg. Auk 91:132-138.
Tatum, J.B. 1975. Egg volume. Auk 92:576-580.
|
|