Monitoring populations of bioluminescent organisms using digital night photography and image analysis: a case study of the fireflies of the Selangor River, Malaysia


Laurence G. Kirton, Tropical Forest Biodiversity Centre, Forest Research Institute Malaysia, 52109 Kepong, Selangor, Malaysia. E-mail:


Abstract.  1. The ability of bioluminescent organisms to produce light provides opportunities for remote, non-destructive sampling through imaging. A case study of its use in monitoring populations is described for fireflies that congregate on riverbank trees in an ecotourism destination in Kuala Selangor, Malaysia.

2. Digital images were captured from set locations at a standardised moon phase and time of night, at distances of 60–270 m across the riverbank.

3. Counts of bright spots by trained, cross-calibrated operators were used as an index of abundance, and could often be predicted by regression equations for a subsample of particle analysis counts generated by image analysis software.

4. In tests of the sustainability of the technique, prediction of counts from an upgrade camera could be achieved by multiple linear regressions incorporating camera-subject distance, particle size, and particle intensity characteristics. Multiple linear regressions could also be used to refine prediction of manual counts from particle analysis counts in this camera.

5. Sampling light emissions enabled a much larger area of habitat to be monitored than would have been possible with other methods. In total, 1.6 km of the river margin could be imaged in just three nights from 20:30 to 23:30 hours. The technique can also be adapted to monitor populations of other aggregating, light producing organisms and to study group display behaviour.


Bioluminescence occurs across a range of life forms. In insects, for example, it occurs in a number of coleopteran families and the dipteran family Mycetophilidae (Lloyd, 1983). The ability of such organisms to produce light makes it possible to remotely sample their light emissions as a means of studying behaviour and population size.

Adults of some species of fireflies (Coleoptera: Lampyridae) are known for their communal flash displays (Carlson & Copeland, 1985). For example, fireflies of the genus Pteroptyx Olivier form large, monospecific aggregations on certain trees, usually along riverbanks (Lloyd, 1973; Lloyd et al., 1989), and a number of species flash synchronously (Buck & Buck, 1968; Case, 1980). This spectacle fuels an ecotourism industry in countries such as Malaysia and Thailand (Saphakun, 2009; Wong, 2009).

One of the better-known ecotourism destinations for firefly watching in Southeast Asia is along the lower reaches of the Selangor River near Kuala Selangor in Malaysia (Kirton & Nada, 2010). Here, adult Pteroptyx tener Olivier congregate in large numbers on the mangrove plant Sonneratia caseolaris (L.) Engl., whereas the larvae prey on snails that depend on the river and its natural vegetation for food and refuge (Nagelkerken et al., 2008; Nada et al., 2009). However, habitat loss, pollution, and changes in salinity due to river-water extraction for agriculture and human consumption threaten the firefly population (Nada & Kirton, 2004; Nada et al., 2009).

An effective monitoring programme is fundamental in detecting change in a population and in assessing the effectiveness of conservation measures (Hellawell, 1991). In this article, we describe a method of monitoring fireflies based on digital photography and image analysis, which was developed to determine yearly and long-term population trends of fireflies along the Selangor River (Kirton et al., 2007). The method has been in use for a monitoring programme for over 4 years. It is envisaged that it can be readily adapted for monitoring any firefly species or other aggregating, light-producing organisms.

Materials and methods

Laboratory test

In a laboratory experiment, fireflies were stocked at three different densities at a male-female ratio of 4:1 in clear Perspex boxes (25 × 25 × 30 cm) containing sprigs of the display plant S. caseolaris, and photographed in a darkened room at a distance of 82 cm (focal plane to centre of box) using a Canon EOS 5D (Canon Inc., Japan) with a Canon Zoom Lens 28–105 mm (ISO 3200 equivalent, f.l. 50 mm, f. 4.5, 0.5 s). Three replicates of each stocking density were used and three images of each vertical face of each box were captured. Counts of bright spots in the images were averaged for each box.

Field sampling

In the field, images of flashes of fireflies along stretches of riverbank were captured at night on their display trees that overhang the banks of the Selangor River (Fig. S1 Supporting information). Photographs were taken from across the river at several sites where there was a gap in the vegetation that enabled a good view of the opposite bank.

The primary camera used was a Canon EOS 5D with an EF 70–200 mm f/2.8 L IS USM lens. Maximum JPEG resolution, image size, sensor sensitivity (ISO 3200 equivalent), and aperture (f. 2.8) were used, with preset focus and a site-specific focal length between 85 and 135 mm. Eight exposure times ranging from 0.1 to 8 s were tested in five sequential sets of identically framed images, with the order of exposures randomised within sets.

