Active sludge color detection method based on image recognition and related device
Through the improved U2-Net neural network and multi-layer perceptron technology, combined with the distribution interval statistics method of HSV color space, the problems of insufficient data volume and uneven distribution in activated sludge color detection are solved, and the detection accuracy and accuracy are improved , realizes intelligent detection of activated sludge color.
Patent Information
- Application Number
- CN202411048814.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2044-08-01
AI Technical Summary
The existing activated sludge color detection method based on image recognition has few sample data sets and uneven distribution, resulting in insufficient data volume of model training, which in turn affects the detection accuracy.
By obtaining the sedimentation cylinder image equipped with activated sludge, the activated sludge area in the sedimentation cylinder image is detected using the trained activated sludge detection model, the hue, saturation and brightness of the pixel points are calculated, and the corresponding distribution is The intervals are compared, the color of activated sludge is determined, the structure and feature extraction of U2-Net neural network are improved, and the multi-layer perceptron and Dropout regularization technology is combined to improve the generalization ability and recognition accuracy of the model.
The accuracy and accuracy of activated sludge color detection have been improved, the problems of insufficient data volume and uneven distribution have been overcome, the accuracy and intelligent detection of activated sludge color have been achieved, and the automated detection level of sewage treatment plants has been improved.
Smart Images

