# Segmentation of Activated Sludge Flocs in Microscopic Images for Monitoring Wastewater Treatment

Authors: Ahmed Elaraby; Walid Hamdy; Humaira Nisar; Monagi H. Alkinani
Journal: Complexity
 (2022)

---

## Abstract

The proposed work describes an approach for segmentation of activated sludge flocs from the microscopic images for monitoring wastewater treatment. The morphological features of flocs (microbial aggregates) and filaments are related to the state of an activated sludge wastewater treatment plant and must be monitored for proper functioning. Hence, image processing and analysis could be a time-saving monitoring tool. To address this challenge, we propose a novel framework involving a multiphase edge detection algorithm based on information theory. The proposed framework is evaluated and scrutinized critically considering the artifacts found in the photographs tested. To evaluate the segmentations, gold approximation of estimated truth images is created. In addition, the performance was subjectively evaluated for its potential for segmenting activated sludge images. Experimental results show that the proposed framework exhibits the good results and demonstrates its effectiveness.


---

## Body

## 1. Introduction

In wastewater treatment plants, the activated sludge (AS) technique is extensively applied to handle both industrial and domestic effluent. Physico-chemical techniques, which are time-consuming, arduous, and have associated environmental concerns, are used to monitor the process’s performance [1]. The use of image processing and analysis to monitor AS in a wastewater treatment plant is a safe, time-effective, and semiautomated solution [2].The AS process’s efficiency is determined by the capacity of flocs to settle and the existence of bacteria named filamentous in the wastewater treatment plant’s secondary clarifier. Microbial aggregates made up of live and dead bacteria, as well as their metabolic products, are known as flocs [3]. In this publication, bacteria of filamentous are too referred as filaments. It uses a phase-contrast microscopy (PCM) picture of AS to show the visual representation of the flocs and filaments. The ability of a floc to settle is determined by its morphological structure. The backbone of the floc structure is made up of filaments [4].A floc’s compactness and, as a result, its ability to settle improve when filaments are present at a certain concentration [5, 6]. Consequently, the flocs do not settle adequately, impacting the AS wastewater treatment plant’s effluent quality. Image processing and analysis can be used to monitor and parametrize the morphology and quantification of the flocs and filaments. The overall length of filament, for example, is a critical metric that is determined through image processing [7]. It is utilized to model the sludge size index, which is one of the most critical AS process characteristics to track.In the last few decades, image processing has seen a substantial increase in its application and utilization. Image processing uses a variety of techniques and algorithms to edit images, such as image filtering, image segmentation algorithms, and image classification algorithms [8]. Using such techniques, you can extract a lot of relevant information from an image. Image processing has a wide range of uses, including medical, entertainment, and remote sensing [9]. The use of image processing in the field of activated sludge wastewater treatment was investigated in this research [10–12].Microscopy is required to detect the minute particles generated by bacteria during activated sludge wastewater treatment [13]. One sort of microscopy is phase-contrast microscopy, which converts phase changes in light passing through a transparent object into brightness changes in the image. The human eye is incapable of detecting phase alterations in light under normal conditions. Bright-field microscopy, on the other hand, converts phase changes into brightness variations that can be seen by the naked eye [14].By processing a microscopic image of a wastewater sample produced using phase-contrast microscopy, image processing can be used to segment and quantify filaments and flocs [15]. The performance of the image processing method, on the other hand, will be greatly determined by the algorithm employed to process the image. In this paper [3], image segmentation algorithms were researched and tested for their performance on filament segmentation and quantification, and one technique was used to segment and quantify flocs. The Bradley Thresholding, Sobel Edge Detection, and Laplacian Edge Detection Algorithms were utilized to segment filaments in this research [16], whereas the Otsu Thresholding technique was employed to segment and quantify flocs.To address this challenge, we present a novel framework based on information theory that includes a multiphase edge detection technique. The suggested framework is rigorously assessed and inspected in light of the artefacts discovered in the images examined. Gold approximation of estimated truth pictures is constructed to test the segmentations. Additionally, the performance was judged subjectively for its ability to partition activated sludge photos. The results of the experiments reveal that the suggested framework produces good outcomes and is effective.The goal of this study was to see how well each method performed at segmenting filaments. Aside from that, the project will look at employing image processing to quantify the flocs [17, 18]. This study was also conducted to better understand the impact of adjusting various parameters in image segmentation algorithms on the algorithms’ performance [19].In [20], they studied bright-field and phase-contrast microscopy pictures and utilized three techniques to segment and measure the flocs. Image segmentation using the Bradley local thresholding technique is the first way, texture segmentation using range filtering and Otsu’s thresholding is the second method, and segmentation using the Gaussian Mixture Method is the third method. In [21], they begin by explaining the background of image segmentation, as well as the methodologies and metrics used in image segmentation. Second, they go into the history of metalearning and provide a more detailed description of the term. The similarities and differences between metalearning and other related approaches are thoroughly compared. In [22], they proposed turning the challenge of detecting concave points into one of determining the relative location of a point and a linear equation. The relative location of a pixel point and a linear equation can be used to determine the pixel coordinates of concave points. The algorithm is simple to implement and runs quickly. Finally, they achieve a high accuracy rate of segmentation for the adhesion of two objects.


