Floc sensor prototype tested in the municipal wastewater treatment plant

A novel floc sensor prototype was tested in a Norwegian municipal wastewater treatment plant. The resulting images of flocs, captured using a specially designed software, were analysed by texture image analysis technique—grey level co-occurrence matrix (GLCM). The results of image analysis were merged with the coagulation process measurement data—inlet and outlet wastewater parameters. The data based only on GLCM textural features resulted in 96.6% explained total variance by two principal components and distinguished two classes in the data— low and high outlet turbidity values. The predicted by partial least squares regression (PLSR) coagulant dosages precisely followed the reference dosages, explained Y total variance by 3 factors equals 91.8% for calibration and 77.9% for validation. Results of the studies indicate that the GLCM method and sensor prototype can be used for an improvement of coagulant dosage control. Tested sensor prototype gives a solid basis for development of the low-cost floc sensor. Subjects: Water Quality; Environment & the City; Environmental Chemistry; Civil, Environmental and Geotechnical Engineering; Water Engineering; Water Science; Image Processing; Water Industries


ABOUT THE AUTHORS
The authors are members of Water, Environment, Sanitation and Health (WESH) research group at the Norwegian University of Life Sciences (NMBU), Faculty of Sciences and Technology (RealTek). WESH group focuses on water and wastewater related issues and is heavily involved in teaching and supervision of MSc and PhD programs in water engineering and technology. The group also has one of the largest externally funded research and educational project portfolios at RealTek, and collaborates with partners from EU, North America, Eurasia, Asia and Africa. It also has a number of Research, Development and Innovation projects with Norwegian partners. The main research and development areas of the WESH group are: process control and optimization of coagulation and biological treatment processes; membrane fouling and filtration processes; microbial water quality and risk assessment; decentralized wastewater systems; modelling of sewer systems.

PUBLIC INTEREST STATEMENT
Wastewater treatment plants use excessive amounts of chemicals (coagulants) to secure the precipitation and separation of water contaminants such as particles and phosphates. Advanced dosage control systems prevent overdosage and provide the required removal efficiencies of the impurities. However, such control systems usually require big investments and should rely on many expensive water quality sensors. A novel low-cost sensor prototype based on textural image analysis of the coagulated particles (flocs) was tested in the municipal wastewater treatment plant. Results obtained from the tests with a prototype give a basis for the actual floc sensor to be developed. The floc sensor would be suitable to improve the coagulation dosage control strategy and potentially will substitute some of the more expensive water quality sensors.

