You are on page 1of 6

International Symposium on Green & Sustainable Technology

ISGST 2014, UTAR Perak Campus, Malaysia, Sept 30 Oct 3, 2014

Segmentation and Detection of Activated Sludge Flocs in microscopic images


Keywords: Activated sludge, image processing, image segmentation

Activated sludge process is commonly used in wastewater treatment plants to process domestic or industrial effluent. The main
objects of interest in the activated sludge systems are flocs and the filamentous organisms. The proper settling of the sludge
flocs in the activated sludge wastewater treatment process is crucial to the normal functioning of the system. Sludge bulking
presents a common and persistent problem in wastewater treatment plants as it prevents the ability for flocs to settle down in
secondary clarifier of the plant. The conventional methods that detect this problem are time consuming and they give results
when very little time for precautionary measures is left. Hence image processing and analysis methods present potential
solutions to the long standing problem. In this paper image processing techniques are used to segment and detect activated
sludge flocs in microscopic images. This can help in the study of the morphology of individual flocs and their quantification.
Segmentation is one of the most important part of digital image processing. Good image segmentation is necessary for
identifying the objects of interest. In this paper, Otsu thresholding, K-means and C-means segmentation techniques are used to
segment and detect flocs in microscopic images of activated sludge. The performance of the segmentation techniques is
evaluated for activated sludge images at different microscopic magnifications using global consistency error (GCE) and
detection of number of flocs. Ground truth images are used to benchmark the accuracy of segmentation algorithms.