Figure CN119169106A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of activated sludge color detection, and in particular to an activated sludge color detection method based on image recognition and related devices. Background Art
[0002] At present, domestic and foreign sewage treatment technologies are mainly based on biological methods. Activated sludge, which has a history of 100 years, is still the core method used by many sewage treatment plants to treat sewage. Activated sludge is a general term for microbial communities and the organic and inorganic substances they are attached 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 water purification efficiency and diagnosing and troubleshooting when faults occur.
[0003] There are many factors that affect the performance of activated sludge, most of which are mainly related to the flocs and bacterial flocs of the activated sludge itself. Activated sludge generally contains hundreds of different types of major microorganisms and protozoa. Their activity and biomass, as quality indicators of activated sludge performance, can prove whether the pollutants have been completely biochemically decomposed during the biological treatment stage. Researchers generally use microscopes to microscopically detect activated sludge flocs and microorganisms. The overall operation is complex and time-consuming, requires professional cultivation, and is easily affected by the external environment and personal subjective factors, resulting in large detection errors.
[0004] At present, image recognition and neural network technologies are developing rapidly and have been applied in the field of sewage treatment. Activated sludge color detection plays an important role in real-time analysis of microbial activity in sludge, macroscopic detection of sludge performance, monitoring of sewage treatment process and prevention of sludge bulking accidents. Some researchers have developed an innovative method based on digital image processing. Under the same detection conditions such as light intensity, by analyzing the blue intensity in the image of activated sludge culture medium, the activated sludge biomass is quantified, and the types and activities of microorganisms in activated sludge are objectively and accurately analyzed. The traditional activated sludge performance detection method is improved, and the level of automated detection in sewage treatment plants is improved.
[0005] However, there are still some problems with activated sludge color detection based on image recognition: the currently available activated sludge color sample data sets are small and unevenly distributed, resulting in a small amount of data available for model training and questions about the accuracy of the model. Summary of the invention
[0006] The purpose of this application is to provide an activated sludge color detection method and related device based on image recognition, which can improve the accuracy of activated sludge color detection.
[0007] To achieve the above objectives, this application provides the following solutions:
[0008] In a first aspect, the present application provides an activated sludge color detection method based on image recognition, the activated sludge color detection method based on image recognition comprising:
[0009] 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;
[0010] 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;
[0011] 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 range, saturation distribution range and brightness distribution range corresponding to each color to determine the color of the activated sludge.
[0012] In a second aspect, the present application provides an activated sludge color detection device based on image recognition, the activated sludge color detection device based on image recognition comprising:
[0013] 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;
[0014] 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;
[0015] 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 range, saturation distribution range and brightness distribution range corresponding to each color to determine the color of the activated sludge.
[0016] In a third aspect, the present application provides 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 above-mentioned activated sludge color detection method based on image recognition.
[0017] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned activated sludge color detection method 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 activated sludge color detection method based on image recognition.
[0019] According to the specific embodiments provided in this application, this application discloses the following technical effects:
[0020] The present application provides an activated sludge color detection method and related devices based on image recognition, which use a trained activated sludge detection model to detect the activated sludge area in the sedimentation cylinder image to obtain an activated sludge area image, calculate the hue, saturation and brightness of each pixel in the activated sludge area in the activated sludge area image, and compare the hue, saturation and brightness of all pixels with the hue distribution interval, saturation distribution interval and brightness distribution interval corresponding to each color to determine the color of the activated sludge, thereby no longer predicting the color of the activated sludge through 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 model, thereby improving the activated sludge color detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 This is an application environment diagram of an activated sludge color detection method based on image recognition provided in Example 1 of the present application.
[0023] Figure 2 A schematic flow chart of an activated sludge color detection method based on image recognition provided in Example 1 of the present application.
[0024] Figure 3 A schematic diagram of the technical route of an activated sludge color detection method based on image recognition provided in Example 1 of the present application.
[0025] Figure 4 U provided in Example 1 of the present application 2 -Schematic diagram of the structure of the neural network.
[0026] Figure 5 The intermediate U provided in Example 1 of the present application 2 -Schematic diagram of the structure of the neural network.
[0027] Figure 6 The improved U provided in Example 1 of the present application 2 -Schematic diagram of the structure of the neural network.
[0028] Figure 7 A schematic diagram of the structure of the multi-layer perceptron provided in Example 1 of the present application.
[0029] Figure 8 This is a schematic diagram of the HSV distribution histogram of black sludge provided in Example 1 of the present application; wherein, 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] Fig. 9 A schematic diagram of the HSV distribution histogram of gray-white sludge provided in Example 1 of the present application; wherein, Fig. 9 (a) is the hue distribution histogram of gray-white sludge; Fig. 9 (b) is the saturation distribution histogram of gray-white sludge; Fig. 9 (c) is the brightness distribution histogram of gray-white sludge.
[0031] Fig.10 This is a schematic diagram of the HSV distribution histogram of red sludge provided in Example 1 of the present application; wherein, Fig.10 (a) is the hue distribution histogram of red sludge; Fig.10 (b) is the saturation distribution histogram of red sludge; Fig.10 (c) is the brightness distribution histogram of red sludge.
[0032] Fig.11 A schematic diagram of the HSV distribution histogram of yellow sludge provided in Example 1 of the present application; wherein, Fig.11 (a) is the hue distribution histogram of yellow sludge; Fig.11 (b) is the saturation distribution histogram of yellow sludge; Fig.11 (c) is the brightness distribution histogram of yellow sludge.
[0033] Fig.12 This is a schematic diagram of the HSV distribution histogram of light brown sludge provided in Example 1 of the present application; wherein, Fig.12 (a) is the hue distribution histogram of light brown sludge; Fig.12 (b) is the saturation distribution histogram of light brown sludge; Fig.12 (c) is the brightness distribution histogram of light brown sludge.
[0034] Fig.13A schematic diagram of the functional modules of an activated sludge color detection device based on image recognition provided in Example 2 of the present application.
[0035] Fig.14 A schematic diagram of the structure of a computer device provided in Example 3 of the present application. DETAILED DESCRIPTION
[0036] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0037] Example 1
[0038] The activated sludge color detection method based on image recognition provided in the embodiment of the present application can be applied to Figure 1 In the application environment 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 the server receives the sedimentation cylinder image to be processed, for the sedimentation cylinder image to be processed, the server uses the sedimentation cylinder image as input, and 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 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 pixels 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. The server can feedback the color of the activated sludge obtained to the terminal.
[0039] In addition, in some embodiments, the activated sludge color detection method based on image recognition can also be implemented independently by a server or a terminal. 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] like Figure 2 As shown, a method for detecting color of activated sludge based on image recognition is provided. The method is executed by a computer device, and can be executed by a computer device such as a terminal or a server alone, or by a terminal and a server together. In the embodiment of the present application, the method is applied to Figure 1Taking the server in as an example, the activated sludge color detection method based on image recognition includes the following steps:
[0041] Step S1, obtaining 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.
[0042] Step S2, taking the sedimentation measuring cylinder image as input, and using the trained activated sludge detection model to detect the activated sludge area in the sedimentation measuring cylinder image to obtain an activated sludge area image.
[0043] Step S3, for each pixel point in the activated sludge area in 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 range, saturation distribution range and brightness distribution range corresponding to each color, to determine the color of the activated sludge.
[0044] The above-mentioned steps S1 to S3 are implemented. In this embodiment, 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, and the hue, saturation and brightness of each pixel in the activated sludge area in the activated sludge area image are calculated. The hue, saturation and brightness of all 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, thereby determining the color of the activated sludge by the hue, saturation and brightness of each pixel in the HSV color space. The model is no longer used to predict the color of the activated sludge, and the problem of poor model accuracy caused by the imbalanced distribution of types and foreground and background areas in the existing activated sludge color sample data set is solved, thereby achieving accurate and intelligent detection of the activated sludge color.
[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 aeration tank outlet of the sewage treatment plant and move it into the sedimentation cylinder. After standing, observe the phenomenon in the sedimentation cylinder and analyze it. 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. In S1, the mud-water mixture taken from the end of the aeration tank outlet in the sewage treatment plant is placed in the sedimentation cylinder. After standing to separate the water and activated sludge, the sedimentation cylinder is photographed. At this time, the sedimentation cylinder contains supernatant and activated sludge, and the supernatant is located above the activated sludge. The sedimentation cylinder image containing activated sludge is obtained. Subsequently, the sedimentation cylinder image is used as input, and the activated sludge area in the sedimentation cylinder image is detected using the trained activated sludge detection model to obtain an activated sludge area image.
[0046] like Figure 3 As shown, before the activated sludge area in the sedimentation measuring cylinder image is detected using the trained activated sludge detection model with the sedimentation measuring cylinder image as input to obtain 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 images of sample sedimentation measuring cylinders filled with activated sludge, wherein the sample sedimentation measuring cylinder images are taken under different light intensities.
[0048] In order to improve the robustness of the activated sludge detection model to external lighting changes and reduce the interference of the image background and the sedimentation cylinder scale lines and shadows 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 company as the sample set. According to expert analysis, the main activated sludge colors are included, including light brown, yellow, black, gray and red. The first four correspond to activated sludge in different growth states, and red corresponds to a mature anaerobic ammonia oxidation sludge. These activated sludge colors cover a wide range, can intuitively reflect the state of activated sludge, and have certain detection value.
[0049] (2) Performing image enhancement on the sample set to obtain an enhanced sample set, wherein the image enhancement includes random scaling and random noise addition, and the enhanced sample set includes a plurality of samples, wherein the samples include a sample sedimentation measuring cylinder image and an enhanced image, and the enhanced image is an image obtained after performing image enhancement on the sample sedimentation measuring cylinder image.
[0050] After sorting, a total of 500 sample sedimentation measuring cylinder images were screened out, and image enhancement was performed on each sample sedimentation measuring cylinder image, mainly including random scaling and random noise operations, to obtain the enhanced image. The sample sedimentation measuring cylinder image and the enhanced image constitute the enhanced sample set to expand the sample set. By simulating the image scanning process in real conditions, the sample set was appropriately expanded to improve the generalization ability of the model. A total of 1000 samples were generated.
[0051] (3) For each sample, the activated sludge area in the sample is marked to obtain a label of the sample. The marked activated sludge area is the inscribed rectangular area of the area where the activated sludge in the sample is located.
[0052] Labelme software was used to annotate the activated sludge area in the sample. The activated sludge area was regarded as the foreground and the rest of the area as the background. The activated sludge area was manually annotated. Due to the line of sight, the lower boundary of the sedimentation cylinder in the image was generally arc-shaped, and the mud-water separation interface was generally elliptical and affected by light, resulting in color difference compared with the real color of the activated sludge. In order to ensure the uniformity and accuracy of activated sludge color recognition, the inscribed rectangular part of the entire activated sludge area was selected to annotate, which neither interfered with the next step of activated sludge color detection nor facilitated the initial activated sludge detection model to learn and identify the activated sludge area.
[0053] (4) All samples and the labels of each sample form a data set.
[0054] (5) The initial activated sludge detection model is trained using the data set 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 1,000 samples, the workload of labeling all of them is very heavy, so this embodiment adopts an iterative labeling method, randomly selects 100 samples, labels them, and makes a training set. The initial activated sludge detection model is trained using the training set. After the training, the trained model is obtained, and the remaining 900 samples are tested using the trained model. Samples with poor test results are screened for a second round of labeling and added to the training set again. The initial activated sludge detection model is trained again using the training set until a trained activated sludge detection model that can accurately identify the activated sludge area can be generated.
[0056] This embodiment adopts U 2 -Net neural network identifies activated sludge areas, U 2 -Net neural network consists of multiple groups of RSU (Residual U-blocks) and an external U-shaped structure connecting the RSUs. Its traditional structure is as follows Figure 4 As shown in the figure, it can realize the image multi-level, multi-scale feature extraction and region recognition and segmentation tasks. 2 -Net neural network is introduced into the field of activated sludge area recognition, which can accurately identify and segment the activated sludge area. However, in the actual detection environment of activated sludge performance, due to the U 2 -Net neural network structure is deep, and direct use is prone to accumulate too many invalid features in the image, lose the main information such as the edge of the activated sludge area, and cause the problem of over-segmentation or under-segmentation of the activated sludge area in the image, resulting in the model being unable to accurately obtain the activated sludge area, and there is a systematic error in the color detection of activated sludge. To address this problem, this embodiment uses U 2 -Net network structure and feature extraction are appropriately improved to improve the accuracy of activated sludge area identification.
[0057] (1) Network structure
[0058] U 2 -Net neural network is mainly composed of two parts: encoder and decoder. Under the premise of not affecting the accuracy of the model, U 2 -Net neural network structure can improve the model's ability to extract shallow detail features of images. Figure 5 As shown, consider reducing U 2 -Net neural network’s first encoder and first decoder, i.e., removing Figure 4 In RSU-7, redundancy is removed to improve the feature extraction capability of the model.
[0059] After reducing a group of RSU-7, the model size is greatly reduced. After training, verification and testing, the accuracy of activated sludge area recognition is 90.63%, which is comparable to the original U 2 -Net neural network, the accuracy is improved by about 20%. 2 -Net neural network (i.e. original U 2 -Net neural network and intermediate U 2 -Net neural network) to identify the activated sludge area in an image and find the intermediate U 2 -Net neural network overcomes the interference of detection background factors, avoids over-segmentation and under-segmentation problems, and identifies activated sludge areas more accurately.
[0060] In order to further compare the improvement effect of network structure redundancy, we remove one group of RSU-7 and then remove one group of RSU-6 to test the regional segmentation performance of the remaining network. 2 -Net neural network structure is too shallow, resulting in insufficient image feature extraction and expression capabilities. The model cannot capture more complex image features and cannot learn richer feature representations. The final accuracy of activated sludge area recognition is comparable to that of the original U 2 -Net neural network, but it dropped by 1.94%. Therefore, this embodiment chooses to 2 -Net neural network based on the removal of a group of RSU-7 as the basic model structure for identifying the activated sludge area.
[0061] (2) Feature extraction
[0062] like Figure 6 As shown, in the middle U 2-Net neural network is integrated with MLP (Multi-layer Perceptron) after each feature extraction stage to assist the model in further learning more complex feature representations such as the texture of the activated sludge area. By enhancing the model's image understanding and regional recognition capabilities, the model's learning ability for the activated sludge area is improved, enabling the model to overcome interference from multiple factors such as lighting and object shadows, and more accurately identify the activated sludge area.
[0063] By fusing the models before and after MLP (i.e., the middle U 2 -Net neural network and improved U 2 -Net neural network) to identify the activated sludge area in an image, and found that the improved U 2 -Net neural network compared to the intermediate U before fusion MLP 2 -Net neural network avoids the interference of shadow areas in the image, and the recognition effect of activated sludge area is more accurate. Figure 6 Designed by U 2 -Net neural network improved structure as the backbone of the activated sludge detection model.
[0064] MLP is a feedforward neural network. As one of the foundations of modern artificial intelligence, it can be used as a component of convolutional neural networks in deep learning and computer vision. It converts input features into higher-level feature representations through hidden layers and learns the nonlinear complex mapping relationship between input data and output data through activation functions. The multi-layer perceptron used in this embodiment has a basic structure as follows: Figure 7 shown.
[0065] The MLP structure design and ideas in the activated sludge detection model are as follows:
[0066] (1) Input layer: Receives sludge area feature maps from RSU and flattens them into one-dimensional vectors.
[0067] (2) Hidden layer: It consists of 128 neurons, which convert the input features into higher-level feature representations; it uses the ReLU activation function for nonlinear transformation, introduces nonlinear characteristics and alleviates the gradient vanishing problem.
[0068] (3) Dropout layer (i.e., random inactivation layer): Dropout technology is applied after the hidden layer to randomly discard (set to zero) the output of neurons with a certain probability, thereby enhancing the generalization ability of the network and preventing overfitting.
[0069] (4) Output layer: The MLP-transformed features are mapped back to the same number of features as the input sludge region feature map, and then reshaped to 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, 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 -Net neural network, add a multilayer perceptron between two adjacent layers of encoders, record the two adjacent layers of encoders as upper encoder and lower encoder respectively, 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.
[0071] Usually, the actual detection environment of sewage treatment plants is complex, with many debris and interference from various factors such as external light changes. It is difficult to maintain the same conditions as in the laboratory during on-site detection. In order to solve the problem of complex detection environment, U 2 -Net neural network is introduced into the field of activated sludge area identification, by simplifying U 2 -Net neural network structure, delete the first layer codec RSU-7, so that the model pays more attention to the features such as the boundary of the activated sludge area, avoids the loss of shallow key information, and reduces some computing resource consumption, thus improving the detection efficiency of the activated sludge area. 2 -Net neural network integrates multi-layer perceptrons in each RSU, introduces nonlinear activation functions and Dropout regularization technology, so that the model can learn more robust feature representations to alleviate the gradient vanishing problem of the neural network, improve the generalization ability of the model, and improve the ability to identify activated sludge areas under different light intensities.
[0072] Noise is redundant information in the image and exists in various links such as image acquisition, compression and transmission. The signal fluctuations generated interfere with the clarity and quality of the image and affect the subsequent image processing and analysis, which need to be prevented and removed. This embodiment selects several common image noise reduction methods, including Gaussian filtering, mean filtering, median filtering and bilateral filtering. Comparison shows that Gaussian filtering and mean filtering fail to remove most of the noise in the activated sludge area image, and the latter makes the image more blurred; although bilateral filtering retains the image details, there are still many noise points. In contrast, median filtering has the best noise reduction effect and does not affect the sludge color of the activated sludge area image, so median filtering is selected to smooth and reduce the noise of the activated sludge area image.
[0073] Before calculating the hue, saturation and brightness of each pixel in the activated sludge area of the activated sludge area image, the activated sludge color detection method based on image recognition in this embodiment 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.
[0074] HSV color space is a model for characterizing the color characteristics of the research object. It mainly describes the color of the object through three attributes, namely hue (Hue, referred to as H), saturation (S) and brightness (V), which conforms to the color perception habits of the human eye. In view of the fact that the color detection of activated sludge is easily affected by factors such as light intensity and detection background, as well as the color gradient phenomenon that may exist in the activated sludge itself, this embodiment is based on the HSV interval statistics method, and uses the interval statistics method based on the three attributes of the HSV color space (i.e., hue, saturation and brightness) to detect the color of the activated sludge. Hue represents the basic type of sludge color. Saturation, as a color purity index, can distinguish between colored and colorless components in the sludge. Brightness reflects the brightness of the sludge color. Moreover, the hue and saturation attributes are not affected by changes in light, and can maintain the consistency of the sludge color characteristics. According to the hue distribution interval, saturation distribution interval and brightness distribution interval corresponding to each color set, the color of the sludge area is detected, and the automatic detection of sludge color based on image recognition is realized.
[0075] In S3, for each pixel in the activated sludge area of the activated sludge area image, the hue, saturation and brightness of the pixel are calculated, which 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 of hue, saturation and brightness) is as follows:
[0076]
[0077] V=C max ;
[0078] Among them, H is hue; S is saturation; V is brightness; R, G, B are the values of the red, green, and blue components of the pixel in the RGB color space respectively; the maximum value C max =max(R,G,B); 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 select the activated sludge area in the sedimentation cylinder image. The activated sludge area can be subsequently intercepted and then color detection can be performed. Of course, the activated sludge area can also be not intercepted and color detection can be performed directly.
[0080] In S3, the hue, saturation and brightness of all 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 pixel, 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 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, the color of the pixel is that color; determine the number of pixels of each color, and select the color with the largest number of pixels as the color of the activated sludge.
[0081] Before comparing the hue, saturation and brightness of all pixels 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 example, five colors of activated sludge are measured based on the training set. First, the training set is manually divided into five categories according to color. 2 -Net neural network prediction results intercept the activated sludge area, and only the identified activated sludge area is retained in the activated sludge area, without including background information, so as to obtain the sample activated sludge area image corresponding to each color, thereby improving the accuracy of setting the sludge HSV threshold (i.e., 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 in the activated sludge area of the sample activated sludge area image corresponding to the color.
[0086] (2.2) A hue distribution histogram is generated based on the hues of all sample pixels, and a hue distribution interval corresponding to the color is determined based on the hue distribution histogram. The horizontal axis of the hue distribution histogram is the hue, and the vertical axis is the number of sample pixels.
[0087] (2.3) A saturation distribution histogram is generated based on the saturation of all sample pixels, and the saturation distribution interval corresponding to the color is determined based on the saturation distribution histogram. The horizontal axis of the saturation distribution histogram is the saturation, and the vertical axis is the number of sample pixels.
[0088] (2.4) A brightness distribution histogram is generated based on the brightness of all sample pixels, and the brightness distribution range corresponding to the color is determined based on the brightness distribution histogram. The horizontal axis of the brightness distribution histogram is the brightness, and the vertical axis is the number of sample pixels.
[0089] The calcHist function is used to count the H, S, and V distribution of each color and generate a H, S, and V distribution histogram for each color, such as Figure 8-Figure 12 As shown, the H, S, and V distribution histograms correspond to 5 colors. The horizontal axis of each picture represents hue, saturation, and brightness, and the vertical axis represents the number of pixel occurrences in the corresponding channel in the image.
[0090] from Figure 8-Figure 12 It can be seen that the distribution of H, S, and V of each color is as follows: the H value of black sludge 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; the H value of gray-white sludge 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; the H value of red sludge is distributed between 0-9, the S value is distributed between 173-250, and the V value is distributed between 25-150; the H value of yellow sludge is distributed between 18-24, the S value is distributed between 206-255, and the V value is distributed between 28-150; the H value of light brown sludge is distributed between 0-20, the S value is distributed between 50-200, and the V value is distributed between 28-130.
[0091] Therefore, the hue distribution range, saturation distribution range and brightness distribution range of the five colors are set. Subsequently, the color of the sludge is determined according to the main distribution area of the HSV attribute of the sludge in the image to realize intelligent detection of sludge color.
[0092] In view of the imbalanced distribution of types and foreground and background areas in the existing activated sludge color sample data set, a method based on HSV interval statistics is designed to analyze the color distribution of the activated sludge area. The hue, saturation and brightness distribution intervals of sludge color detection are set by the sludge hue, saturation and brightness distribution histograms, so as to achieve accurate and intelligent detection of the color of the activated sludge area in the case of unbalanced data set.
[0093] This embodiment introduces image segmentation into the field of activated sludge performance detection, and proposes an intelligent detection method for activated sludge color based on computer vision and artificial intelligence. 2-Net neural network identifies the activated sludge area in the image. By removing network redundancy and combining MLP and Dropout regularization methods, the ability to extract and express activated sludge area features is improved, and the accuracy of regional recognition is improved by 25%, and Dice is improved by 16.89%; the sludge hue, brightness and saturation distribution histogram in the HSV color space is used to determine the hue, brightness and saturation distribution interval of the sludge color, and the color attribute distribution of the sludge area is detected by the HSV interval statistics method to identify the sludge color and analyze the corresponding performance of the sludge. The average accuracy of the main color detection of the sludge in this embodiment is more than 96%, which basically realizes the intelligent detection and performance analysis of the activated sludge color in the actual environment. In the actual scene 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 experimental analysis is performed to verify the effectiveness of the method of this embodiment:
[0095] (1) Network training parameter setting
[0096] The computer configuration used for the training of the activated sludge detection model is Intel(R) Core(TM) i7-10750H CPU @ 2.60 GHz and 16 GB of memory. 2 -Net neural network training parameter configuration is shown in Table 1. The total training cycle is set to 300 epochs, 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 lead to 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 accuracy is set to 1e-08, which is responsible for updating the model weight. The saving frequency is set to 100, and the model weight is saved every 100 iterations during the training process.
[0097] Table 1 Training parameter configuration table
[0098]
[0099]
[0100] (2) Automatic identification of activated sludge areas
[0101] Through the improved U 2-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, the images were uniformly scaled to 320*320 pixels and randomly cropped to 288*288 pixels during the training process to enrich the multi-scale information of the image and prevent the model from overfitting. After the training, a set of weight files with smaller loss values were selected to test the remaining images.
[0102] Precision, recall, accuracy and Dice are used as evaluation indicators of the model. The formula is as follows:
[0103]
[0104] Among them, t p is the number of pixels in the image that are correctly identified as foreground; f p is the number of pixels in the background area that are mistakenly identified as foreground; f n is the number of pixels in the foreground area that are mistakenly identified as background; n is the number of pixels correctly identified as background.
[0105] Precision can measure the model's ability to correctly predict the foreground, which is of great significance in scenarios with high false positive cost. In the process of sludge color detection, if part of the background is mistakenly predicted as the activated sludge area, the correct HSV interval cannot be output, which will affect the sludge color detection and the false positive cost is high. Therefore, the improved U 2 -Net neural network is used to improve the accuracy of regional recognition. Its accuracy is 90.63%, which is about 20% higher than before the improvement. The recall rate is 99.54%, the accuracy is 99.34%, and the Dice is 94.83%. It can basically achieve accurate recognition of sludge areas under complex detection backgrounds.
[0106] (3) Sludge area color detection and performance analysis
[0107] In order to solve the problems of light interference and sludge color gradient in activated sludge images, the HSV interval statistical method is used to detect the color of the sludge area. After setting 5 HSV distribution intervals of sludge color, the number of pixels of the sludge area color in each interval in the image to be tested is counted, and the color of the activated sludge is determined 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%. The corresponding sludge-related properties can be analyzed based on the detected sludge color, and the automatic detection of activated sludge color based on image recognition is basically realized.
[0109] Table 2 Activated sludge color and performance analysis
[0110]
[0111] Introducing intelligent detection of activated sludge color in the field of sewage treatment is a promising research direction for sludge performance analysis in the water treatment industry. The change of activated sludge color is generally related to factors such as sludge activity, type and concentration. Abnormal color change can usually be used as an early signal of sludge performance or system failure. This embodiment combines image processing, deep learning and data analysis methods to perform intelligent detection and analysis of sludge color during sewage treatment. 2 -Net neural network and HSV interval statistics method, designed an intelligent detection process for activated sludge color, which can obtain the activated sludge status in a timely and accurate manner, thereby assisting technical personnel to optimize some equipment parameters in the sewage treatment process, improve sewage treatment efficiency, and provide a certain reference value for intelligent, low-cost and rapid detection of sludge performance.
[0112] The embodiment of the present application also provides an application scenario, which applies the above-mentioned activated sludge color detection method based on image recognition. Specifically, the activated sludge color detection method based on image recognition provided in this embodiment can be applied in the activated sludge color recognition scenario. The activated sludge color recognition scenario includes an image acquisition link and an image processing link. The image acquisition link is used to acquire the image of the sedimentation measuring cylinder filled with activated sludge, and the image processing link is used to process the image of the sedimentation measuring cylinder filled with activated sludge to obtain the color of the activated sludge. The activated sludge color detection method based on image recognition provided in this embodiment belongs to the image processing link.
[0113] Example 2
[0114] Based on the same inventive concept, the embodiment of the present application also provides an activated sludge color detection device based on image recognition for implementing the activated sludge color detection method based on image recognition involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the embodiment of the activated sludge color detection device based on image recognition provided below can refer to the limitations of the activated sludge color detection method based on image recognition above, and will not be repeated here.
[0115] like Fig.13 As shown, an activated sludge color detection device based on image recognition is provided, and the activated sludge color detection device based on image recognition includes:
[0116] The image acquisition module M1 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 supernatant and activated sludge, and the supernatant is located above the activated sludge.
[0117] The activated sludge area detection module M2 is used to use 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 in the activated sludge area image, and compare the hue, saturation and brightness of all the pixels with the hue distribution range, saturation distribution range and brightness distribution range corresponding to each color to determine the color of the activated sludge.
[0119] Example 3
[0120] In an exemplary embodiment, a computer device is provided. The computer device may be a server or a terminal. The internal structure diagram thereof may be as follows: Fig.14 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. 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. 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 image to be processed. The input / output interface of the computer device is used to exchange information between the processor and an external device. 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 an activated sludge color detection method based on image recognition.
[0121] Those skilled in the art will understand that Fig.14 The structure shown in the figure is only a block diagram of a part of the structure 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 certain components, or have a different arrangement of components.
[0122] In an exemplary embodiment, a computer device is also provided, including: 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 described in Example 1.
[0123] Example 4
[0124] An embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the activated sludge color detection method based on image recognition described in Example 1 is implemented.
[0125] Example 5
[0126] An embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the activated sludge color detection method based on image recognition described in Example 1.
[0127] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, 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, they should be considered to be within the scope of this specification.
[0128] This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. At the same time, for those skilled in the art, according to the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting this 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 range, saturation distribution range and brightness distribution range corresponding to each color to determine the color of the activated sludge.
2. The activated sludge color detection method based on image recognition according to claim 1, characterized in that: 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 -Net neural network, add a multilayer perceptron between two adjacent layers of encoders, record the two adjacent layers of encoders as upper encoder and lower encoder respectively, 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.
3. The activated sludge color detection method based on image recognition according to claim 1, characterized in that: 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.
4. The method for detecting color of activated sludge 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.
5. The method for detecting color of activated sludge 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.
6. 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.
7. 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 range, saturation distribution range and brightness distribution range corresponding to each color to determine the color of the activated sludge.
8. 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 6.
9. 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 6 is implemented.
10. 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 6 is implemented.
Citation Information
Patent Citations
Device for automatically collecting, observing and identifying activated sludge settlement experiment process
CN112229770A
Sewage discharge detection method, detection device and computer readable storage medium
CN115049680A
Activated sludge indicative microorganism target detection model construction method and system
CN115294569A
Sewage grade identification method and device based on image
CN115619998A
Activated sludge microscopic image segmentation model construction method
CN116152805A
Cited By
Sludge sedimentation layering height automatic detection system and method based on color difference
CN121026888A