Introduction
Wastewater contains a significant amount of suspended and dissolved pollutants that create the need for its treatment before discharging into the environment. Coagulation is one of the methods in wastewater treatment to remove suspended solids, phosphates and other water contaminants. At first treatment plants, the quality control was done by manual water sampling after certain stages of treatment (Edzwald, 2010). The main problem with this approach was very long response time from sampling until obtaining the results making it impossible to adjust operating conditions to achieve optimal results. Nowadays, the flow-proportional dosing concept is usually used for coagulation process, while process optimisation often bases on the results from the jar tests (Ratnaweera & Fettig, 2015). Many modern wastewater treatment plants (WWTP) perform water quality control based on online measurements of water parameter (Vesilind, 2003). In this approach, the sampling and analysing of water parameters are typically automatized while process control is carried out by online monitors coupled with complicated optimal dosage control systems (Bourgeois, Burgess, & Stuetz, 2001;Ratnaweera, 2004). However, the operational cost of such monitors and control systems are very high. In addition, some of this equipment, for example, orthophosphate and total phosphate monitors, have an entirely long response time, because of the nature of phosphorus chemical analysis process. The characteristics of coming to the WWTP wastewater are changing dramatically within short periods, so the control systems, which require a longer time for the response, are not applicable for dosage control.
Advanced dosing control systems based on multiple water quality parameters that could be measured online have confirmed to be successful (Ratnaweera, 1997;VA-Support, 2012). Such systems enable a reduction in operational costs by lowering coagulant consumption, reduce the sludge volumes and maintain the desired removal of particles and phosphates (Manamperuma, Ratnaweera, & Rathnaweera, 2013;Manamperuma, Wei, & Ratnaweera, 2017). The need for wastewater treatment processes optimisation is growing and requires the development of accurate, robust, reliable and low-cost online dosing control systems (Ratnaweera & Fettig, 2015).
Raspberry Pi ® is a single-board computer which was created last decade and became popular because of its low price. It was previously used in the research projects as a data logger of the optical sensor for continuous marine monitoring and water quality monitoring . Raspberry Pi was also tested as an alternative to Programmable Logic Controller (PLC) for the automation of a small-scale water treatment plant (Lagu & Deshmukh, 2015).
During the last decades, image analysis techniques were often applied in water and wastewater treatment industry to determine such particles characteristics as floc size, fractal dimension, strength and breakage (Chakraborti, Atkinson, & Van Benschoten, 2000;Chakraborti, Gardner, Atkinson, & Van Benschoten, 2003;Jarvis, Jefferson, Gregory, & Parsons, 2005;Vlieghe, Coufort-Saudejaud, Frances, & Liné, 2014). However, their applicability has been limited to laboratory scale tests due to complicated and inaccurate measurements in the field, hardware and software limitations. Sievers et al. (2003) have developed an on-line method to optimize the sludge dewatering process. The method is based on CCD-line scan camera and image processing which measures the relative floc size distribution for the control of sludge dewatering. Juntunen, Liukkonen, Lehtola, and Hiltunen (2014) have studied the correlations between floc properties and the flocculation process parameters using an industrial camera and self-organizing maps. Particles' characteristics such as size, form and area were retrieved form the digital images of flocs was well as information about colour (average green, red, blue and colour index) and were used for modelling. The removal of suspended solids and colour from textile wastewater by coagulation was evaluated on-line using digital image analysis application (Yu, Chen, & Cheng, 2017). The authors measured mean grey value and mean red/green/blue values of the captured images in addition to particles' characterization parameters (e.g. particle size, area and fractal dimension). Recent review of sensor technologies for the energy-water nexus (Abegaz, Datta, & Mahajan, 2018) summaries the information about sensors used in the water sector and their costs. The authors emphasize a need for modern, remote and real-time sensor technologies as well as wireless sensor networks to achieve economic benefits in the energy-water nexus.
The new approach in image analysis of flocs-computing flocs characteristics on the images as textural features was proposed and tested (Sivchenko, Kvaal, & Ratnaweera, 2014, 2016Sivchenko, Ratnaweera, & Kvaal, 2017). Such method of image characterisation is comparatively easy since it analyses the whole image texture instead of calculating the shape characteristics of each particle in the image. The innovative extremely low-cost image acquisition system based on Raspberry Pi single-board computer and camera module was tested during the research. This paper presents the applicability of the concept for municipal wastewater treatment to be further developed into an actual sensor. The sensor is to be used for advanced dosage control to optimising the coagulation process.

