How to count the population of flocks of birds using software
We normally see around a few birds and it is rather easy to count them. However, when there is a flock with dozens, hundreds or thousands of birds, there is need for an automated (computer-assisted) method to count the birds. Without a computer-assisted method, it is easy to over/under-estimate the count, and worst of all, there is no way to provide evidence of your count to a third-party.
There are several efforts to use software to count birds and other wildlife. Juan M. Pérez-García in The use of digital photography in censuses of large concentrations of passerines: the case of a winter starling roost-site (2010) describes how to use the UHTSCSA Image Tool 3.0 (specialized image processing software primarily for medical applications) in order to count the population of flocks. He calculates the error from the automated counting from the images. The specific software is closed-source, for Windows only and was last updated in 2002.
Another option that is suitable for bigger birds such as flamingos is described at An automatic counter for aerial images of aggregations of large birds (2011) (full text) by Arnaud Béchet et al. A specialized program was written, called FLAMINGO (distributed under the CeCILL license, a French free and open-source software license), that can count populations of birds that their body shape is shown as an ellipse in aerial photographs.
Each bright spot most likely corresponds to a bird, and the software manages to identify and count them. Apparently, the software has been tuned to work with such low resolution images, since the airplane probably had to fly high enough in order not to disturb the flock.
I could not get it to work reliably with my photos. It works better with pre-processed images at low resolution.
A final option is to use ImageJ, as explained by Christof, at How to count the birds in a photo of a flock – automatically! I will be repeating the instructions here, with emphasis on how to use on Ubuntu. ImageJ has been developed in Java, thus it is also available in Windows and OS/X. Check at ImageJ on how to download and install on Windows or OS/X (then, continue at step 3 below).
- First of all, ImageJ is available at the Software Centre in Ubuntu. Find it and install it,
You will notice that the icon of ImageJ will then be automatically added to the launcher.
The icon looks like a golden optical microscope.
- The version that we just installed was 1.47a, and was released in the summer of 2012. At http://imagej.nih.gov/ij/notes.html we can see that there is a more recent version. Let’s update! We need to close the ImageJ application (if it is running) and then open the Terminal window. There, we run gksudo imagej which will run ImageJ with superuser privileges. The reason why we do this, is to click on the Help → Updated ImageJ… menu, and get ImageJ to auto-update itself. Do that. Once the update is completed, we can close ImageJ and start it again from the Launcher and get the latest ImageJ!
- Let’s start with an example. Let’s count the birds at
Right-click on the image above and save it locally in order to open with ImageJ. Then, start ImageJ and open the image.
- In ImageJ, click on the menu Image → Type → 8-bit in order to convert the image to an 8-bit image. This step simplifies the image for the next step. The colors are reduced as they are not important for our counting.
- Then, click on the menu Image → Adjust → Threshold… With the Threshold tool we can select what information on the image to keep, and easily remove the rest. We set lower and upper thresholds, and at the same time can see in the image when the birds and just the birds appear in the special red color. Once we are happy with the threshold values, we click on Apply. By applying, the features in the image that are in red will remain, and the rest are gone.
- Now let’s count. Click on Analyze → Analyze Particles… (see documentation at http://rsbweb.nih.gov/ij/docs/guide/146-30.html)
In the Size text box we can specify the range for the size of each individual bird. 0-50 means that a single pixel up to a group of 50×50 (2500) pixels will be counted as an individual bird. Circularity describes how circular the shapes of the birds should be. Circularity 1 means a perfect circle and 0 means not a circle at all. Therefore, the value 0.00-1.00 means that we accept here any shape. Finally, we click OK in order to perform the analysis.
- Here is the output,
You can notice that the branch/stick on the upper-left of the image has not been counted as a bird due to the upper size limit that we specified. The total number of birds has been counted to 803. Obviously there should be some errors, and depending on the set of images that we work on, it is important to calculate how big that error can be (comparing with hand-counting from the photograph, etc).
Let’s try with another image, a photograph straight from the camera.
You need to click on the image in order to get the full resolution (4912 x 2760). Them, click to save as an image file.
You can distinguish most of the birds at the lower-right of the image. Feel free to try to count them manually before getting the result from ImageJ.
It is helpful, after you convert the image to 8-bit, to try to subtract the background of the image. For this image, the clouds will get dull which will help with the next steps in the processing. To subtract the background, click on Process→Substract background…
Below is an animated GIF that shows a section of the original photograph, in three animated frames. The first frame is the original photograph, after the background has been subtracted. The second frame shows the birds being identified after the threshold has been applied. The third frame has the birds numbered.
You may notice that two birds have not been picked up by ImageJ as they can barely be distinguished. Another source of error is when two or more birds overlap, and are counted as one (this case is not shown in the animated GIF). These two issues contribute to the margin of error, when using ImageJ.
ImageJ can accept plugins, so it is feasible to write a BirdCounting plugin that performs these steps in one go.
Bird counting is a difficult task. By taking photographs of a flock, it is possible to count them and provide evidence of the count.