Method and related device for detecting color of activated sludge based on image recognition

By analyzing the color of activated sludge area images and comparing them with the preset distribution interval, the activated sludge color is solved, and the problem of low color detection accuracy in the prior art is solved, and a higher precision color recognition is achieved.

CN119169106BActive Publication Date: 2025-06-10BEIJING JINKONG DATA TECH +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411048814.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-01
Publication Date
2025-06-10
Estimated Expiration
2044-08-01

AI Technical Summary

Technical Problem

The existing activated sludge color detection method based on image recognition has the problem of small sample data sets and uneven distribution, resulting in low detection accuracy.

Method used

By obtaining the sedimentation cylinder image equipped with activated sludge, the activated sludge area is detected using the trained activated sludge detection model, the hue, saturation and brightness of each pixel point are calculated, and the distribution intervals corresponding to each color are compared to determine the color of activated sludge.

Benefits of technology

The accuracy of activated sludge color detection is improved, the problems of insufficient sample data sets and uneven distribution are solved, and more accurate activated sludge color recognition is achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119169106B_ABST
    Figure CN119169106B_ABST
Patent Text Reader

Abstract

The present application discloses a method and related device for detecting the color of activated sludge based on image recognition, which relates to the technical field of activated sludge color detection. The trained activated sludge detection model is used to detect the activated sludge area in the sedimentation cylinder image to obtain the activated sludge area image. The hue, saturation, and brightness of each pixel point in the activated sludge area of the activated sludge area image are calculated, and the hue, saturation, and brightness of all pixel points are respectively compared with the hue distribution interval, saturation distribution interval, and brightness distribution interval corresponding to each color to determine the color of the activated sludge. Thus, the color of the activated sludge is no longer predicted by the model, solving the problem that the activated sludge color sample data set is small and unevenly distributed, resulting in a small amount of data available for model training and inaccurate models, and improving the accuracy of activated sludge color detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of activated sludge color detection, and particularly to a method and related device for detecting the color of activated sludge based on image recognition. Background Art

[0002] At present, the main sewage treatment technologies at home and abroad are mainly biological methods. The activated sludge with a history of 100 years is still the core method used by many sewage treatment plants to treat sewage. Activated sludge is the general term for microbial populations and the organic and inorganic substances they adhere to. The performance of activated sludge directly affects the sewage purification effect. Timely detection of the performance of activated sludge is very important for analyzing the water purification efficiency and diagnosing and troubleshooting during failures.

[0003] There are many reasons affecting the performance of activated sludge, and the vast majority are mainly related to the flocs and zoogloea of activated sludge itself. Activated sludge generally contains hundreds of different types of main microorganisms and protozoa. Its activity and biomass, etc., as quality indicators reflecting the performance of activated sludge, can prove whether pollutants have been completely biochemically decomposed in the biological treatment stage. Researchers generally detect activated sludge flocs and microorganisms through microscopic examination. The overall operation is relatively complex and time-consuming, requires professional training, and is easily affected by the external environment and personal subjective factors, resulting in large detection errors.

[0004] Currently, image recognition and neural network technologies have developed rapidly and are applied in the field of sewage treatment. Activated sludge color detection plays an important role in instantaneously analyzing the activity of microorganisms in sludge, macroscopically detecting the performance of sludge, monitoring the sewage treatment process, and preventing the occurrence of sludge bulking accidents. Some researchers have developed an innovative method based on digital image processing. By analyzing the blue intensity in the image of the activated sludge culture medium under the same detection conditions such as light intensity, the biomass of activated sludge is quantified, and the types and activities of microorganisms in activated sludge are objectively and accurately analyzed, improving the traditional method for detecting the performance of activated sludge and enhancing the automation detection level of sewage treatment plants.

[0005] However, there are still some problems in the color detection of activated sludge based on image recognition: The currently publicly available activated sludge color sample datasets are few and unevenly distributed, resulting in a small amount of data available for model training, and there are problems with the accuracy of the model. Summary of the Invention

[0006] The purpose of the present application is to provide a method and related device for detecting the color of activated sludge based on image recognition, which can improve the accuracy of activated sludge color detection.

[0007] To achieve the above purpose, the present application provides the following solutions:

[0008] In a first aspect, the present application provides a method for detecting the color of activated sludge based on image recognition. The method for detecting the color of activated sludge based on image recognition includes:

[0009] Obtain an image of a sedimentation cylinder containing activated sludge; the image of the sedimentation cylinder includes the sedimentation cylinder, the supernatant and the activated sludge contained in the sedimentation cylinder, and the supernatant is located above the activated sludge;

[0010] Using the image of the sedimentation cylinder as input, use the trained activated sludge detection model to detect the activated sludge area in the image of the sedimentation cylinder to obtain an image of the activated sludge area;

[0011] For each pixel point in the activated sludge area of the activated sludge area image, calculate the hue, saturation and brightness of the pixel point, and compare the hue, saturation and brightness of all the pixel points with the hue distribution interval, saturation distribution interval and brightness distribution interval corresponding to each color respectively to determine the color of the activated sludge.

[0012] In a second aspect, the present application provides a device for detecting the color of activated sludge based on image recognition. The device for detecting the color of activated sludge based on image recognition includes:

[0013] An image acquisition module for obtaining an image of a sedimentation cylinder containing activated sludge; the image of the sedimentation cylinder includes the sedimentation cylinder, the supernatant and the activated sludge contained in the sedimentation cylinder, and the supernatant is located above the activated sludge;

[0014] An activated sludge area detection module for using the image of the sedimentation cylinder as input and using the trained activated sludge detection model to detect the activated sludge area in the image of the sedimentation cylinder to obtain an image of the activated sludge area;

[0015] A color determination module for calculating the hue, saturation and brightness of each pixel point in the activated sludge area of the activated sludge area image, and comparing the hue, saturation and brightness of all the pixel points with the hue distribution interval, saturation distribution interval and brightness distribution interval corresponding to each color respectively to determine the color of the activated sludge.