Camera location was reproduced with the aid of a permanent ground marker, a fixed-length plumb line, and a heavy tripod with a built-in spirit level. Camera orientation was reproduced at night based on daytime presets, with the aid of the tripod’s graduated dials or a compass (for further information on camera setup see Appendix S1). The camera was panned to capture images that covered the entire visible stretch of riverside trees (Fig. S1a).

Image analysis

Each image was cropped in image editing software to exclude the small amount of overlap with the previous image in the sequence (Appendix S2). Visual counts of flashes (manual counts) were made on enhanced (gamma +5.00) images in image analysis software at a magnification of 200% on high quality, 19–22 inch LCD screens. The same operator was used for all images within an experiment.

Particle analysis by an image analysis software, Olympus Soft Imaging Solutions analySIS LS Research 2.8 with a detection module add-in (Olympus Soft Imaging Solutions GmbH, Germany), was used to aid in the counting of flashes. Particle analysis detects, counts, and characterises spots or patches (‘particles’) comprising a minimum number of adjacent pixels that fall within set levels of brightness (upper and lower detection thresholds). For it to be an effective tool in the analysis of images, there needs to be sufficient contrast between the particles and the background, as in the bright flashes of fireflies in a dark image. Greyscale images (256 levels) based on different colour separations were tested. Optimum parameters for detection were determined by comparing the results against manual counts. Maximum brightness (255) was set for the upper threshold, whereas the lower threshold (hereafter referred to only as the threshold) was varied to allow detection of bright spots of different intensity.

Cross-calibration of cameras

Comparative tests were also carried out using a Canon EOS 5D Mark II (referred to herein as the EOS 5DII) with an EF 70–200 mm f/2.8 L USM lens. The cameras were mounted on dual tripod heads on a single tripod (Fig. S1c) such that framing was virtually identical, and were triggered simultaneously by a wireless remote (further information on dual camera setup is given in Appendix S3). Images were captured in four panning sequences in which the wireless receivers were switched over on the cameras and the cameras switched over on the tripod heads in a fully crossed design. Counts were averaged for each camera angle. The capture sequences were replicated three times with a gap of 5 min, as well as on three different months.

Prior to conducting manual counts, a median filter, which replaces each pixel with the median of that pixel and its eight-nearest neighbours, was used to remove small flecks of grey-white noise inherent in the images of the EOS 5DII. Averaged manual counts from the two cameras were regressed to determine relationships, and best subsets multiple linear regressions were used to improve prediction. Variables used were camera-subject distance (to the midpoint of the image), aspect (angle of incidence to the vegetation line at image midpoint) and the particle analysis parameters, mean particle area (mean number of pixels per particle), mean particle intensity mean (mean of the means of all pixel grey-level intensities in each particle), and mean integral intensity (mean of the sum of all pixel intensities multiplied by their area in pixels for each particle).


Visual interpretation of images

In the laboratory test, there was a linear relationship and high correlation (R2 = 0.94; slope = 0.16, < 0.001; intercept = 1.12, > 0.06) between stocking density and manual counts of bright spots in images (Fig. S2). In the much greater distances of the field, flashes of fireflies in images (Fig. S3) could be counted after image enhancement, with a high degree of correlation between an experienced operator and a novice operator that had no prior instruction (R2 = 0.95, = 3 images × 6 sites) and increased concordance after training and practice (R2 = 0.99). However, the slopes of the regression lines of three experienced operators differed by 2–13%. In a larger dataset of 405 images (5 months × 9 sites × 3 camera angles × 3 images), the variance component (R2) accounted for by the regression of square-root transformed counts of one operator against the other was 99.29% (slope = 0.975, < 0.001; intercept = −0.057, > 0.1). The inclusion of all other factors (site, month, and camera angle) and interaction terms accounted for an additional variance of only 0.45% in a general linear model.

Mean manual counts of bright spots increased more or less logarithmically with exposure time, rising steeply between 0.1 and 1.0 s but less steeply thereafter, with the highest variation at the shortest exposures (Fig. 1). Overall intensity of bright spots increased with longer exposure time, as did background intensity and multiple spots produced by movement of individual fireflies. An exposure time of 0.5 s was selected for further tests.

Figure 1.

 Effects of exposure time on manual counts of bright spots (mean ± SE) in identically framed images (enhanced to gamma level 5.00 for 0.1–0.8 s, 4.50 for 1.0–2.0 s, 4.00 for 4.0 s, and 2.5 for 8.0 s).

Particle analysis

In tests of different colour separation layers, the green layer produced the largest and brightest spots (Table S1) and the best linear regressions of manual and particle analysis counts (Table S2). Further tests were, therefore, based on this layer. Particle detection increased logarithmically with decreasing threshold, with no point of inflection and with a dramatic increase beyond the manual count level (Fig. S4). Setting a minimum particle size of two pixels (diagonal connectivity permitted), with a threshold of 36, detected approximately 82% of manual counts and greatly reduced or eliminated unwanted detection of skylight and water surface reflections.

