Background

Understanding the ecology and evolution of malaria vector species and populations is a key factor in controlling the disease they carry [1]. In several contexts, the estimation of the fitness of Anopheles mosquitoes is required. For instance, this may help to understand adaptation of different populations to given environmental conditions [24] or the opposite [57], interactions between the vectors and the parasites [812] or the vertebrate hosts [13]. More directly related to vector control, fitness measures can help deciphering the effect of insecticides [14], including new classes of insect growth regulators [15], effect of insecticide resistance [16, 17], genetic manipulation of vector populations to make them resistant to parasites [18, 19], or to impede their reproductive success. The fecundity is a key variable to assess the fitness of populations. In mosquitoes, it can be measured at several stages, but the number of eggs laid by females is often considered as a good estimate. Depending on the case study, the experiments may involve hundreds of females, possibly over many gonotrophic cycles and generations. As female Anopheles can lay over one hundred eggs every 2-3 days, one experiment only, often involves counting thousands of eggs [20, 21]. Such a task is obviously tedious, time-consuming and prone to errors. These facts make the identification and counting of eggs a natural task for automation.

As software capable of correctly counting Anopheles eggs laid on filter paper was not available, we developed a fully automatic software together with its own user-friendly interface. Egg-Counter v1.0 has the capacity of counting individual eggs as well as eggs laid in piles. At first, it counts the eggs laid on the paper, excluding the debris. Then, the user is able to modify any details of the presented result by means of a provided user-friendly interface. The software was tested by comparing the automatic and manually corrected results with the number of manually counted eggs, and a precision of 98% was obtained. Egg-Counter is fully written in Java and, therefore, completely platform-independent; it can be downloaded, installed and used within a couple of minutes.

The rest of this paper is organized as follows: In Methods, the proposed method for processing the images is elaborated. A brief description of the software provided and its features are introduced in Software. Experimental results on 16 different images, taken in different experiments are presented in Results and Discussion.

Methods

Figure 1 shows the diagram of the proposed algorithm for counting the eggs of an image. First the color image is converted to a grayscale by flattening the image. A binary map is extracted from the grayscale version of the image by means of image thresholding. Then, each connected component in the map is extracted as an object. To make the software as independent as possible from image resolutions and the camera settings, objects containing just one egg are detected and the size of one egg is estimated. Debris objects are detected and removed based on the original color image. Finally noise is removed and the number of eggs inside each of the remaining objects is calculated according to the estimated size of one egg.

Figure 1
figure 1

Proposed approach.

Grayscale Conversion

Color images are converted to grayscale images. Luminance is typically computed as a weighed sum of the color components. The most often used weights were originally developed for encoding analog color television signals as:

I i =0.299× R i +0.587× G i +0.144× B i ,
(1)

where R i , G i and B i are the intensity levels of the red, green, and blue channels of the ithpixel respectively. Figures 2(a) and 2(b) show a sample color image of the mosquitoes’ eggs and its resulting grayscale version.

Figure 2
figure 2

Sample image of the Anopheles eggs and resulting processed images.

Image Thresholding

As shown in Figure 2(b), the eggs and debris are the dark objects on the white paper. Therefore, a proper binary map of the image can be used to distinguish them from the background. This binary map is defined as:

B i = 1 , if I i T auto 0 , otherwise.
(2)

Where B i and I i are the binary value and intensity of the ithpixel respectively and T autois the automatic threshold value based on an entropic thresholding method proposed in [22] as:

arg max T C B (T)+ C F (T),
(3)

with

C B (T)=log g = 0 T p ( g ) p ( T ) 2 ,
(4)

and

C F (T)=log g = T + 1 T p ( g ) 1 p ( T ) 2 .
(5)

Where T auto is the value of T that makes C B (T) + C F (T) maximum, p(g) is the probability of intensity level g and p(T) is the cumulative probability function. Unlike the original method [22], here T controls the maximum value of threshold in order to remove high exposure in the images caused by flash where empirically T [160,180]. Figure 2(c) shows the resulting binary map of the sample image. As it is shown eggs and debris are properly extracted, after the automatic threshold is found.

Object Extraction

In this step eggs and debris are detected by extracting eight-connected neighborhood components. Putting it simply, connected component labeling is the process of assigning labels to the foreground elements in such a way that adjacent foreground elements are assigned to the same label [23]. Here, adjacent means 8-adjacent pixels neighborhood.

Egg Size Estimation

Usually, a single mosquito egg has an elongated ellipse shape, while a pile of eggs looks more circular (see Figure 2(b)). Therefore, the eccentricity of the object is used to distinguish single eggs from the piles of eggs. Eccentricity measures how much an object deviates from being circular. It is the ratio of the distance between the foci and its major axis length [24], defined as:

e= 1 λ 1 λ 2 ,
(6)
λ i = μ 20 + μ 02 2 ± 4 μ 11 + ( μ 20 μ 02 ) 2 2 .
(7)

Where μ mn is the central moment of order (m n), defined as:

μ mn = u , v R u x ̄ p v x ̄ q ,
(8)

where x ̄ , y ̄ is the centroid of the object and u , v R represents whole set of pixel coordinates inside the object. The value of the eccentricity falls in the interval [0,1]. A value of one indicates a perfect circle and zero indicates a line segment. In this step, the objects with high eccentricity, e 1<e<e 2, are selected as eggs. Values of e 1e 2can be set from 0.95 up to 0.99. Experimental results show that more than 80% of the components containing one egg are in this range. Finally, the mode of the size of the candidate objects is chosen as the estimated size for one egg.