[0016] In a third aspect, the present application provides a computer device, including: a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor executes the computer program to implement the above-mentioned method for detecting the color of activated sludge based on image recognition.

[0017] In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the above-mentioned method for detecting the color of activated sludge based on image recognition.

[0018] In a fifth aspect, the present application provides a computer program product, including a computer program which, when executed by a processor, implements the above-mentioned method for detecting the color of activated sludge based on image recognition.

[0019] According to the specific embodiments provided by the present application, the following technical effects are disclosed:

[0020] The present application provides a method for detecting the color of activated sludge based on image recognition and related devices. The trained activated sludge detection model is used to detect the activated sludge area in the sedimentation cylinder image, obtaining the activated sludge area image. The hue, saturation, and brightness of each pixel point in the activated sludge area of the activated sludge area image are calculated, and the hue, saturation, and brightness of all pixel points are respectively compared with the hue distribution interval, saturation distribution interval, and brightness distribution interval corresponding to each color to determine the color of the activated sludge. Thus, the color of the activated sludge is no longer predicted by the model, solving the problem that the activated sludge color sample data set is small and unevenly distributed, resulting in a small amount of data available for model training and inaccurate models, and improving the accuracy of activated sludge color detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0022] Figure 1 It is an application environment diagram of a method for detecting the color of activated sludge based on image recognition provided in Embodiment 1 of the present application.

[0023] Figure 2 It is a schematic flowchart of a method for detecting the color of activated sludge based on image recognition provided in Embodiment 1 of the present application.

[0024] Figure 3 It is a schematic technical route diagram of a method for detecting the color of activated sludge based on image recognition provided in Embodiment 1 of the present application.

[0025] Figure 4 It is the U 2 -Net neural network structure diagram provided in Embodiment 1 of the present application.

[0026] Figure 5 It is the intermediate U 2 -Net neural network structure diagram provided in Embodiment 1 of the present application.

[0027] Figure 6 Schematic diagram of the improved U- 2 Net neural network provided in Embodiment 1 of the present application.

[0028] Figure 7 Schematic diagram of the multi-layer perceptron provided in Embodiment 1 of the present application.

[0029] Figure 8 Schematic diagram of the HSV distribution histogram of black sludge provided in Embodiment 1 of the present application; where Figure 8 (a) is the hue distribution histogram of black sludge; Figure 8 (b) is the saturation distribution histogram of black sludge; Figure 8 (c) is the brightness distribution histogram of black sludge.

[0030] Figure 9 Schematic diagram of the HSV distribution histogram of grayish-white sludge provided in Embodiment 1 of the present application; where Figure 9 (a) is the hue distribution histogram of grayish-white sludge; Figure 9 (b) is the saturation distribution histogram of grayish-white sludge; Figure 9 (c) is the brightness distribution histogram of grayish-white sludge.

[0031] Figure 10 Schematic diagram of the HSV distribution histogram of red sludge provided in Embodiment 1 of the present application; where Figure 10 (a) is the hue distribution histogram of red sludge; Figure 10 (b) is the saturation distribution histogram of red sludge; Figure 10 (c) is the brightness distribution histogram of red sludge.

[0032] Figure 11 Schematic diagram of the HSV distribution histogram of yellow sludge provided in Embodiment 1 of the present application; where Figure 11 (a) is the hue distribution histogram of yellow sludge; Figure 11 (b) is the saturation distribution histogram of yellow sludge; Figure 11 (c) is the brightness distribution histogram of yellow sludge.

[0033] Figure 12 Schematic diagram of the HSV distribution histogram of light brown sludge provided in Embodiment 1 of the present application; where Figure 12 (a) is the hue distribution histogram of light brown sludge; Figure 12 (b) is the saturation distribution histogram of light brown sludge; Figure 12 (c) is the brightness distribution histogram of light brown sludge.

[0034] Figure 13Schematic diagram of functional modules of an activated sludge color detection device based on image recognition provided in Embodiment 2 of this application.

[0035] Figure 14 Schematic diagram of the structure of a computer device provided in Embodiment 3 of this application. Detailed implementation manners

[0036] Next, the technical solutions in the embodiments of this application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this application.

[0037] Embodiment 1

[0038] The activated sludge color detection method based on image recognition provided in the embodiments of this application can be applied to an application environment as Figure 1 shown. Among them, the terminal communicates with the server through the network. The data storage system can store the data that the server needs to process. The data storage system can be set up separately, integrated on the server, or placed on the cloud or other servers. The terminal can send the sedimentation cylinder image to be processed to the server. After receiving the sedimentation cylinder image to be processed, for the sedimentation cylinder image to be processed, the server uses the trained activated sludge detection model to detect the activated sludge area in the sedimentation cylinder image to obtain the activated sludge area image; for each pixel point in the activated sludge area of the activated sludge area image, calculate the hue, saturation, and brightness of the pixel point, and compare the hue, saturation, and brightness of all pixel points with the hue distribution interval, saturation distribution interval, and brightness distribution interval corresponding to each color respectively to determine the color of the activated sludge. The server can feedback the obtained color of the activated sludge to the terminal.

[0039] In addition, in some embodiments, the activated sludge color detection method based on image recognition can also be implemented by the server or the terminal alone. For example, the terminal can directly process the sedimentation cylinder image to be processed, or the server can obtain the sedimentation cylinder image to be processed from the data storage system and process the sedimentation cylinder image to be processed.

[0040] As Figure 2 shown, an activated sludge color detection method based on image recognition is provided. This method is executed by a computer device, and can be specifically executed by a computer device such as a terminal or a server alone, or jointly executed by the terminal and the server. In the embodiments of this application, this method is applied to Figure 1Taking the server in [the relevant context] as an example for illustration, the method for detecting the color of activated sludge based on image recognition includes the following steps:

[0041] Step S1, obtain an image of a sedimentation cylinder containing activated sludge; the image of the sedimentation cylinder includes the sedimentation cylinder, and the sedimentation cylinder contains supernatant and activated sludge, and the supernatant is located above the activated sludge.

[0042] Step S2, using the image of the sedimentation cylinder as the input, utilize the trained activated sludge detection model to detect the activated sludge area in the image of the sedimentation cylinder, and obtain an image of the activated sludge area.

[0043] Step S3, for each pixel point in the activated sludge area of the image of the activated sludge area, calculate the hue, saturation, and brightness of the pixel point, and compare the hue, saturation, and brightness of all the pixel points with the hue distribution interval, saturation distribution interval, and brightness distribution interval corresponding to each color respectively to determine the color of the activated sludge.

[0044] By implementing the above steps S1 to S3, in this embodiment, the trained activated sludge detection model is used to detect the activated sludge area in the image of the sedimentation cylinder, obtain an image of the activated sludge area, calculate the hue, saturation, and brightness of each pixel point in the activated sludge area of the image of the activated sludge area, and compare the hue, saturation, and brightness of all the pixel points with the hue distribution interval, saturation distribution interval, and brightness distribution interval corresponding to each color respectively to determine the color of the activated sludge. Thus, the color of the activated sludge is determined by the hue, saturation, and brightness of each pixel point in the HSV color space, and the model is no longer used to predict the color of the activated sludge, solving the problem that the types and the foreground and background area distributions of the existing activated sludge color sample data sets are unbalanced, resulting in poor model accuracy, and realizing accurate and intelligent detection of the color of the activated sludge.

[0045] Staff often use the sedimentation cylinder method to detect the performance of activated sludge, that is, take an appropriate amount of mud-water mixture at the end of the outlet of the aeration tank in the sewage treatment plant and transfer it into a sedimentation cylinder, observe the phenomena in the sedimentation cylinder after standing, and conduct analysis. The aeration tank is the main biological treatment unit in the activated sludge treatment process. Sampling at the end of the aeration tank can monitor the biological treatment effect. Then in S1, put the mud-water mixture taken at the end of the outlet of the aeration tank in the sewage treatment plant into the sedimentation cylinder, let it stand to separate the water and the activated sludge, and then take a picture of the sedimentation cylinder. At this time, the sedimentation cylinder contains supernatant and activated sludge, and the supernatant is located above the activated sludge, obtaining an image of the sedimentation cylinder containing activated sludge. Subsequently, using the image of the sedimentation cylinder as the input, utilize the trained activated sludge detection model to detect the activated sludge area in the image of the sedimentation cylinder, and obtain an image of the activated sludge area.

[0046] Such asFigure 3 As shown, before using the trained activated sludge detection model to detect the activated sludge area in the sedimentation cylinder image with the sedimentation cylinder image as the input and obtaining the activated sludge area image, the activated sludge color detection method based on image recognition in this embodiment further includes:

[0047] (1) Obtain a sample set, which includes multiple sample sedimentation cylinder images containing activated sludge. The sample sedimentation cylinder images are taken under different light intensities.

[0048] To improve the robustness of the activated sludge detection model to external light changes and reduce the interference of the image background, as well as areas such as the scale lines and shadows of the sedimentation cylinder in the image on the activated sludge color detection, this embodiment selects the sample sedimentation cylinder images containing activated sludge taken under different light intensities provided by a certain company as the sample set. After expert analysis, it already contains the main activated sludge colors, including light brown, yellow, black, grayish white, and red. The first four correspond to activated sludge in different growth states, and red corresponds to a kind of cultivated and mature anaerobic ammonium oxidation sludge. These activated sludge colors cover a wide range and can intuitively reflect the state of activated sludge, having certain detection value.

[0049] (2) Perform image enhancement on the sample set to obtain an enhanced sample set. The image enhancement includes random scaling and random noise addition. The enhanced sample set includes multiple samples, and each sample includes a sample sedimentation cylinder image and an enhanced image. The enhanced image is the image obtained after performing image enhancement on the sample sedimentation cylinder image.

[0050] A total of 500 sample sedimentation cylinder images were screened out. Image enhancement was performed on each sample sedimentation cylinder image, mainly including random scaling and random noise addition operations, to obtain enhanced images. The sample sedimentation cylinder images and the enhanced images form an enhanced sample set to expand the sample set and improve the model generalization ability by simulating the image scanning process in the real situation. A total of 1000 samples were generated.

[0051] (3) For each sample, label the activated sludge area in the sample to obtain the label of the sample. The labeled activated sludge area is the inscribed rectangular area of the area where the activated sludge is located in the sample.

[0052] Use the Labelme software to label the activated sludge area in the samples. Consider the activated sludge area as the foreground and the rest as the background. Manually label the activated sludge area. Due to the line-of-sight angle, the lower boundary of the sedimentation cylinder in the image is generally arc-shaped, and the mud-water separation interface is generally elliptical and affected by light, resulting in a color difference compared with the true color of the activated sludge. To ensure the unity and accuracy of the activated sludge color recognition, select the inscribed rectangle part of the overall activated sludge area, which not only does not interfere with the next step of activated sludge color detection but also helps the initial activated sludge detection model learn and identify the activated sludge area.

[0053] (4) Combine all samples and the labels of each sample to form a dataset.

[0054] (5) Use the dataset to train the initial activated sludge detection model to obtain a trained activated sludge detection model.

[0055] Preferably, since there are a large number of samples in the enhanced sample set, a total of 1000, and the workload of fully annotating them is large, this embodiment adopts an iterative annotation method. Randomly select 100 samples, annotate them to form a training set, use the training set to train the initial activated sludge detection model. After training, obtain a trained model. Use the trained model to test the remaining 900 samples, screen out the samples with poor test results for the second-round annotation, add them to the training set again, and use the training set to retrain the initial activated sludge detection model until a trained activated sludge detection model that can accurately identify the activated sludge area can be generated.