Manual counts regressed well against particle analysis counts within sites and sampling periods that had sufficiently bright spots or where small numbers of images with dim spots were excluded, but regression slopes varied by site on any one sampling period (Fig. 2a) and by sampling period in any one site (Fig. 2b). However, selecting just three images from a variety of camera angles with high particle analysis counts enabled construction of a zero-intercept, linear regression equation that could be used to predict manual counts for the remaining images within a site and sampling period (Fig. 2c). Correlation between predicted and actual manual, site-period counts (Fig. S5) was very high (R2 = 0.999, = 36) with a slight but significant underestimation (slope = 1.014, = −3.8, = 0.002; intercept = 1.263, > 0.59).

Figure 2.

 Regression between manual and particle analysis counts of bright spots within single sites and sampling periods (three images per camera angle). (a) Differing regression slopes for different sites in the same month. (b) Differing regression slopes for the same site in different months. (c) Substitution of a full regression (broken line, all symbols) with a zero-intercept regression slope (solid line) obtained from just three images (black symbols) selected for variety of camera angles and high particle analysis counts.

Cross-calibration of cameras

The EOS 5DII produced images with bright spots of lower intensity against a darker background, thus requiring a threshold of 18 (compared to 36 in the EOS 5D) to attain a comparable degree of particle detection. At this threshold, skyline had to be excluded to prevent detection. At moderate camera-subject distances (72–96 m), manual counts for the two cameras had a simple linear, close to 1:1 relationship (= 0.99x, R2 = 0.98). Where camera-subject distance was greater, best subsets multiple linear regression incorporating particle and camera-subject parameters was required for prediction of EOS 5D manual counts from EOS 5DII counts (Fig. 3).

Figure 3.

 Relationship between manual counts of flashes in images taken by the EOS 5D and EOS 5DII (at equivalent enlargement of 156%). Different symbols represent different camera angles and hence different camera-subject distances. (a) Biased, distance dependent scatter at a site with large camera-subject distances. (b) Accurate prediction of EOS5D counts from EOS 5DII counts at this site using multiple linear regression. (c) High distance-dependent scatter in a site with extreme camera-subject distances. (d) Prediction of EOS5D counts from this site by separate multiple regressions for images with extreme (closed symbols) and shorter (open symbols) camera-subject distances. Ĉ1 = best subsets regression for prediction of EOS 5D manual count, C2 = EOS5DII manual count, = mean particle area (pixels), Ī = mean particle intensity mean (grey level), = camera-subject distance (m).

Best subsets multiple linear regression could also be used to improve prediction (R2 = 0.95) of EOS 5DII manual counts from its particle analysis counts (Fig. S6) without the need for an estimate of the regression slope for each site each month using three-point, zero-intercept regression lines.

Use of the technique in monitoring

A continuously varying number of flashes registered in identically framed, 0.5 s exposures taken in sequence (Fig. 4a). Averaging counts for two or three images taken at intervals of 60–90 s reduced variation and the effects of extreme values, with less obvious advantage averaging more (Fig. 4b). Three replicate sets of images were, therefore, taken at each site during actual monitoring.

Figure 4.

 Fluctuation in the number of flashes of fireflies over time in identically framed images taken at 1 s intervals with the EOS 5D. (a) Particle analysis counts for images taken over a period of 10.0 min. (b) Box plot of particle analysis counts for 1122 images taken over a period of 18.7 min (left) and for averages of different numbers of counts subsampled using 100 different random start times with random intervals of between 60 and 90 s (right).

Display trees along a total of 1.6 km of riverbank could be photographed over three nights within 2–3 h between 20:30 and 23:30 hours using the technique described. A monthly index of abundance of fireflies was formed based on the total counts of flashes in the entire image series for each site, averaged for three replicates. Moon phase and time of night were as similar as possible during each sampling period. Fluctuations in the sizes of aggregations at each site varied considerably over a year, with three-fold or 10-fold differences between the lowest and highest periods (Fig. 5).

Figure 5.

 Examples of firefly population trends at two representative sites along the Selangor River for the year 2008, using an index of abundance based on the method described. Monitoring periods coincided with the new moon of each lunar cycle.


Application to monitoring of the Selangor River fireflies

The laboratory tests established that flash density in images of group displays was directly related to actual firefly density. In images taken at greater distance in the field, different operators readily identified flashes. Site, sampling period, or camera angle had very little impact on overall image interpretation, but subjectivity in the interpretation of the dimmest spots against background noise led to slight overall differences in counts between operators. The counts of different operators can, however, be standardised against a single operator.