Activated sludge process is widely employed process
included in the secondary stage of wastewater treatment
plants to treat wastewater from domestic sewage or food
industry. The disturbances and abnormal state of Activated
sludge wastewater treatment process can be detected and
identified by morphology of flocs and filaments found in
mixed liquor samples from aeration basin of the plant
(Heine, et al. 2001) (Bizukojc 2005)(Mesquita, et al. 2013).
Image analysis has been extensively reported in the last
decade in context of morphology of flocs which has been
correlated with sludge volume index (SVI), mixed liquor
suspended solids (MLSS) and abnormal conditions like
filamentous bulking and pin flocs (Mesquita, et al. 2011).
Image segmentation is partitioning of the image into
significant regions which represent the objects of interest in
the image. A number of image segmentation techniques
have been reported in context of activated sludge process.
Histogram based thresholding using intermeans algorithm
was used by Jenne et al. for segmentation of flocs and
filaments (Jenne`, et al. 2003). Heine et al. employed image
enhancement and edge detection using gradient, followed
by thresholding (Heine, et al. 2001). Sikora and Smolka
reported that segmentation using analysis of low spatial
frequency components and thresholding perform poorly
because of irregular illumination (Sikora and Smolka 2001).
They also suggested floc segmentation using variance
operator and filament segmentation using Laplacian. As
another alternative, Sikora and Smolka used Cannys

algorithm followed by two level thresholding (Sikora and

Smolka 2001). The sequence of background correction,
histogram equalization, median filtering and morphological
operations was suggested by Perez et al. for floc
segmentation (Perez, et al. 2006). Lee et al. used watershed
algorithm for floc segmentation (Yong, et al. 2013). In this
paper we have used Otsu thresholding, k-means and cmeans segmentation for floc segmentation and evaluated
their performance for bright field microscopic images of
sample collected from aeration tanks of domestic
wastewater treatment plants.
Given a number of segmentation algorithms, it necessitates
a qualitative or quantitative assessment of the algorithms.
Here we have adopted the Global Consistency Error (GCE)
as performance metric because of its robustness to boundary
mismatch. The approximation of ground truth images has
been prepared manually and segmentation of an image is
assessed against respective ground truth using GCE.
Samples are collected from an experimental setup and a
domestic wastewater treatment plant. A drop of sample was
analysed under trinocular microscope with a coverslip.
Bright field microscopy was used to acquire the images
with resolution 20881550. In this work, images are
segmented without any enhancement technique. The study
gave us additional information about how the segmentation
techniques used are sensitive to the irregularity of
illumination. The segmentation algorithms are briefly

International Symposium on Green & Sustainable Technology

ISGST 2014, UTAR Perak Campus, Malaysia, Sept 30 Oct 3, 2014

presented in the following paragraphs.

Otsu Thresholding
The Otsu thresholding method is a commonly used
thresholding technique, suggested by Otsu (Otsu 1979).
With this method, a threshold value dividing the intensity
values into clusters/classes (2 for binary thresholding) that
produce the maximum between-class variance is searched
for among all the available intensity values. The square of
total variance T of an image is the sum of squares of




b (Otsu 1979).

2T = 2w + 2b
The total variance is a constant number for any image, and
a within-class variance that has a lowest value will cause
the between-class variance to be maximal. It can be
imagined that a threshold which maximizes b has
achieved an optimum clustering state, and hence this forms
the principle for the Otsu thresholding technique. The
following discriminant criterion (of the three criteria
suggested by Otsu) was used (Otsu 1979)

= b2
The optimum threshold will be the intensity at the index
where b is maximum.
K-means Segmentation
In k-means clustering, the objective is to partition the data
(intensity values) into k clusters that minimizes the withincluster sum of squares of Euclidean point-to-centroid
distance for all the clusters (Tatiraju and Mehta 2008). The
algorithm follows an iterative refinement technique as
1. Determine/initialize k number of values for k
number of clusters. They are known as cluster
2. Attribute each data point with the cluster centre
closest to it.
3. Calculate the mean of the data points within each
cluster. The means become the new cluster centres.
4. Repeat the above steps until convergence is
After convergence, the binary threshold value is to be taken
from the border intensity value of the clusters.
Fuzzy C-means Segmentation
The fuzzy c-means clustering assumes that every pixel
belong to each cluster to some extent specified by
membership function. The clustering is done iteratively to
minimize sum of square of point-to-centroid distance scaled
by membership function, summed over all clusters (Bezdec
1981). The algorithm flow is as follows:
1. Initial guess for cluster centres.
2. Assignment of membership functions to every
3. Update of centroids and membership function.
4. Repeat from step 2 above until the centroids have a
value change not larger than the termination

Segmentation Assessment Criteria

There are a number of metric found in literature to assess
the segmentation. The parameter is chosen depending upon
the particular aspect (such as size and shape etc) of the
image we are interested in. In order to assess the
segmentations in this paper, parameter of global consistency
error (GCE) has been used because of its robustness for
boundary errors. GCE can be effective metric of
segmentation of performance as long as the segmentation
algorithms are not distorting the shape of the objects and are
robust to irregular illumination of microscopic images. GCE
measured the consistency of segmentations with the gold
standard which was prepared by manual segmentation to
approximate the ground truth.
GCE was suggested by Martin (Martin, et al. 2001) and is
based on the idea that if all segmentation are refinement of
each other, GCE should have some minimum value. If
segmentation does not appear to be refinement of the other,
GCE should have higher value obviating that that the
segmentations are inconsistent. Let S1 and S2 are two
segmentations and R(S,pi) is some region in the
segmentation S, containing the pixel pi. If n is the number
of pixels, the GCE is given by (Martin, et al. 2001)

GCE= min

(1) and


{ E ( S , S , p ) , E(S , S , p )}

|R ( S a , pi ) / R ( Sb , pi )|
|R ( S a , pi )|

E ( S a , S b , pi ) =


is cardinality of set x and \ is the difference.

Experimental Results
The results in this paper are based on initial version of our
database which comprised of total 60 images: 26 at 4x, 15
at 10x, 14 at 20x and 5 at 40x magnification. The three
segmentation techniques which have been briefed in the
previous section were implemented. A database of images
of sample collected from wastewater treatment plants was
constructed at different objective magnifications of 4x, 10x,
20x and 40x. Ground truth images were prepared for the
images in order to assess the accuracy of segmentation. The
segmentation is evaluated against the respective ground
truth of each image. Global consistency error was used as
performance matric for the evaluation of the segmentation
accuracy. The results are depicted in the bar graph shown in
the figure.
The two results were observed in two perspectives:
performance of segmentation at each magnification and
effect of magnification on each segmentation algorithm. In
the first perspective, at each magnification, as obvious by
the figure 1(a), Otsu thresholding segmentation gave
minimum GCE at each magnification. Then k-mean global
thresholding performed better than fuzzy c-means at 4x and
10x magnification, but performed comparable with small
difference. It was observed that fuzzy c-means and k-means
segmentations are more sensitive to irregular illumination
than Otsu thresholding algorithm. Illumination can also
adversely affect the value of GCE as obvious from the
table. In the second perspective, fuzzy c-means appreciably

International Symposium on Green & Sustainable Technology

ISGST 2014, UTAR Perak Campus, Malaysia, Sept 30 Oct 3, 2014

performed better at 4x magnification than 10x, 20x and 40x

observations are not true in absolute terms as the nature of
magnifications. At higher magnifications, GCE increases
both illumination and segmentations are of stochastic
but the increase for fuzzy c-means and k-means
nature. For example, in the table 1, at 4x magnification, for
segmentations is more significant than Otsu. Actually Otsu
the image (b), GCE is greater for Otsu as compared to that
performs better at 40x magnification and appeared to be
for k-mean and fuzzy c-means. Similar is the case for image
less sensitive to irregularity in illumination. The
Table 1: Comparison of the segmentations (gray=true positive, green=false positive, magenta=false negative)

Original Image

Ground Truth

Fuzzy c-means


Otsu Thresholding


























International Symposium on Green & Sustainable Technology

ISGST 2014, UTAR Perak Campus, Malaysia, Sept 30 Oct 3, 2014




Figure 1: Mean GCE for fuzzy c-means, k-means and Otsu thresholding segmentations at different magnifications
Table 2: Total number of flocs detected by fuzzy c-means, k-means and Otsu thresholding segmentations at different

International Symposium on Green & Sustainable Technology

ISGST 2014, UTAR Perak Campus, Malaysia, Sept 30 Oct 3, 2014


Ground Truth

Number of flocs detected

Fuzzy c-mean

(a) at 40x magnification, though Otsu performed best at

40x. Furthermore, there can be possibly two sources of
error: irregular illumination and limited depth of field.
Finally, the segmentation techniques are compared on the
basis of number of flocs detected. Here only those flocs
were considered which contains more than 900 pixels. All
the techniques, except Otsu thresholding, detected less
number of flocs because some flocs are lost to the dark
areas of irregular illumination. In case of Otsu
Thresholding, the technique detected all the flocs in almost
all cases, but with detection of additional flocs which are
actually the because of dark areas of irregular illumination.

The performance of segmentation algorithms is different for
different microscopic magnifications. Otsu thresholding
segmentation performed better as compared to fuzzy cmean and k-means segmentation. At low magnification, the
three algorithms work fine, but performance of fuzzy cmeans and k-means segmentation was deteriorated. Preprocessing has not been included in this study to compare
the capability of the segmentation algorithms only. The
results obviate the extent of pre-processing required for
segmentation. The database of images has been constructed
to include diverse illumination and field of depth conditions
to make the results consistent. As future work, database is
being expanded to abnormal conditions of wastewater
treatment plant, new segmentation techniques are being
investigated and additional assessment metric is needed to
cater for irregular illumination.



Bizukojc, E.: Application of image analysis techniques in

activated sludge wastewater treatment processes.
Biotechnology Letters, 1427-1433 (2005)
Mesquita, D., Amaral, A., Ferreira, E.: Activated sludge
characterization through microscopy: A review on
quantitative image analysis and chemometric techniques.
Analytica Chimica Acta, 14-28 (2013)
Mesquita, D., Amaral, A., Fareira, E.: Identifying different
types of bulking in an activated sludge system through
quantitative image analysis. Chemoshpere, 643-652 (2011)
Jenne`, R., Banadda, E., Philips, N., Impe, J.: Image
analysis as a monitoring tool for activated sludge properties
in lab-scal installations. J Environ Sci Health A Tox Hazard
Subst Environ Eng., 2009-18. (2003)
Sikora, M., Smolka, B.: Feature analysis of activated sludge
based on microscopic images. In : Canadian conference on
Electrical and COmputer Engineering, pp.1309-1314 (2001)
Perez, Y., Leite, S., Coelho, M.: Activated sludge
morphology characterisation through an image analysis
procedure. Brazilian Journal of Chemical Engineering, 319
- 330 (2006)
Yong, L., Nisar, H., Yeap, K.: An Approach for the
Segmentation and Quantification of Activated Sludge Floc
Blobs. Advanced Science Letters (2013)


Otsu, N.: A threshold selection method from grayscale

histograms. IEEE Transactions on Systems, Man and
Cybernetics SMC-9(1), 62-66 (January 1979)

This work is supported by EScience Research Fund grant

funded by Ministry of Science Technology Innovation
(MOSTI), Malaysia (Project No. 06-02-11-SF0139).

Tatiraju, S., Mehta, A.: Image Segmentation using k-means

clustering, EM and Normalized Cuts. University Of
CaliforniaIrvine (2008)


Bezdec, J. C.: Pattern recognition with fuzzy objective

function algorithms.. Plenum Press, New York (1981)

Heine, W., Sekoulov, , Burkhardt, H., Bergen, L., Behrendt,

J.: Early warning system for operation failures in biological
stages of WWTPs by online image analysis. In : IWA
Conference, Berlin, pp.15-19 (2001)

Martin, D., Fowlkes, C., Tal, D., Malik, J.: A database of

human segmented natural images and its application to
evaluating segmentation algorithms and measuring
ecological statistics. In : Eighth IEEE International
Conference on Computer Vision, Vancouver, BC (2001)

International Symposium on Green & Sustainable Technology

ISGST 2014, UTAR Perak Campus, Malaysia, Sept 30 Oct 3, 2014