[0056] This embodiment uses a U 2 -Net neural network to identify the activated sludge area. The U 2 -Net neural network consists of multiple groups of RSU (Residual U-blocks) and an external U-shaped structure connecting the RSU. Its traditional structure is as Figure 4 shown, which can achieve multi-level and multi-scale feature extraction of images as well as region recognition and segmentation tasks. Introducing the U 2 -Net neural network into the field of activated sludge area recognition can accurately identify and segment the activated sludge area. However, in the actual detection environment of activated sludge performance, due to the relatively deep structure of the U 2 -Net neural network, directly using it is likely to accumulate too many invalid features in the image, lose main information such as the edge of the activated sludge area, resulting in over-segmentation or under-segmentation problems of the activated sludge area in the image, causing the model to be unable to accurately obtain the activated sludge area and there being a systematic error in the activated sludge color detection. To address this problem, this embodiment makes appropriate improvements from two aspects: the U 2 -Net network structure and feature extraction to improve the accuracy of activated sludge area recognition.

[0057] (1) Network structure

[0058] U 2 -Net neural network mainly consists of an encoder and a decoder. Without affecting the model accuracy, appropriately streamline U 2 -Net neural network structure to improve the model's ability to extract shallow detail features of images. As Figure 5 shown, consider reducing U 2 -Net neural network's first-layer encoder and first-layer decoder, that is, remove Figure 4 the RSU-7 in it to remove redundancy and improve the model's feature extraction ability.

[0059] After reducing a group of RSU-7, the model size is greatly reduced. After training, verification and testing, the recognition accuracy of the activated sludge area reaches 90.63%. Compared with the original U 2 -Net neural network, the accuracy is increased by about 20%. In this embodiment, the U 2 -Net neural network before and after the structure improvement is used respectively (that is, the original U 2 -Net neural network and the intermediate U 2 -Net neural network) to identify the activated sludge area in an image, and it is found that the intermediate U 2 -Net neural network after the structure improvement overcomes the interference of detection background factors, avoids over-segmentation and under-segmentation problems, and the recognition of the activated sludge area is more accurate.

[0060] To further compare the improvement effect of network structure redundancy, continue to remove a group of RSU-6 on the basis of removing a group of RSU-7, and detect the region segmentation performance of the remaining network. Through experiments and analysis, after reducing a group of RSU-7 and a group of RSU-6, due to the 2 -Net neural network structure being too shallow, the image feature extraction and expression ability is insufficient, the model cannot capture more complex image features, and cannot learn richer feature representations. Finally, the recognition accuracy of the activated sludge area is compared with the original U 2 -Net neural network before improvement, and it has decreased by 1.94% instead. Therefore, in this embodiment, a group of RSU-7 is removed on the basis of the original U 2 -Net neural network as the basic model structure for identifying the activated sludge area.

[0061] (2) Feature extraction

[0062] As Figure 6 shown, in the intermediate U 2After each feature extraction stage of the -Net neural network, MLP (Multi-layer Perceptron) is fused to assist the model in further learning complex feature representations such as the texture of the activated sludge area. By enhancing the model's image understanding ability and region recognition ability, the learning ability of the activated sludge area is improved, enabling the model to overcome interference from multiple factors such as light and object shadows and accurately identify the activated sludge area.

[0063] By using the models before and after fusing MLP (i.e., the intermediate U 2 -Net neural network and the improved U 2 -Net neural network) to identify the activated sludge area in an image respectively, it is found that the improved U 2 -Net neural network after fusing MLP can avoid the interference of the shadow area in the image compared with the intermediate U 2 -Net neural network before fusing MLP, and the recognition effect of the activated sludge area is more accurate. Therefore, the improved structure of the designed U Figure 6 -Net neural network is used as the backbone of the activated sludge detection model. 2

[0064] MLP is a feedforward neural network. As one of the bases of modern artificial intelligence, it can be used as a component of a convolutional neural network in deep learning and computer vision. It transforms the input features into higher-level feature representations through hidden layers and learns the non-linear complex mapping relationship between the input data and the output data through activation functions. The basic structure of the multi-layer perceptron adopted in this embodiment is as Figure 7 shown.

[0065] The MLP structure design and idea in the activated sludge detection model are as follows:

[0066] (1) Input layer: Receive the sludge area feature maps from the RSU and flatten these feature maps into one-dimensional vectors.

[0067] (2) Hidden layer: Consisting of 128 neurons, it transforms the input features into higher-level feature representations; uses the ReLU activation function for non-linear transformation, introducing non-linearity and alleviating the vanishing gradient problem.

[0068] (3) Dropout layer (i.e., random inactivation layer): Apply the Dropout technique after the hidden layer to randomly discard (set to zero) the outputs of neurons with a certain probability, enhancing the generalization ability of the network and preventing overfitting.

[0069] (4) Output layer: Map the features transformed by the MLP back to the same number of features as the input sludge area feature maps, and then reshape them into the original spatial dimensions to be compatible with the subsequent network structure of the activated sludge detection model.

[0070] In S2, the trained activated sludge detection model uses the improved U 2 -Net neural network. The improved U 2 -Net neural network is obtained by improving the U 2 -Net neural network. The improvements include: removing the first-layer encoder and the first-layer decoder of the U 2 -Net neural network to obtain the intermediate U 2 -Net neural network; adding a multi-layer perceptron between adjacent two-layer encoders of the intermediate U 2 -Net neural network. Denote the adjacent two-layer encoders as the upper encoder and the lower encoder respectively. The input end of the multi-layer perceptron is connected to the output end of the downsampling layer, the input end of the downsampling layer is connected to the output end of the upper encoder, and the output end of the multi-layer perceptron is connected to the input end of the lower encoder; wherein, the multi-layer perceptron includes an input layer, a hidden layer, a dropout layer and an output layer connected in sequence.