Wastewater treatment plant
Full-scale tests were conducted in August 2016 at the Skiphelle wastewater treatment plant situated in city Drøbak-the centre of Frogn municipality in Akershus county, southeast part of Norway. Skiphelle WWTP receives municipal wastewater from Drøbak city and the neighbourhood area. Average inlet flow is 4,600 m 3 /day (14,000 pe) during the days without snowmelt and/or precipitations.
Skiphelle WWTP is a mechanical-chemical precipitation plant. The treatment process consists of the next stages: screens, two parallel pre-sedimentation basins, three sequenced coagulation chambers with the different velocity gradients, and two parallel sedimentation chambers. The plant also has the sludge dewatering and thickening system. The inlet and outlet water quality parameters are measured by online sensors and recorded (average values) with the 10 min interval. The data is available for observation in the plant's SCADA (Supervisory Control and Data Acquisition) system and through the DOSCON (DOSCON AS, Oslo, Norway) system. The retrieved water parameters included inlet wastewater flow (QIN), inlet pH (PHI), inlet turbidity (TUI), wastewater temperature (TMP), coagulant dosage (Dose), pH after coagulant dosage (PHO) and outlet turbidity (TUO). The plant operators perform daily sampling of inlet and outlet total Phosphorous (total P) in water. Total P was measured using DR3900 spectrophotometer and DRB200 reactor for digestion (Hach ® , USA). Wastewater flow was measured in open channel by the ultrasonic system consisting of an ultrasonic sensor 7005 and a flow converter 713 (MJK Automation, Xylem Inc., Denmark). Inlet and outlet pH was measured by two pHix Compact™ sensors (MJK Automation, Xylem Inc., Denmark). Inlet and outlet turbidity was measured by two VisioTurb ® 700 IQ sensors (YSI, USA). The coagulant was dosed by digitally controlled direct-drive diaphragm pump IX-C150TCR-RF-E (IWAKI Co., Ltd., Japan). The summarised data of water quality parameters for the tests period is given in Table 1. Coagulant used in the Skiphelle WWTP is polyaluminium chloride (ECOFLOCK 90, Feralco), 9 ± 0.3 % aluminium by weight, and density 1,356 ± 25 kg/m 3 .