Debris Detection

Debris are black regions extracted on the binary map (see Figure 2(b) and 2(c)) that could be assessed as eggs on the binary map. Nevertheless, a yellow brownish area often presents around the regions of debris (see Figure 2(a)) that can be used to detect debris. For extracting the brownish area near the debris, a chroma value for each pixel is defined as:

C i =max( R i , G i , B i )min( R i , G i , B i ).
(9)

In this step, the objects that have at least X pixels with C> C E in their radii r are considered as debris. Parameter C E is 0.15 by default, but the application allows the user to tune it, resulting in a change of the detection sensitivity. Because eggs have a dark color and the paper is white, the rate of true negatives (considering non-debris areas as debris) is negligible and it only happens for the eggs that are inside the yellow brownish area.

Egg Count and Noise Removal

The number of the eggs N inside the object i, is estimated as:

N(i)= A ( i ) S , A ( i ) 2 × S A ( i ) × C S , otherwise,
(10)

where A(i) is the area of the object, S is the estimated size of one egg, ∥.∥ is the round function and C is the accumulative ratio which should be less than one. The accumulative ratio is necessary due to the fact that regions in the intersection of the eggs inside a pile are shadowed by the eggs and are usually considered as a connected object in the binary map. Therefore, multiplying by this ratio allows better estimation of the number of eggs.

It should be mentioned that thresholding may produce noise, especially in the grid lines of the paper. There are many methods for noise reduction such as low-pass filters and other smoothing operators. However, these methods highly depend on the size of the filter. Here components smaller than half of the estimated size of one egg, are considered as noise in the Equation (10), and are removed.

Software

The algorithm explained above, has been implemented in Java as open source software. After the user opens an image, the software automatically computes the threshold value, detects and removes areas of debris, estimates the number of eggs inside each pile of the eggs and removes the noise. After that, the user is able to remove, add, and edit the automatically detected features by means of a user-friendly graphical interface. Figure 3 shows the basic graphical user interface of the software. The user can zoom, select single and/or multiple objects, modify their properties etc. and after each modification the total number of eggs is recalculated.

Figure 3
figure 3

Basic graphical user interface. Zoom utility signaled by ‘a’, and egg count by ‘b’.

Figure 4 shows advanced options of the software, which allows the user to change the sensitivity of the thresholding as well as the sensitivity of the debris detection process. Finally, the user can save the results as an image indicating the number of eggs beside each object as well as the total number of eggs. Figure 2(d) shows a sample output of the software, and Figure 2(e) shows the result after a small manually modification. The application estimated 103 eggs and, after manual modification, it showed 92 eggs. Corrections are mainly required on the debris areas without enough colorful pixels beside them, and eggs that fall in the neighborhood of debris areas.

Figure 4
figure 4

Advanced graphical user interface. ‘c’ signals the advanced features for changing the automatic threshold and chroma value. ‘b’ signals a manually corrected egg.

Results and Discussion

The software was tested over 16 randomly chosen images from 2 different experiments. Table 1 shows the number of the eggs estimated by the software; the result after manually correction; the ground truth; the time that the application took in seconds; and the average time for manually counting in minutes.

Table 1 Results of 16 different images

As it is shown in the error rate column, the precision of the software after a first correction is on average more than 98%, whereas the time saved is enormous. For image number 3, the automatic processing was very poor and the user had to manually set the sensitivity parameters. It should be mentioned that a proper sensitivity can be easily found by just adjusting a sliding bar. Manually counting all eggs of an image containing more than 500 eggs can take up to 30 minutes but, the same image, can be processed by Egg-Counter v1.0 in only a few seconds.

The results show that the proposed automatic method produces results that are close to the ground truth, and by making a few adjustments, mainly in the regions of debris and the paper’s grid lines, these results get even closer to the ground truth. Multiplying the time gained by the number of images and experiments, results in economizing an extremely large amount of time. The sensitivity value of the test results for assessing the eggs is around 0.945 in the fully automatic use of the software and is higher after a few mouse clicks. The specificity value, in this case, makes no sense since the true negatives are not actually known. Elimination of thousands of noise pixels during different stages of the analysis does not allow a reliable calculation of the specificity of the software. Positive predictive value of the test is set around 0.921 for the full automatic version.

The proposed algorithm works well, if eggs are clearly darker than the background paper, even if they are brown or another dark color. To introduce better and higher contrast and a wider color difference between the paper and laid eggs, we suggest using white or semi-white paper. In addition, it is highly recommended to take images with a camera of at least 5M pixels, using the lowest ISO and maximum shutter speed and avoiding re-sizing the images afterwards. Depending on your Laboratory lightning conditions, you might need to use a flash.

Conclusion

In this article, a promising new software package for automatically counting Anopheles eggs was presented. A very intuitive graphical user interface is available, that allows correction of the detection results, if needed. Additionally, in the parameters section of the interface it is possible to control the sensitivity to egg detection. Nevertheless, the proposed approaches involved in the processing of such images demonstrated a very high level of robustness, as it was shown by the results. The adoption of the proposed software package will save many hours of labor for the bench scientist.

Author’s contributions

Ali Mollahosseini, António dos Anjos and Hamid Reza Shahbazkia contributed with the proposed methods and software and Marie Rossignol, Cédric Pennetier, Anna Cohuet and Fabrice Chandre for testing and providing the necessary material. All authors read and approved the final version of the manuscript.