[0071] Generally, the actual detection environment in a sewage treatment plant is relatively complex, with a lot of debris and various factors such as external light changes interfering. It is difficult to keep the conditions consistent like in a laboratory during on-site detection. To address the problem of the complex detection environment, the U 2 -Net neural network for salient object detection is introduced into the field of activated sludge area recognition. By streamlining the structure of the U 2 -Net neural network and deleting the first-layer encoder-decoder RSU-7, the model pays more attention to features such as the boundary of the activated sludge area, avoids losing key shallow information, and reduces the consumption of some computing resources, improving the detection efficiency of the activated sludge area. To address the problem that external light changes interfere with the color detection of activated sludge, a multi-layer perceptron is fused in each RSU of the intermediate U 2 -Net neural network, introducing a non-linear activation function and Dropout regularization technology, enabling the model to learn more robust feature representations to alleviate the gradient vanishing problem of the neural network, improving the generalization ability of the model, and improving the ability to identify the activated sludge area under different light intensities.

[0072] As redundant information in an image, noise exists in all links such as image acquisition, compression and transmission. The signal fluctuations generated interfere with the clarity and quality of the image, affecting subsequent image processing and analysis, and need to be prevented and removed. In this embodiment, several common image denoising methods are selected, including Gaussian filtering, mean filtering, median filtering and bilateral filtering. It is found by comparison that Gaussian filtering and mean filtering fail to remove most of the noise in the image of the activated sludge area, and the latter even makes the image blurrier; although bilateral filtering retains the image details, there are still many noise points remaining. In contrast, median filtering has the best denoising effect and does not affect the sludge color of the image of the activated sludge area. Therefore, median filtering is selected to smooth and denoise the image of the activated sludge area.

[0073] Before calculating the hue, saturation, and brightness of each pixel point in the activated sludge area for the image of the activated sludge area, the activated sludge color detection method based on image recognition in this embodiment further includes: using the median filtering algorithm to smooth and denoise the image of the activated sludge area to obtain a denoised image, and using the denoised image as the new image of the activated sludge area.

[0074] The HSV color space is a model that characterizes the color characteristics of the research object. It comprehensively describes the color of an object mainly through three attributes, namely hue (abbreviated as H), saturation (abbreviated as S), and value (abbreviated as V), which conforms to the color perception habit of the human eye. Aiming at the fact that the detection of activated sludge color is easily affected by factors such as light intensity and detection background, and the possible color gradient phenomenon of the activated sludge itself, this embodiment is based on the HSV interval statistical method, and uses the interval statistical method based on the three attributes (i.e., hue, saturation, and brightness) of the HSV color space to detect the activated sludge color. Hue represents the basic type of sludge color, saturation is used as an index of color purity to distinguish the colored components and colorless components in the sludge, and brightness reflects the light and dark degree of the sludge color. Moreover, the hue and saturation attributes are not affected by light changes and can maintain the consistency of sludge color characteristics. According to the set hue distribution interval, saturation distribution interval, and brightness distribution interval corresponding to each color, the color of the sludge area is detected to realize the automatic detection of sludge color based on image recognition.

[0075] In S3, for each pixel point in the activated sludge area of the activated sludge area image, calculating the hue, saturation, and brightness of the pixel point is to convert the activated sludge area image from the RGB color space to the HSV color space. The color space conversion formula (i.e., the calculation formula for hue, saturation, and brightness) is as follows:

[0076]

[0077] V = C max ;

[0078] Among them, H is the hue; S is the saturation; V is the brightness; R, G, and B are the values of the red, green, and blue components of the pixel point in the RGB color space respectively; the maximum value C max = max(R, G, B); the minimum value C min = min(R, G, B).

[0079] It should be noted that the activated sludge area image obtained by the trained activated sludge detection model is to frame the activated sludge area in the sedimentation cylinder image. Subsequently, the activated sludge area can be intercepted and then color detection can be performed. Of course, color detection can also be directly performed without intercepting the activated sludge area.

[0080] In S3, the hue, saturation, and brightness of all pixel points are respectively compared with the hue distribution interval, saturation distribution interval, and brightness distribution interval corresponding to each color to determine the color of the activated sludge, which specifically includes: for each pixel point, the hue, saturation, and brightness of the pixel point are respectively compared with the hue distribution interval, saturation distribution interval, and brightness distribution interval corresponding to each color to determine the color of the pixel point. If the hue, saturation, and brightness of the pixel point are all within the hue distribution interval, saturation distribution interval, and brightness distribution interval corresponding to the color, then the color of the pixel point is that color; determine the number of pixel points of each color, and select the color with the largest number of pixel points as the color of the activated sludge.

[0081] Before comparing the hue, saturation, and brightness of all pixel points with the hue distribution interval, saturation distribution interval, and brightness distribution interval corresponding to each color to determine the color of the activated sludge, the activated sludge color detection method based on image recognition in this embodiment further includes:

[0082] (1) Obtain the sample activated sludge area image corresponding to each color.

[0083] In this embodiment, the activated sludge of 5 colors is measured according to the training set. First, the training set is manually divided into 5 categories by color, and the activated sludge area is intercepted through the prediction result of the improved U 2 -Net neural network. Only the recognized activated sludge area is retained in the activated sludge area, and no background and other information are included, so as to obtain the sample activated sludge area image corresponding to each color and improve the accuracy of setting the HSV threshold of the sludge (that is, the hue distribution interval, saturation distribution interval, and brightness distribution interval corresponding to each color).

[0084] (2) For each color, perform the following steps:

[0085] (2.1) Calculate the hue, saturation, and brightness of each sample pixel point in the activated sludge area of the sample activated sludge area image corresponding to the color.

[0086] (2.2) Generate a hue distribution histogram based on the hue of all sample pixel points, and determine the hue distribution interval corresponding to the color based on the hue distribution histogram. The abscissa of the hue distribution histogram is the hue, and the ordinate is the number of sample pixel points.