Short exposure times increased variation in counts, depending on the level of synchrony with flash cycles, whereas longer exposure times increased the problem of movement of the fireflies. The choice of 0.5 s for P. tener enabled consistent capture of one or two flashes of the dominant males, which have a flash interval of about 0.27 s (Case, 1980). At this exposure time, double flashes usually registered as single bright spots, except during high winds.

In particle analysis, the green separation layer was better than the red even though red was a significant component of the light produced by P. tener, because there was also a strong red component in the background noise. As particle detection was continuous with no point of inflection in the curve when threshold was decreased, it could be inferred that some of the bright spots in the images contrasted only weakly with the background and no single threshold would reliably predict manual counts. However, manual counts had a linear relationship with particle analysis counts at a range of thresholds, providing overall intensity of bright spots was sufficient for detection. Images that had inadequate spot intensity generally occurred in distant sections of the river where the vegetation is viewed at an extreme angle, and could be recognised visually or by examining the green levels of bright spots in image editing software.

The relationship between manual and particle analysis counts varied with site and sampling period as a result of behavioural, environmental, and physical differences, precluding a universal prediction model. However, within sites and sampling periods, regression could still be applied with a high degree of accuracy to estimate counts based on three-point, zero-intercept regression lines. This greatly reduced handling time. Greater accuracy and less bias in the regression slope were achieved by selecting images with high particle analysis counts from a variety of camera angles. Very slight underestimation is expected as a result of selecting images with the highest counts, which tend to have slightly higher detection rates.

In tests of the comparability of counts from two cameras, the EOS 5DII registered the same flashes as the EOS 5D at shorter camera-subject distances, but registered more flashes than the EOS 5D at greater distances, requiring multiple regression with distance and particle parameters for cross-calibration of the cameras. The greater ability of the EOS 5DII to differentiate and to register subtle differences in flash brightness made manual count prediction from particle analysis possible under a wider range of flash intensities and camera-subject distances than in the EOS 5D. In addition, multiple linear regression could virtually eliminate the need for an estimate of the regression slope for each site each month. As digital camera sensors become more advanced, particle analysis has the potential to replace manual counts, enabling the processing of large numbers of images in a short time.

When used as a tool for monitoring the Selangor River firefly population, the technique provided an index of abundance that could be used to determine population trends, although biased towards the more dominant males, which display more consistently (Case, 1980). The effects of fluctuating flash patterns, which were probably related to behavioural changes in flash intensity and orientation (Case, 1980), were effectively minimised by panning the camera three times so that a time lapse of a minute or more occurred between replicate images. Errors due to flash behaviour, weather, and time of night are unlikely to affect interpretation of population trends because of the large area that could be monitored by this technique and the great differences in firefly abundance observed over time.

Application in the study of other light emitting organisms

The technique can be adapted to monitor a variety of firefly species and other light emitting organisms using the principles demonstrated in this case study. Where clear views from a stationary vantage point are not possible, it may be possible to hand-hold a camera at closer range and minimise effects of camera shake and variation by using a shorter exposure time.

The method described will also be a useful tool for the study of group display behaviour, supplementing conventional tools such as photomultipliers and oscilloscopes and having the advantage of enabling recognition of individual organisms, counts of numbers, and spatial analyses.

Advantages and limitations of the technique

Using this technique, large areas of habitat can be monitored in a short period of time with relatively inexpensive, consumer cameras. Other methods such as sweep netting (e.g. Zaidi et al., 2005) or visual counts through a cut-out window (Nallakumar, 2002) would not be able to monitor such large areas of habitat and are more likely to be affected by patterns of migration and local variation. The technique also enables more objective calibration for differences between operators, and is more quantitatively sensitive than visual scores of abundance.

Although the technique has few limitations, it does require a clear view of the display areas of the light emitting organisms, preferably from a stable platform. It also eventually requires carefully calibrated migration from one camera system to another for continuity.


Funding for this project was initially provided by the Department of Irrigation and Drainage, Malaysia in cooperation with DANIDA under the Integrated River Basin Management (IRBM) project, and subsequently by the Malaysian Economic Planning Unit. We are grateful to Mr Bo Christensen and Mr S. Mohamad Khairi for their interest and help in initiating the project. We are also thankful to our colleagues in FRIM for field and laboratory assistance, to Mr Raymond Lim of Olympus Soft Imaging Solutions (Kuala Lumpur) for software (macro) development, to the staff of Matrix Optics (Malaysia) for additional software support and to Canon Marketing (Malaysia) for the loan of test cameras. Last but not least, we thank Mr J. Abdul Razak and other members of the local community who live along the Selangor River for accommodating our work and for providing assistance.