Image acquisition and pre-processing
A special installation was designed to observe changes in flocs' structure online. The facility was set above the second flocculation chamber and consisted of the tube, peristaltic pump 620U (WMFTG, UK), acrylic cell for image acquisition, floodlight LED (anslut ® 427-624, 600 lumens) as a light source for a camera, Raspberry Pi with a camera module and the screen. The same system but with the DSLR camera was presented in the previous research paper (Sivchenko et al., 2017). The imaging cell was disassembled for cleanings with water each 2-3 days.
Raspberry Pi 2 Model B V1.1 single-board computer was chosen for its low price (35$ range), compact size and programmability. It is an affordable and perspective tool to be developed into the actual sensor. A low-cost (15$) camera module (5-megapixel OV5647 sensor) with the changeable focal length was mounted to the Raspberry Pi (Figure 1(a) and (b). A unique program was written in Python to control the camera and make changes in the camera settings. The interface of the application is shown in Figure 2. Using the program, it is possible to set specific needed parameters, such as camera settings (Figure 2(b)), the time lapse between the images and start time. In time lapse window (Figure 2(c)) option "Interval" means the time interval in seconds between the captured series of images. It was decided that one image might be not enough to represent the flocs structures. Hence, option "Picture count" indicates a number of images in series (three during this research) and option "Shotspeed" sets the time interval in seconds between the images in one set (5 s in this case). It is also possible to use the online camera mode and see the flocs movement through the cell on the monitor in real time. On demand, the video can be recorded choosing menu option "Record video" (Figure 2(a)).
Three images were captured every 10 min with the interval 5 s between the images (sets of images further in the text). The size of the image-capturing zone in the cuvette was 3.2 cm × 9.6 cm. In order to obtain flocs with the proper depth of field, the black metal stripe was placed in the centre of

(a) (b)
the cuvette, which also became a background for the flocs. The choice of the background colour was based on the fact that the wastewater flocs are greyish coloured. Thus, using a contrasting background, it is easier to perform the further image analysis.
The obtained images have a resolution of 5 megapixels each. They were processed in the open source image analysis software ImageJ v.1.49 (Rasband, 1997(Rasband, /2016) that based on plugins and macros. For each image 1360 × 1360 pixels (3 cm × 3 cm) area was cropped by manual investigation of the area.

Image analysis by Grey level co-occurrence matrix
GLCM is one of the methods to analyse texture in the image. Previously it was successfully tested on the laboratory scale basis with model wastewater (Sivchenko et al., 2016) and in full scale with municipal wastewater using an expensive DLSR camera (Sivchenko et al., 2017). The GLCM measurements can be further implemented and computed by Raspberry Pi board itself.
ImageJ plugin "GLCM Texture Too" v. 0.009 was used to obtain the GLCM feature vectors. The resulting output was given as a vector of the next four parameters per each image: Contrast, Entropy, Homogeneity and Variance. Hence, the data matrix was obtained with the size 588 × 4. The detailed description, explanation, and equations for above GLCM texture features can be found in the literature (Conners, Trivedi, & Harlow, 1984;Haralick, Shanmugam, & Dinstein, 1973;Zheng, Sun, & Zheng, 2006). GLCM textural features for two images in a set were averaged and used for calibration, while the textural information from the third image in a set was used for validation during principal component analysis (PCA).
Calibration data-set included inlet and outlet measurements of the coagulation process, coagulant dosage and corresponding 4 GLCM textural features of images of flocs (average values from 2 images for each 10 min process data). Validation data-set included inlet and outlet measurements of the coagulation process, coagulant dosage and corresponding 4 GLCM textural features of images of flocs (retrieved from the third image captured for the 10 min process data).
Three images for each 10 min were chosen to be representative. The measured GLCM feature vectors were averaged for every 2 images and matched with the retrieved water quality parameters. According to the tracer tests conducted in Skiphelle WWTP, the outlet turbidity values were 45 min shifted to meet the response lag between the coagulant injection point and outlet from the sedimentation tank. After the removal of missing values and outliers, the resulting data-set included 196 samples. In a real-world situation, the removal of outliers should be treated carefully due to a warning of unwanted conditions.

Multivariate statistical analysis and modelling
The resulted data matrix was processed in statistical software The Unscrambler® X 10.3 (CAMO Software AS, Norway) and in MATLAB using PLS toolbox (Eigenvector Research, Inc., USA). Principal component analysis (PCA) was performed to find the relationships between water quality parameters and images of flocs -GLCM feature vectors. PCA is a statistical data analysis technique to reduce the dimensionality of the data-set, overview and describe the interrelationships among variables and to find so-called hidden structures in the data. Partial least squares regression (PLSR) was performed to predict coagulant dosage based on the combination of water quality parameters and GLCM texture features. PLSR is a statistical regression method to model the response variable using a large number of predictor variables while those variables may highly correlate.

Results and discussion
Previously the three different texture image analysis systems applied to coagulation process were tested in the laboratory scale (Sivchenko et al., 2016). It was found that the textural information retrieved from the images of flocs is related to the coagulant dosages. Thus, the quantified information from the images of flocs can be used directly for the dosage prediction. Afterwards, the special installation for image acquisition was placed in the Skiphelle WWTP. The captured by a digital singlelens reflex (DSLR) camera images of flocs were used to predict the outlet turbidity values after sedimentation (Sivchenko et al., 2017). It was also shown that such image analysis technique could work as an early warning system of coagulation failure.
This work aimed to continue the development of a floc sensor prototype using cheap hardware available in the market. Since the difference in images resolution for Nikon D600 DSLR camera and Raspberry Pi camera module is significant, 24 and 5 MP, respectively, it was essential to check whether the last can produce flocs images of enough quality to use them for the coagulant dosage prediction.
The significant advantage of a Raspberry Pi computer is that it is entirely programmable and easy to control the camera module. It is also possible to develop a sophisticated self-standing system that includes image acquisition, storage and processing -all done in Raspberry Pi. Besides, the single-board computer has a Wi-Fi module, so the captured/processed information can be sent right away to the server, database cloud or remote PC.
During this research, the images of flocs were captured with the specified frequency and stored on the Raspberry Pi memory card, afterwards collected manually and processed on the remote PC. Here the results of analysed images of flocs by GLCM and corresponding them measurement data from the coagulation process are presented. The results of PCA performed for all inlet (QIN, TUI, PHI) and outlet (PHO, TUO) process measurements, 4 textural features of the flocs images and coagulant dosage in ml/s, are shown in Figure  3(b). Data class, which corresponds to the high outlet turbidities (marked in red), is better separated by two PCs. However, the data-set in this case included variable TUO. Even though the scores are visually separated better, the total explained variance of the data-set is much lower. Total explained variance for calibration: PC1 = 38.4%, PC2 = 55.9%, PC3 = 70.4%, PC4 = 79.7%; for validation: PC1 = 18.2%, PC2 = 29.9%, PC3 = 30.4%, PC4 = 60.8%.

Results of partial least squares regression
For the prediction of coagulant dosages the data matrix was divided into calibration and test data sets, 60 and 40% of the data, respectively. The data was divided based on the outlet turbidity values. The X matrix for PLSR included inlet wastewater parameters-QIN, TUI, PHI, TMP; after the dosage measurement PHO; an hour of the day; and GLCM textural features-Contrast, Entropy, Homogeneity and Variance. The response Y was coagulant dosage in ml/s. The PLSR model was calibrated on the data values which correspond to the outlet turbidity measurements between 1.9-5 FNU (desired range of effluent turbidity for the Skiphelle WWTP). The test data-set included measurements related to outlet turbidity values (TUO) higher than 5 FNU. Figure 4 shows the results of PLSR -coagulant dosage prediction. The continuous red line is the reference dose (dosages used in the WWTP). Black squares represent the dosage prediction of calibration data with corresponding TUO in a range 1.9-5 FNU. Black dots are the dosage predictions which correspond to TUO less than 1.9 FNU. Black diamonds are the dosage predictions which correspond to TUO above 5 FNU. Minimum desired value of effluent turbidity -1.9 FNU and maximum value 5 FNU are marked by dashed green lines, TUO min and TUO max, respectively.
Overall, the predicted coagulant dosages precisely follow the reference dosages. Prediction R 2 equals 0.92 for calibration and 0.78 for validation with three factors, root mean square error (RMSE) for calibration is 0.182 and 0.297 for validation. The area with high TUO represents a rain event, dosage was manually adjusted by plant operators and tend to be under-estimated. The predicted by PLSR model dosages (black diamonds, Figure 4) suggest having higher coagulant use for the wetweather period. Figure 5 represents the sample flocs images of three classes in the data-set -coagulation process conditions when resulting outlet turbidity was lower than 1.9 FNU, range of desired in the plant effluent turbidity 1.9-5 FNU and conditions lead to high TUO values (higher than 5 FNU). The actual values of TUO for the presented images are written in brackets. For each class, the average GLCM textural features are presented. The predicted coagulant dosages for the particular presented images of flocs are also shown.

Grey level co-occurrence matrix feature vectors
Investigating the average values of four GLCM parameters, it can be concluded that the images of flocs with higher Homogeneity (visually these flocs also seem to have a higher density) result in good treatment efficiency -low outlet turbidity measurements. Images of flocs with the higher Contrast, Entropy and Variance values point on the coagulation failure and require higher dosages of the coagulant. Visually such flocs are more separated from each other, and probably it results in worse sedimentation abilities of the flocs. However, the sedimentation rates of the different floc structures were not studied in this research.

Practical implications and further studies
The study shows a potential possibility of the floc sensor prototype to be developed into an actual sensor, based on textural image analysis of flocs. The sensor is to be used to improve an existing coagulant dosage control system. Raspberry Pi and the camera module are to be sealed into the waterproof stainless steel case and put directly into the coagulation chamber for online image analysis. The software in Raspberry Pi should be extended to include automated GLCM texture analysis algorithm and rewriting function of the stored images. The appropriate light source is also to be found and mounted next to the camera lens.