[0087] (2.3) Generate a saturation distribution histogram based on the saturation of all sample pixel points, and determine the saturation distribution interval corresponding to the color based on the saturation distribution histogram. The abscissa of the saturation distribution histogram is saturation, and the ordinate is the number of sample pixel points.

[0088] (2.4) Generate a brightness distribution histogram based on the brightness of all sample pixel points, and determine the brightness distribution interval corresponding to the color based on the brightness distribution histogram. The abscissa of the brightness distribution histogram is brightness, and the ordinate is the number of sample pixel points.

[0089] Use the calcHist function to count the H, S, V distribution of each color, and generate the H, S, V distribution histograms of each color. As Figures 8 - 12 shown, they respectively correspond to the H, S, V distribution histograms of 5 colors. The abscissa of each graph represents hue, saturation, and brightness respectively, and the ordinate represents the number of pixel occurrences in the corresponding channel within the image.

[0090] From Figures 8 - 12 it can be seen that the H, S, V distribution of each color is as follows: for black sludge, the H value is distributed between 4 - 36 and 90 - 120, the S value is distributed between 20 - 255, and the V value is distributed between 3 - 50; for grayish-white sludge, the H value is distributed between 4 - 36 and 165 - 177, the S value is distributed between 2 - 40, and the V value is distributed between 41 - 150; for red sludge, the H value is distributed between 0 - 9, the S value is distributed between 173 - 250, and the V value is distributed between 25 - 150; for yellow sludge, the H value is distributed between 18 - 24, the S value is distributed between 206 - 255, and the V value is distributed between 28 - 150; for light brown sludge, the H value is distributed between 0 - 20, the S value is distributed between 50 - 200, and the V value is distributed between 28 - 130.

[0091] Thus, set the hue distribution interval, saturation distribution interval, and brightness distribution interval of the 5 colors. Subsequently, judge the color of the sludge according to the main distribution area of the sludge HSV attributes in the image, and realize the intelligent detection of the sludge color.

[0092] Aiming at the problems of the unbalanced distribution of the types and foreground and background regions in the existing activated sludge color sample data set, design a method for analyzing the color distribution of the activated sludge region based on the HSV interval statistical method. Set the hue, saturation, and brightness distribution intervals for sludge color detection through the sludge hue, saturation, and brightness distribution histograms, and realize the accurate and intelligent detection of the color of the activated sludge region under the condition of data set imbalance.

[0093] This embodiment introduces image segmentation into the field of activated sludge performance detection, and proposes an intelligent detection method for the color of activated sludge based on computer vision and artificial intelligence. The improved U 2-Net neural network identifies the activated sludge area in the image. By removing network redundancy and combining the MLP and Dropout regularization methods, the ability to extract and express the characteristics of the activated sludge area is improved. The regional recognition accuracy is increased by 25%, and the Dice is increased by 16.89%. The histograms of sludge hue, brightness, and saturation distribution in the HSV color space are used to determine the distribution intervals of the hue, brightness, and saturation of the sludge color. The color attribute distribution of the sludge area is detected by the HSV interval statistical method to identify the sludge color and analyze the corresponding performance of the sludge. The average accuracy rate of the main color detection of the sludge in this embodiment reaches more than 96%, basically realizing the intelligent detection and performance analysis of the activated sludge color in the actual environment. In the actual scenario of the sewage treatment plant, by identifying the sludge area and detecting the color, the microbial activity in the sludge is indirectly judged and the sludge performance is analyzed.

[0094] The following is an experimental analysis to verify the effectiveness of the method of this embodiment:

[0095] (1) Network training parameter settings

[0096] The computer configuration used for training the activated sludge detection model is Intel(R) Core(TM) i7-10750H CPU@2.60GHz, and the memory is 16G. The training parameter configuration of the improved U 2 -Net neural network is shown in Table 1. The total number of training epochs is set to 300, and the training batch size is 5. Adam (Adaptive Moment Estimation) is selected as the optimizer of the model. Its learning rate and other parameters determine the weight update step size. Too high or too low will both cause slow model training. In this embodiment, the learning rate is set to 0.001, the momentum parameter is set to (0.9, 0.999), and the precision is set to 1e-08, which is responsible for updating the model weights. The saving frequency is set to 100, and the model weights are saved every 100 iterations during the training process.

[0097] Table 1 Training parameter configuration table

[0098]

[0099]

[0100] (2) Automatic identification of the activated sludge area

[0101] Through the improved U 2- The -Net neural network automatically identifies the activated sludge area in the sedimentation cylinder image. Considering the scale of the training set and the actual size of the sedimentation cylinder, during the training process, the images are first uniformly scaled to 320*320 pixels and randomly cropped to 288*288 pixels to enrich the multi-scale information of the images and prevent model overfitting. After the training is completed, a set of weight files with smaller loss values is selected to test the remaining images.

[0102] Precision, Recall, Accuracy, and Dice are used as evaluation indicators of the model, and the formulas are as follows:

[0103]

[0104] Among them, t p is the number of pixels correctly identified as foreground in the image; f p is the number of pixels misidentified as foreground in the background area; f n is the number of pixels misidentified as background in the foreground area; t n is the number of pixels correctly identified as background.

[0105] Precision can measure the ability of the model to correctly predict the foreground, which is of great significance in scenarios where the cost of false positives is high. In the process of sludge color detection, if some background is mispredicted as the activated sludge area, the correct HSV interval cannot be output, which will affect the sludge color detection, and the cost of false positives is high. Therefore, the improved U 2 -Net neural network is used to improve the accuracy of area recognition. Its precision is 90.63%, which is about 20% higher than that before improvement. The recall rate is 99.54%, the accuracy is 99.34%, and the Dice is 94.83%. The accurate recognition of the sludge area can be basically achieved under complex detection backgrounds.

[0106] (3) Sludge area color detection and performance analysis

[0107] Aiming at the problems of light interference and sludge color gradient in the activated sludge image, the HSV interval statistical method is used to detect the color of the sludge area. After setting 5 HSV distribution intervals for sludge colors, the number of pixels of the sludge area color in each interval in the image to be tested is counted, and the activated sludge color is judged according to the interval with the largest number of pixels.