## 2. Proposed Methodology

In this section, we present description of the proposed framework that will be used for segmentation of activated sludge flocs and filaments in microscopic images for monitoring wastewater treatment. As illustrated in Figure1, the gradient image in the phase-contrast image comprises two types of edges: one amidst the halos and the background and the other amidst the halos and the foreground. The latter has a higher gradient value. As a result, we conclude that halo can be corrected by applying a gradient threshold. Thus, entropy thresholding was applied in the edge-based approach. Shannon finds the threshold automatically at first and then repeatedly tunes it to 1.4 for the last thresholding. The correction worker was necessary due to halos at the flocs’ edges and filaments being an artifact. Such parameters are used to fine-tune picture segmentation to deal with application-specific aberrations like halos. If we look closely at the halos, we can see that they have two edges. The foreground is one thing, while the flocs or filaments, which are considerably sharper, are another. As a result, the adjustment factor appears to be a natural technique to raise the gradient’s threshold to shrink the observed border toward filament or the flocs.Figure 1
Diagram segmenting and assessing bright-field images activated sludge (AS).There are multiple steps to this process. The image is first transformed into a grayscale image (MATLAB software). Second, using the proposed edge detection approach, the images are turned into gradient images. Third, the adjusted adjustment factor is used to binarize the gradient image. Fourth, the binary picture is overlaid on top of the grayscale images to sharpen the filament edges. Fifth, as previously said, the color gamut of the image with sharp edges and binary is obtained utilizing the default MATLAB technology’s threshold calculation. Finally, to fill minor discontinuities, we utilize the morphological operation of image closing.Because an image can be understood as an information source with the probability law given by its picture histogram, the Entropy idea becomes increasingly significant in image processing. In image processing, threshold approaches based on entropy have obtained a lot of attention in the previous several years. They have been discovered to be one of the most effective image segmentation algorithms. As a result, we present a method for segmentation that uses a two-phase threshold. The possibility behavior of sources of information is used to define entropy. Given eventse1,e2,…,ez occurring with a high probability p1,p2,…,pz being k the total number of states, ∑i=1zpi=1,0≤pi≤1.Shannon entropy is defined as follows:(1)Hp=−∑i=1kpilogpi.Using equation (1), we suggested a two-phase image thresholding strategy for edge detection that uses Shannon entropy for the global threshold of the input image and then for the local threshold. The Shannon entropy has a high quality when systems can be divided into two statistically independent subsystems X and Y (additively) SX+Y=SX+SY.Supposef(a, b) is the pixels gray value at point (a, b). In digital images fa,b|a∈1,2,…,M,b∈1,2,…,N with size M×N allow the histograms to be hg for g∈0,1,2,…,255 with f denoting the image’s amplitude (brightness) at the actual coordinated point (a, b). The collection of all gray levels is referred to as G for convenience. The gray level diagram of the images is typically used in global thresholding algorithms. The optimal t∗ is calculated by maximizing an appropriate standard function based on the gray-level distributed of the images and many different features. Assume that t represents a threshold values and R=r0,r1 been a paired of grayscale levels with r0,r1∈G. Perfectly, r0 and r1 are usually assumed to be 0 and 1, respectively. The consequence of applying a threshold on the function of an image fa,b at graying level t is a binaries function fta,b with the property fta,b=r0 if fta,b≤t; otherwise, fta,b=r1.A thresholding approach, in general, determines the valuet∗ of t using a criterion function. The thresholding method is point dependant if t∗ is chosen only by the gray level of every pixel [9]. A picture for z gray levels has a probability distributed as pi=p1,p2,…,pz. We may generate two probability distributions from this distribution, one for the item (class X) and then another into the background (class Y), as follows:(2)pX:p1PX,p2PX,…,ptPX,pY:pt+1PY,pt+2PY,…,pzPY,where PX=∑i=1tpi,PY=∑i=t+1zpiFor any distribution, the Shannon entropy can be calculated as follows:(3)SXt=−∑i=1tpXlnpX,SYt=−∑i=t+1zpYlnpY.Create a binary image initially in the proposed scheme by selecting a sufficient threshold value. The method entails processing each pixel of the original image and constructing a new image in such a way that the old image is no longer visible, such thatfta,b=0 if fta,b≤t∗α otherwise, that fta,b=1 for every for a∈1,2,…,M, for b∈1,2,…,N. When α⟶1, the value found by Shannon’s approach is the same as the threshold value in equation (2). To find the ideal threshold at α⟶1, use the following expression as a criterion function:(4)t∗=ArgmaxSαXt+SαYt.The diagram of the multiphase edge detection algorithm of image with activated sludge is shown in Figure2.Figure 2
Diagram of the multiphase edge detection algorithm of image with activated sludge.