[0108] As shown in Table 2, the average accuracy of sludge color detection in the test set is 96%. According to the detected sludge color, the corresponding sludge-related performance can be analyzed, and the automatic detection of activated sludge color based on image recognition is basically realized.

[0109] Table 2 Analysis table of activated sludge color and performance

[0110]

[0111] Introducing intelligent detection of the color of activated sludge in the field of sewage treatment is a promising research direction for sludge performance analysis in the water treatment industry. The change in the color of activated sludge is generally related to factors such as the activity, type, and concentration of the sludge. An abnormal change in color can usually be used as an early signal of sludge performance or system failure. In this embodiment, intelligent detection and analysis of the sludge color are carried out by combining methods such as image processing, deep learning, and data analysis during the sewage treatment process. An improved U 2 -Net neural network and the HSV interval statistical method are used to design an intelligent detection process for the color of activated sludge, which can timely and accurately obtain the state of activated sludge, thereby assisting technicians in optimizing some equipment parameters in the sewage treatment process, improving the sewage treatment efficiency, and providing certain reference value for intelligent and low-cost rapid detection of sludge performance.

[0112] The embodiment of the present application also provides an application scenario that applies the above-mentioned method for detecting the color of activated sludge based on image recognition. Specifically, the method for detecting the color of activated sludge based on image recognition provided in this embodiment can be applied in the scenario of identifying the color of activated sludge. The scenario of identifying the color of activated sludge includes an image acquisition link and an image processing link. The image acquisition link is used to acquire an image of a settling cylinder containing activated sludge, and the image processing link is used to process the image of the settling cylinder containing activated sludge to obtain the color of the activated sludge. The method for detecting the color of activated sludge based on image recognition provided in this embodiment belongs to the image processing link.

[0113] Embodiment 2

[0114] Based on the same inventive concept, the embodiment of the present application also provides a device for detecting the color of activated sludge based on image recognition for implementing the above-mentioned method for detecting the color of activated sludge based on image recognition. The implementation solution provided by this device to solve the problem is similar to the implementation solution described in the above method. Therefore, the specific limitations in the embodiment of the device for detecting the color of activated sludge based on image recognition provided below can refer to the limitations on the method for detecting the color of activated sludge based on image recognition in the above text, and will not be repeated here.

[0115] As Figure 13 shown, a device for detecting the color of activated sludge based on image recognition is provided. The device for detecting the color of activated sludge based on image recognition includes:

[0116] An image acquisition module M1, configured to acquire an image of a settling cylinder containing activated sludge; the image of the settling cylinder includes a settling cylinder, and the settling cylinder contains supernatant and activated sludge, and the supernatant is located above the activated sludge.

[0117] The activated sludge area detection module M2 is used to take the sedimentation cylinder image as input, and use the trained activated sludge detection model to detect the activated sludge area in the sedimentation cylinder image to obtain an activated sludge area image.

[0118] The color determination module M3 is used to calculate the hue, saturation, and brightness of each pixel point in the activated sludge area of the activated sludge area image, and compare the hue, saturation, and brightness of all the pixel points with the hue distribution interval, saturation distribution interval, and brightness distribution interval corresponding to each color respectively to determine the color of the activated sludge.

[0119] Example 3

[0120] In an exemplary embodiment, a computer device is provided. The computer device can be a server or a terminal, and its internal structure diagram can be as Figure 14 shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store the sedimentation cylinder images to be processed. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with an external terminal through a network connection. The computer program is executed by the processor to implement a method for detecting the color of activated sludge based on image recognition.

[0121] Those skilled in the art can understand that Figure 14 the structure shown in

[0122] is only a block diagram of some structures related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.

[0123] Example 4

[0124] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the method for detecting the color of activated sludge based on image recognition described in Embodiment 1.

[0125] Embodiment 5

[0126] An embodiment of the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the method for detecting the color of activated sludge based on image recognition described in Embodiment 1.

[0127] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.

[0128] Specific examples are used in this article to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.

Claims

1. An activated sludge color detection method based on image recognition, characterized in that: The activated sludge color detection method based on image recognition comprises: Acquire an image of a sedimentation measuring cylinder containing activated sludge; the sedimentation measuring cylinder image includes a sedimentation measuring cylinder, the sedimentation measuring cylinder contains a supernatant and activated sludge, and the supernatant is located above the activated sludge; Taking the sedimentation measuring cylinder image as input, detecting the activated sludge area in the sedimentation measuring cylinder image using a trained activated sludge detection model to obtain an activated sludge area image; For each pixel point in the activated sludge area in the activated sludge area image, the hue, saturation and brightness of the pixel point are calculated, and the hue, saturation and brightness of all the pixel points are compared with the hue distribution interval, saturation distribution interval and brightness distribution interval corresponding to each color, respectively, to determine the color of the activated sludge; The trained activated sludge detection model adopts the improved U 2 -Net neural network; improved U 2 -Net neural network is a 2 -Net neural network is improved, including: removing U 2 -Net neural network’s first layer encoder and first layer decoder to obtain the intermediate U 2 -Net neural network; in the middle U 2 -A multilayer perceptron is added between two adjacent layers of encoders of the neural network, and the two adjacent layers of encoders are respectively recorded as an upper encoder and a lower encoder, the input end of the multilayer perceptron is connected to the output end of the downsampling layer, the input end of the downsampling layer is connected to the output end of the upper encoder, and the output end of the multilayer perceptron is connected to the input end of the lower encoder; wherein the multilayer perceptron includes an input layer, a hidden layer, a random inactivation layer, and an output layer connected in sequence; The hue, saturation and brightness of all the pixels are compared with the hue distribution interval, saturation distribution interval and brightness distribution interval corresponding to each color to determine the color of the activated sludge, specifically including: For each of the pixels, the hue, saturation and brightness of the pixel are compared with the hue distribution interval, saturation distribution interval and brightness distribution interval corresponding to each color, respectively, to determine the color of the pixel; if the hue, saturation and brightness of the pixel are all within the hue distribution interval, saturation distribution interval and brightness distribution interval corresponding to the color, then the color of the pixel is the color; The number of pixels of each color is determined, and the color with the largest number of pixels is selected as the color of the activated sludge.

2. The activated sludge color detection method based on image recognition according to claim 1, characterized in that: Before the activated sludge region in the sedimentation measuring cylinder image is detected using the trained activated sludge detection model using the sedimentation measuring cylinder image as input to obtain the activated sludge region image, the activated sludge color detection method based on image recognition further includes: Acquire a sample set; the sample set includes a plurality of images of sample sedimentation measuring cylinders filled with activated sludge, the sample sedimentation measuring cylinder images being taken under different light intensities; Performing image enhancement on the sample set to obtain an enhanced sample set; the image enhancement includes random scaling and random noise addition; the enhanced sample set includes a plurality of samples, the samples include a sample sedimentation measuring cylinder image and an enhanced image, and the enhanced image is an image obtained by performing image enhancement on the sample sedimentation measuring cylinder image; For each of the samples, an activated sludge region in the sample is marked to obtain a label of the sample; the marked activated sludge region is an inscribed rectangular region of the region where the activated sludge in the sample is located; Combining all the samples and the labels of each of the samples into a data set; The data set is used to train the initial activated sludge detection model to obtain a trained activated sludge detection model.

3. The activated sludge color detection method based on image recognition according to claim 1, characterized in that: Before comparing the hue, saturation and brightness of all the pixel points with the hue distribution interval, saturation distribution interval and brightness distribution interval corresponding to each color to determine the color of the activated sludge, the activated sludge color detection method based on image recognition further includes: Obtain an image of the sample activated sludge area corresponding to each color; For each color, follow these steps: Calculate the hue, saturation and brightness of each sample pixel point in the activated sludge area of ​​the sample activated sludge area image corresponding to the color; Generate a hue distribution histogram based on the hues of all sample pixel points, and determine the hue distribution interval corresponding to the color based on the hue distribution histogram; the abscissa of the hue distribution histogram is the hue, and the ordinate is the number of sample pixel points; A saturation distribution histogram is generated based on the saturation of all sample pixel points, and a saturation distribution interval corresponding to the color is determined based on the saturation distribution histogram; the abscissa of the saturation distribution histogram is the saturation, and the ordinate is the number of sample pixel points; A brightness distribution histogram is generated based on the brightness of all sample pixels, and a brightness distribution interval corresponding to the color is determined based on the brightness distribution histogram; the abscissa of the brightness distribution histogram is brightness, and the ordinate is the number of sample pixels.

4. The method for detecting color of activated sludge based on image recognition according to claim 1, characterized in that: Before calculating the hue, saturation and brightness of each pixel point in the activated sludge area of ​​the activated sludge area image, the activated sludge color detection method based on image recognition also includes: using a median filtering algorithm to smooth and reduce the noise of the activated sludge area image to obtain a denoised image, and using the denoised image as a new activated sludge area image.

5. An activated sludge color detection device based on image recognition, characterized in that: The activated sludge color detection device based on image recognition comprises: An image acquisition module is used to acquire an image of a sedimentation measuring cylinder containing activated sludge; the sedimentation measuring cylinder image includes a sedimentation measuring cylinder, the sedimentation measuring cylinder contains a supernatant and activated sludge, and the supernatant is located above the activated sludge; An activated sludge area detection module is used to detect the activated sludge area in the sedimentation measuring cylinder image using the sedimentation measuring cylinder image as input and to obtain an activated sludge area image using a trained activated sludge detection model; A color determination module is used to calculate the hue, saturation and brightness of each pixel point in the activated sludge area in the activated sludge area image, and compare the hue, saturation and brightness of all the pixels with the hue distribution interval, saturation distribution interval and brightness distribution interval corresponding to each color, so as to determine the color of the activated sludge; The trained activated sludge detection model adopts the improved U 2 -Net neural network; improved U 2 -Net neural network is a 2 -Net neural network is improved, including: removing U 2 -Net neural network’s first layer encoder and first layer decoder to obtain the intermediate U 2 -Net neural network; in the middle U 2 -A multilayer perceptron is added between two adjacent layers of encoders of the neural network, and the two adjacent layers of encoders are respectively recorded as an upper encoder and a lower encoder, the input end of the multilayer perceptron is connected to the output end of the downsampling layer, the input end of the downsampling layer is connected to the output end of the upper encoder, and the output end of the multilayer perceptron is connected to the input end of the lower encoder; wherein the multilayer perceptron includes an input layer, a hidden layer, a random inactivation layer, and an output layer connected in sequence; The hue, saturation and brightness of all the pixels are compared with the hue distribution interval, saturation distribution interval and brightness distribution interval corresponding to each color to determine the color of the activated sludge, specifically including: For each of the pixels, the hue, saturation and brightness of the pixel are compared with the hue distribution interval, saturation distribution interval and brightness distribution interval corresponding to each color, respectively, to determine the color of the pixel; if the hue, saturation and brightness of the pixel are all within the hue distribution interval, saturation distribution interval and brightness distribution interval corresponding to the color, then the color of the pixel is the color; The number of pixels of each color is determined, and the color with the largest number of pixels is selected as the color of the activated sludge.

6. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the activated sludge color detection method based on image recognition as described in any one of claims 1 to 4.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the activated sludge color detection method based on image recognition described in any one of claims 1 to 4 is implemented.

8. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the activated sludge color detection method based on image recognition described in any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Sewage grade identification method and device based on image

    CN115619998A

  • Color identification method based on template matching

    CN116403009A

  • Electrocardiogram sub-waveform identification method, system and equipment and storage medium

    CN117179780A