## 3. Experimental Results

This section presents the experimental results of the achieved experiments and comparisons with various PCM images. The goal is to deliver the required discussions regarding the findings of this research work. To assess the proposed approach, various samples of PCM images were chosen randomly from databases content of 130 AS samples with a total of 4,048 images to determine its true processing abilities. This dataset comprised of AS processing samples that were either abnormal or normal. In addition, Canny algorithm is used in the comparison process as edge-based segmentation approach. The proposed algorithm and comparison algorithm were implemented using MATLAB 2018a with a computer with 4 GB of memory and a 2.8 GHz Intel Core I5-5 processor. Subjective and objective metrics were used as an additional way to measure the quality of the attained results.Table1 shows the confusion matrix and terminology used in performance evaluation. True positive (TP) pixel is categorized as foreground in-ground reality images but erroneously detected as background at segmentation images. True negative (TN) pixel is classified as background in-ground reality images but erroneously detected as foreground in segmentation images. False negative (FN) pixel is classified as foreground in-ground reality images but erroneously detected as background in segmentation images. False positive (FP) is defined as which the pixel is shown in-ground reality images as background but erroneously detected.Table 1
Confusion matrix.
ImagesGround truthSegmentedTrueFalseTrueTrue positiveFalse positiveFalseFalse negativeTrue negativeFPR is the percentage of background pixels in the ground truth images that are incorrectly identified as foreground. FNR is the percentage of foreground pixels in the ground truth picture that are incorrectly identified as background. The rate of all correctly identified pixels is known as accuracy. From equations (5)–(7), the equations are as follows:(5)accuracy=TN+TPTP+TN+FN+FP,(6)false negative rate=FNFN+TP,(7)false positive rate=FPFP+TN.Table2 compares the mean value of the segmentation assessment. The suggested approach is more accurate than the Canny technique, indicating that it is more sensitive to flocs. In comparison to the Canny technique, the proposed algorithm has a lower FNR and FPR. This indicates that the suggested technique is less likely to under- or oversegment flocs in photos, and it is more consistent than the Canny method when segmenting flocs from images.Table 2
Comparison of average segmentation assessment value.
ParameterFNRFPRAccuracy (%)Canny0.08870.147785.23Proposed model0.08650.134986.18Figure3 shows some sample segmentations of flocs in microscopic images of activated sludge. Experimental results shown in Figures 4–9 indicate the effectiveness of our proposed method.Figure 3
Gallery of some samples microscopic images of activated sludge.Figure 4
Image 1 segmentation results: (a) original image, (b) grayscale image, (c) segmentation results using Canny, and (d) segmentation results using our approach.
(a)(b)(c)(d)Figure 5
Image 2 segmentation results: (a) original image, (b) grayscale image, (c) segmentation results using Canny, and (d) segmentation results using our approach.
(a)(b)(c)(d)Figure 6
Image 3 segmentation results: (a) original image, (b) grayscale image, (c) segmentation results using Canny, and (d) segmentation results using our approach.
(a)(b)(c)(d)Figure 7
Image 4 segmentation results: (a) original image, (b) grayscale image, (c) segmentation results using Canny, and (d) segmentation results using our approach.
(a)(b)(c)(d)Figure 8
Image 5 segmentation results: (a) original image, (b) grayscale image, (c) segmentation results using Canny, and (d) segmentation results using our approach.
(a)(b)(c)(d)Figure 9
Image 6 segmentation results: (a) original image, (b) grayscale image, (c) segmentation results using Canny, and (d) segmentation results using our approach.
(a)(b)(c)(d)


## 4. Conclusion

In this paper, we proposed a new multiconcept algorithm for segmentation of activated sludge flocs in microscopic images for monitoring wastewater treatment efficiently manner by utilizing a combination of well-known processing concepts; the AS samples’ flocs and filamentous bacteria show a complicated structure. The algorithms are evaluated for their ability to segment flocs. From the experimental results, the proposed algorithm performed well. In addition, it showed superiority over the Canny segmentation algorithm.



---

*Source: 4347170-2022-05-11.xml*