Method and device for detecting slurry-water interface, computer device and storage medium
By combining image segmentation networks and grayscale edge detection technology with curve fitting, sub-pixel-level accurate detection of the mud-water boundary in chemical wastewater was achieved, solving the problems of accuracy and fine measurement in existing mud-water boundary detection technologies.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING JINDAYU ENVIRONMENT TECH CO LTD
- Filing Date
- 2025-09-19
- Publication Date
- 2026-05-19
AI Technical Summary
Existing technologies cannot accurately quantify the mud-water boundary, resulting in the inability to achieve precise measurements. In particular, the mud-water interface is unclear and random when the water is turbid, making it difficult to achieve high-precision mud-water boundary detection.
An image segmentation network and image processing algorithm are used to obtain mud-water layered images through preset observation points. Gray-scale edge detection is performed using preset convolution kernels, and curve fitting is performed to obtain sub-pixel level mud-water boundaries.
It achieves efficient and reliable measurement of the mud-water boundary during the sedimentation process of chemical wastewater, reaching sub-pixel accuracy. It solves the problems of misjudgment and unclear boundary in traditional methods, and improves the accuracy and real-time performance of detection.
Smart Images

Figure CN121190513B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of chemical wastewater treatment technology, specifically to a method, apparatus, computer equipment, and storage medium for detecting the mud-water boundary. Background Technology
[0002] Current technologies primarily rely on graduated cylinder sampling and visual observation, but some also employ image recognition technology to subjectively determine the separation point between mud and water during sludge settling, calculating sludge volume by reading the graduations on the graduated cylinder. The current problems are twofold: first, the mud-water interface is unclear when the water is turbid; second, the randomness of sludge settling makes it difficult to detect the interface, thus failing to accurately quantify the true mud-water boundary and meet the standards for refined measurement. Summary of the Invention
[0003] In view of this, the present invention provides a method, apparatus, computer equipment and storage medium for detecting the mud-water boundary, so as to solve the problem that the true boundary between mud and water cannot be accurately quantified and the standard of fine measurement cannot be achieved.
[0004] In a first aspect, the present invention provides a method for detecting the mud-water boundary, the method comprising:
[0005] Images of mud-water stratification during the sedimentation process of chemical wastewater were obtained according to preset observation points;
[0006] Based on the mud-water layered image and the preset image segmentation network, the mud-water ROI region is obtained;
[0007] A preset convolution kernel is used to perform grayscale edge detection on the mud-water ROI region to obtain the initial contour of the mud-water boundary.
[0008] Curve fitting is performed on multiple detection points on the initial contour of the mud-water boundary to obtain the mud-water boundary.
[0009] This invention provides a method for detecting the mud-water boundary. By accurately acquiring mud-water layered images during the settling process at preset observation points, it can dynamically match the monitoring needs of different stages of wastewater settling (such as initial settling and stable settling), ensuring the targeted and continuous nature of data acquisition. It extracts the mud-water region of interest (ROI) based on a preset image segmentation network, reducing computational complexity and improving real-time detection while ensuring the accuracy of the ROI region through masking. Using a preset convolution kernel for grayscale edge detection effectively highlights the blurred boundary, achieving sub-pixel-level edge localization. Finally, by curve fitting of the initial contour detection points, the accuracy of the boundary is further optimized. The overall method balances detection efficiency, accuracy, and scenario adaptability, providing an effective solution for the efficient and reliable measurement of the mud-water boundary during chemical wastewater settling. It solves the problem of being unable to accurately quantify the true mud-water boundary, thus failing to meet the standards of refined measurement.
[0010] In an optional implementation, the method further includes, prior to using the mud-water layered image and a preset image segmentation network:
[0011] A sliding window is used to preprocess the mud-water layered image by cropping. Areas whose size is smaller than the sliding window after cropping are filled with a first preset value, and the preprocessed mud-water layered image is output in a preset image format.
[0012] This invention provides a method for detecting mud-water boundaries. For high-resolution mud-water layered images that may appear in chemical wastewater settling scenarios, a sliding window cropping method breaks down large images into smaller blocks that fit a pre-defined image segmentation network, effectively reducing the computational load on subsequent networks. Areas with insufficient size after cropping are filled with a first preset value, preventing irregular image edges from causing input format disorder in the segmentation network. This ensures uniform image block size after preprocessing, reduces edge region segmentation distortion, and guarantees the standardization and consistency of the segmentation network input data. Furthermore, using a preset image format for output directly matches the input requirements of subsequent pre-defined image segmentation networks, eliminating the need for additional format conversion and achieving seamless integration between preprocessing and segmentation. This also lays a solid data foundation for accurate extraction of mud-water ROI regions and grayscale edge detection, indirectly improving the accuracy and workflow consistency of the final mud-water boundary detection.
[0013] In one optional implementation, the mud-water ROI region includes a mud level ROI and a water level ROI; based on the mud-water layered image and a preset image segmentation network, the mud-water ROI region is obtained, including:
[0014] The pre-processed mud-water layered image is input into a preset image segmentation network for Patch Merge operation and attention calculation with an attention scaling factor to obtain the mud area ROI and water area ROI.
[0015] This invention provides a method for detecting mud-water boundaries. Utilizing a pre-defined image segmentation network with Patch Merge operation, and by designing appropriate convolutional kernels and strides, the feature resolution is reasonably reduced. This aggregates local features of both mud and water regions while avoiding feature loss in key areas such as the mud-water interface, laying a clear feature foundation for subsequent differentiation of mud and water levels. An attention scaling factor is introduced to optimize attention computation, proportionally reducing the computational complexity of attention operations. Simultaneously, the network prioritizes the core region of mud-water stratification (rather than observing irrelevant areas such as bottle edges or background reflections), reducing interference from non-target regions on the segmentation results. Furthermore, this process directly outputs independent ROIs for mud and water levels, rather than mixed target regions. This provides accurate and regular target ranges for subsequent targeted grayscale edge detection of mud-water boundaries, effectively avoiding segmentation deviations caused by mud and water feature confusion. It is particularly suitable for chemical wastewater settling scenarios where mud and water colors are similar and the interface is easily blurred, further improving the accuracy and reliability of subsequent mud-water boundary detection.
[0016] In one alternative implementation, the method further includes:
[0017] After masking and filtering the ROIs of the mud area and the water area, areas whose mask area does not meet the preset area threshold are removed, and the ordinate of the center position between the retained ROIs of the mud area and the water area is not greater than the second preset value.
[0018] The present invention provides a method for detecting the mud-water boundary, which not only removes areas with substandard mask area and filters out noise interference such as small mud particles and air bubbles to ensure the effectiveness of the mud-water ROI area, but also ensures that the mud level and water level ROI center ordinates correspond to the same mud-water interface by limiting the difference between the ordinates of the mud level and water level ROI center, avoiding misjudgment of irrelevant areas, and laying a reliable foundation for subsequent accurate detection of the boundary.
[0019] In one optional implementation, a preset convolution kernel is used to perform grayscale edge detection on the mud-water ROI region to obtain the initial contour of the mud-water boundary, including:
[0020] A pre-defined convolution kernel is used to perform convolution operations on the muddy water ROI region; the pre-defined convolution kernel is a convolution kernel with the Y direction from bright to dark designed based on the Sobel operator;
[0021] A vertical grayscale projection function is constructed based on the mud-water ROI region after convolution operation. The vertical grayscale projection function is then compared with the smoothed vertical grayscale projection function. The positions where the difference result exceeds a preset threshold are selected as the column coordinates of the mud-water boundary line.
[0022] The boundary region is found by iteratively searching the column coordinates, and the boundary region is optimized by morphological algorithms in image processing to obtain the preliminary region of the mud-water boundary.
[0023] The intersection of the mud-water ROI region after mask filtering and the preliminary mud-water boundary region is calculated to obtain the initial contour of the mud-water boundary.
[0024] This invention provides a method for detecting mud-water boundaries. It employs a pre-defined convolution kernel in the Y-direction, designed based on the Sobel operator, that accurately matches the spatial characteristics of mud-water stratification (vertical distribution), effectively highlighting the grayscale changes at the mud-water interface and adapting to scenarios where the interface between chemical waste cement and water is easily blurred. By transforming a two-dimensional ROI image into one-dimensional features through vertical grayscale projection, combined with difference operations and threshold filtering, the column coordinates of the mud-water boundary can be quickly located, eliminating interference from non-boundary regions. Iteratively searching for boundary regions and optimizing them using morphological algorithms expands discrete coordinates into continuous, clean boundary regions, removing isolated noise. Finally, by calculating the intersection of the mud-water ROI and the boundary region, it ensures that the initial contour of the mud-water boundary originates only from the effective mud-water region, avoiding misjudgments of irrelevant areas and laying a precise and reliable foundation for subsequent curve fitting.
[0025] In one optional implementation, a difference operation is performed between the vertical grayscale projection function and the smoothed vertical grayscale projection function, and the positions where the difference result exceeds a preset threshold are selected as the column coordinates of the mud-water boundary, including:
[0026] A grayscale projection is performed on the muddy water ROI region, that is, the average value of each column of pixels is vertically projected to form a one-dimensional array, and the one-dimensional array is integrated to obtain a smoothed integral curve.
[0027] Find the point with the largest grayscale change rate on the smoothed integral curve, and determine whether the grayscale change rate exceeds a preset threshold. If it exceeds the preset threshold, take the point with the largest grayscale change rate as the sub-pixel mud-water boundary point, and take the coordinates of the sub-pixel mud-water boundary point as the column coordinates of the mud-water boundary line.
[0028] This invention provides a method for detecting the mud-water boundary. By converting the cumulative average of column pixels in the mud-water ROI region into a one-dimensional grayscale projection array, the feature extraction dimension of the mud-water boundary is greatly simplified, and the computational complexity is reduced. Integrating the one-dimensional array yields a smooth integral curve, which effectively eliminates grayscale fluctuations caused by noise such as tiny suspended particles and bottle reflections, avoiding interference with boundary positioning. This method is suitable for scenarios where the color of chemical waste cement and water is similar and the boundary is easily blurred. By finding the point with the largest grayscale change rate on the smooth curve and combining it with a threshold judgment, the core location of the mud-water grayscale abrupt change is accurately located, while false positive points that are not true boundaries are eliminated. Furthermore, sub-pixel-level column coordinates are directly output, breaking through the accuracy limitations of traditional pixel-level positioning and providing crucial support for subsequent high-precision detection of the mud-water boundary.
[0029] In one optional implementation, curve fitting is performed on multiple detection points on the initial contour of the mud-water boundary to obtain the mud-water boundary, including:
[0030] Multiple sub-pixel level mud-water boundary points on the initial contour of the mud-water boundary are extracted as multiple detection points, and a preset curve fitting algorithm is used to fit the multiple detection points to obtain a continuous boundary curve.
[0031] Extract the lowest point of the region projection corresponding to the boundary curve, and obtain the mud-water boundary line based on the lowest point of the region projection.
[0032] This invention provides a method for detecting the mud-water boundary line. It uses sub-pixel-level mud-water boundary points as detection points, ensuring high accuracy of the fitted data from the source and avoiding positioning errors caused by pixel-level points. By fitting multiple detection points using a preset curve fitting algorithm, it can correct any discrete or local fluctuations in the initial contour into a continuous and smooth boundary line curve, conforming to the natural continuous shape of the mud-water interface during the settling of chemical wastewater. Furthermore, it extracts the lowest point of the regional projection corresponding to the boundary line curve to determine the final mud-water boundary line. This accurately anchors the core benchmark position of the mud-water interface, effectively avoiding the influence of local deviations in the fitted curve on the boundary determination, ultimately achieving high-precision and high-reliability positioning of the mud-water boundary line.
[0033] Secondly, the present invention provides a device for detecting the mud-water boundary, the device comprising:
[0034] The mud-water stratification image acquisition module is used to acquire mud-water stratification images during the sedimentation process of chemical wastewater according to preset observation points;
[0035] The image segmentation module is used to obtain the mud-water ROI region based on the mud-water layered image and a preset image segmentation network.
[0036] The grayscale edge detection module is used to perform grayscale edge detection on the mud-water ROI region using a preset convolution kernel to obtain the initial contour of the mud-water boundary.
[0037] The curve fitting module is used to perform curve fitting on multiple detection points on the initial contour of the mud-water boundary to obtain the mud-water boundary.
[0038] Thirdly, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer instructions to perform the mud-water boundary detection method of the first aspect or any corresponding embodiment described above.
[0039] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to perform the mud-water boundary detection method of the first aspect or any corresponding embodiment described above.
[0040] Fifthly, the present invention provides a computer program product, including computer instructions for causing a computer to execute the mud-water boundary detection method of the first aspect or any corresponding embodiment described above. Attached Figure Description
[0041] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0042] Figure 1 This is a schematic flowchart of a method for detecting the mud-water boundary according to an embodiment of the present invention.
[0043] Figure 2 This is a flowchart illustrating another method for detecting the mud-water boundary according to an embodiment of the present invention.
[0044] Figure 3 This is a flowchart illustrating another method for detecting the mud-water boundary according to an embodiment of the present invention.
[0045] Figure 4 This is a flowchart illustrating a method for detecting the water-mud boundary according to an embodiment of the present invention.
[0046] Figure 5 This is a schematic diagram of a sliding window in the data preprocessing of the mud-water boundary detection method according to an embodiment of the present invention;
[0047] Figure 6 This is a schematic diagram illustrating several interface examples in the mud-water boundary detection method according to an embodiment of the present invention.
[0048] Figure 7 This is a schematic flowchart of grayscale edge detection in the mud-water boundary detection method according to an embodiment of the present invention.
[0049] Figure 8 This is a schematic diagram of grayscale projection in the method for detecting the mud-water boundary according to an embodiment of the present invention;
[0050] Figure 9 This is a schematic diagram of the actual mud-water boundary in the mud-water boundary detection method according to an embodiment of the present invention.
[0051] Figure 10 This is a structural block diagram of a mud-water boundary detection device according to an embodiment of the present invention;
[0052] Figure 11 This is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. Detailed Implementation
[0053] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0054] In the process of chemical wastewater treatment, sedimentation is the core link to achieve solid-liquid separation. The position and shape of the mud-water boundary directly determine the wastewater treatment effect (such as the solid impurity removal rate and the clarity of the supernatant), and are the key basis for judging whether sedimentation meets the standards and optimizing the flocculant dosage and sedimentation cycle.
[0055] Existing mud-water boundary detection technologies have several shortcomings: First, manual observation is highly subjective, relying on operator experience and prone to misjudging the boundary position due to visual errors. Furthermore, continuous monitoring (such as nighttime or high-frequency data acquisition) is not possible, making it difficult to capture the dynamically changing interface during settling. Second, traditional image processing techniques have weak anti-interference capabilities. In scenarios where the color of chemical wastewater and cement water are similar and the boundary is blurred, ordinary threshold segmentation easily misclassifies suspended particles as mud / water layers, and basic edge detection cannot effectively highlight subtle grayscale changes, resulting in incomplete boundary contours. Third, there is a lack of targeted preprocessing and feature optimization; high-resolution wastewater images directly... The first problem is the high computational load during processing, the lack of lightweight network support, poor real-time performance, and the absence of masking and filtering of segmented regions (such as retaining large effective areas and excluding small noise blocks), which easily introduces irrelevant areas to interfere with boundary detection. The second problem is the low positioning accuracy. Traditional technologies can only achieve pixel-level positioning and cannot reach sub-pixel-level measurement standards, making it difficult to meet the needs of high-precision settlement effect evaluation (such as monitoring of trace mud layer thickness changes). The third problem is the lack of a complete detection-optimization-fitting link. Even if the initial boundary contour is obtained, local fluctuations are not corrected through curve fitting, and the core boundary point (such as the lowest point of the regional projection) is not anchored, resulting in insufficient reliability of the final boundary line.
[0056] This invention provides a method for detecting the mud-water boundary. It employs image segmentation technology and image processing algorithms to achieve sub-pixel measurement standards. By fitting the interface, the optimal mud-water boundary is found. This method improves the detection of interfaces in cases where the sedimentation of the mixed liquor is unclear, based on conventional detection methods. The fully automated process ensures stable, efficient, and accurate detection, and is not affected by environmental changes.
[0057] According to an embodiment of the present invention, a method for detecting the mud-water boundary is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0058] This embodiment provides a method for detecting the mud-water boundary, which can be used with the aforementioned computer equipment. Figure 1 This is a flowchart of a method for detecting the mud-water boundary according to an embodiment of the present invention, as follows: Figure 1 As shown, the process includes the following steps:
[0059] Step S101: Obtain mud-water stratification images during the sedimentation process of chemical wastewater according to preset observation points.
[0060] Specifically, the preset observation points are pre-defined time or location nodes in the chemical wastewater treatment process that trigger the image acquisition module to capture images. Acquisition is automatically initiated, and the captured images are analyzed based on the observation nodes, with results output for each node. This includes:
[0061] First, based on the process characteristics of chemical wastewater settling (such as initial settling, rapid flocculation, and stable clarification stages), observation nodes are pre-set (either at time intervals, such as 5-30 minutes, or triggered by settling stages). At each observation node, layered images are captured inside the chemical wastewater settling container (such as observation bottles or settling tanks) using an image acquisition module (such as an industrial camera), recording the distribution of the mud layer (bottom solid sediment) and the water layer (upper clarified liquid) at that moment. The core of this step is to acquire image data covering the entire settling cycle through timed and staged acquisition, providing continuous snapshots of the state for subsequent analysis.
[0062] Step S102: Based on the mud-water layered image and the preset image segmentation network, obtain the mud-water ROI (Region of Interest).
[0063] Specifically, the acquired mud-water layered images are input into a pre-trained lightweight image segmentation network (such as an optimized segformer network). This network focuses on identifying the core regions of the mud and water layers in the image, outputting the mud region ROI (the effective local area where the mud layer is located) and the water region ROI (the effective local area where the water layer is located). This step intelligently segments and eliminates background (such as container edges and external reflections) and noise interference, focusing on the main mud-water region and defining the precise range for subsequent edge detection.
[0064] Step S103: Use a preset convolution kernel to perform grayscale edge detection on the mud-water ROI region to obtain the initial contour of the mud-water boundary.
[0065] Specifically, for the segmented mud-water ROI region, a pre-defined convolution kernel (highlighting the grayscale changes from bright to dark, adapting to the spatial characteristics of the mud-water layering) is used for convolution operations to enhance the grayscale abrupt change signal at the mud-water interface. Then, the average pixel grayscale value of the convolved ROI region is calculated column-wise to construct a vertical grayscale projection function. This function is then smoothed (e.g., by integration) and differencing is performed to filter out column coordinates (i.e., potential boundary columns) where the difference results exceed a threshold. This is then expanded into a boundary region through iterative searching, optimized using morphological algorithms (e.g., dilation-erosion) to remove noise, and finally, the intersection of this region and the mud-water ROI is calculated to obtain the initial contour of the mud-water boundary (including the core pixel range of the mud-water boundary).
[0066] Step S104: Perform curve fitting on multiple detection points on the initial contour of the mud-water boundary to obtain the mud-water boundary.
[0067] Specifically, key detection points on the initial contour are extracted, and a continuous and smooth curve is generated through a curve fitting algorithm to ultimately determine the precise mud-water boundary.
[0068] The mud-water boundary detection method provided in this embodiment accurately acquires mud-water layered images during the settling process by setting preset observation points. It can dynamically match the monitoring needs of different stages of wastewater settling (such as initial settling and stable settling), ensuring the relevance and continuity of data acquisition. It extracts the mud-water ROI region based on a preset image segmentation network, reducing computational complexity and improving real-time detection while ensuring the accuracy of the ROI region through masking. It uses a preset convolution kernel for grayscale edge detection, effectively highlighting the blurred boundary and achieving sub-pixel-level edge positioning. Finally, it further optimizes the boundary line accuracy by curve fitting of the initial contour detection points. The overall method balances detection efficiency, accuracy, and scenario adaptability, providing an effective solution for efficient and reliable measurement of the mud-water boundary during chemical wastewater settling. It solves the problem of being unable to accurately quantify the true mud-water boundary and failing to meet the standards of refined measurement.
[0069] This embodiment provides a method for detecting the mud-water boundary, which can be used with the aforementioned computer equipment. Figure 2 This is a flowchart of a method for detecting the mud-water boundary according to an embodiment of the present invention, as follows: Figure 2 As shown, the process includes the following steps:
[0070] Step S201: Obtain mud-water stratification images during the sedimentation process of chemical wastewater according to preset observation points. For details, please refer to [link to relevant documentation]. Figure 1 Step S101 of the illustrated embodiment will not be described again here.
[0071] Step S202: The mud-water layered image is pre-processed by cropping using a sliding window. Areas whose size after cropping is less than the size of the sliding window are filled with a first preset value, and the pre-processed mud-water layered image is output using a preset image format.
[0072] Specifically, the first value is set to 0. The default image format is image patch=8.
[0073] The original image of the mud-water layering image has a resolution of 4K×3K (K represents kilopixels), such as... Figure 5 As shown, a 640×640 pixel sliding window with an overlap of 100 pixels is used to segment the image from top to bottom and from left to right. The sliding window coordinates are calculated as follows:
[0074] win_size*t-(t-1)*overloap(1);
[0075] where \(t = 1,\cdots,n\), \(n<\frac{image\_size}{win\_size}\), \(win\_size\) represents the size of the sliding window, \(overloap\) represents the overlap degree, \(image\_size\) represents the image size, \(t\) represents the step size, \(t=\frac{image\_size}{win\_size}\), and zeros are used to pad when the size is insufficient.
[0076] The cropped image is fed into the neural network and output in the format of image patches, that is, patch = 8, to output the pre - cropped muddy - water stratification image, which improves the utilization rate of the GPU (Graphics Processing Unit) and ensures the real - time response.
[0077] Step S203: Based on the muddy - water stratification image and the preset image segmentation network, obtain the muddy - water ROI region.
[0078] Specifically, the muddy - water ROI region (Region of Interest) includes the mud - level region ROI and the water - level region ROI; the above - mentioned step S203 includes:
[0079] Step a: Input the pre - cropped muddy - water stratification image into the preset image segmentation network for PatchMerge operation and attention calculation introducing an attention scaling factor, to obtain the mud - level region ROI and the water - level region ROI.
[0080] Specifically, the preset image segmentation network uses the lightweight segformer image segmentation network. The lightweight SegFormer image segmentation network is an efficient semantic segmentation model designed for real - time and resource - constrained scenarios. Its core is the combination of a hierarchical Transformer encoder and a lightweight MLP (Multilayer Perceptron) decoder, which significantly reduces the computational amount and the number of parameters while maintaining high accuracy.
[0081] In the structure of the lightweight segformer image segmentation network, the Patch Merge operation is performed using convolution operations, that is, by designing the convolution kernel size and stride to reduce the feature resolution. In the attention mechanism, to improve the operation efficiency, an attention scaling factor \(R\) is introduced, that is, the feature dimension of the original attention weight matrix \(K\) is reduced by \(R\) times to reduce the complexity of the attention operation. The formulas for dimension reshaping (Reshape) and linear projection (Linear) of the original attention weight matrix \(K\) are as follows:
[0082]
[0083] Where K is the original attention weight matrix with shape (N, C), N is the length of the input sequence, denoted as the number of image patches, C is the number of feature channels, and R is the attention scaling factor. For the intermediate matrix after dimensional reshaping, Equation (2) indicates that the shape of the original attention weight matrix is adjusted from (N, C) to... Formula (3) represents the intermediate matrix after dimensional reshaping. Perform a linear transformation to restore the number of feature channels from C·R back to C.
[0084] Step S204: After masking and filtering the mud area ROI and water area ROI, remove areas whose mask area does not meet the preset area threshold, and ensure that the ordinate of the center position between the remaining mud area ROI and water area ROI is not greater than the second preset value.
[0085] Specifically, the preset area threshold is set to 100 pixels, and the second preset value is set to 10 pixels.
[0086] After masking and filtering the mud area ROI and water area ROI, areas with a mask area < 100 pixels are removed, and only areas with larger mud and water areas are retained. The difference in the ordinate of the center position between the retained mud area ROI and water area ROI is no more than 10 pixels.
[0087] Step S205: A preset convolution kernel is used to perform grayscale edge detection on the mud-water ROI region to obtain the initial contour of the mud-water boundary. For details, please refer to [link to details]. Figure 1 Step S103 of the illustrated embodiment will not be described again here.
[0088] Step S206: Perform curve fitting on multiple detection points on the initial contour of the mud-water boundary to obtain the mud-water boundary. For details, please refer to [link to relevant documentation]. Figure 1 Step S104 of the illustrated embodiment will not be described again here.
[0089] The mud-water boundary detection method provided in this embodiment utilizes a pre-defined image segmentation network's Patch Merge operation. By designing an appropriate convolution kernel and stride, it achieves a reasonable reduction in feature resolution. While aggregating local features of mud and water regions, it avoids feature loss in key areas such as the mud-water interface, laying a clear feature foundation for subsequent differentiation of mud and water levels. An attention scaling factor is introduced to optimize attention calculation, proportionally reducing the computational complexity of attention operations. Simultaneously, it guides the network to prioritize the core region of mud-water stratification (rather than observing irrelevant areas such as bottle edges or background reflections), reducing interference from non-target regions on the segmentation results. Furthermore, this process directly outputs independent ROIs for mud and water levels, rather than mixed target regions. This provides accurate and regular target ranges for subsequent targeted grayscale edge detection of the mud-water boundary, effectively avoiding segmentation deviations caused by mud and water feature confusion. It is particularly suitable for chemical wastewater sedimentation scenarios where mud and water colors are similar and the interface is easily blurred, further improving the accuracy and reliability of subsequent mud-water boundary detection.
[0090] This embodiment provides a method for detecting the mud-water boundary, which can be used with the aforementioned computer equipment. Figure 3 This is a flowchart of a method for detecting the mud-water boundary according to an embodiment of the present invention, as follows: Figure 3 As shown, the process includes the following steps:
[0091] Step S301: Obtain sludge-water stratification images during the sedimentation process of chemical wastewater according to preset observation points. For details, please refer to [link to relevant documentation]. Figure 2 Step S201 of the illustrated embodiment will not be described again here.
[0092] Step S302: Based on the mud-water layered image and a preset image segmentation network, the mud-water ROI region is obtained. For details, please refer to [link to relevant documentation]. Figure 2 Step S203 of the illustrated embodiment will not be described again here.
[0093] Step S303: Use a preset convolution kernel to perform grayscale edge detection on the mud-water ROI region to obtain the initial contour of the mud-water boundary.
[0094] Specifically, such as Figure 6 As shown, using a preset convolutional kernel to perform grayscale edge detection on the mud-water ROI region can effectively identify the following types of mud-water interfaces (flat interface, concave interface, convex interface, irregular interface, and interface with indistinctness, mud and water interfering with each other, etc.). In particular, when the mud and water colors are similar and the interface is blurred, it is difficult for human senses to determine clearly. Therefore, using a neural network convolutional kernel to learn from a large amount of data can roughly find the boundary position, and then the next technique, sub-pixel edge detection, can be used to find the boundary.
[0095] like Figure 7As shown, step S303 above includes:
[0096] Step S3031: Perform convolution operation on the muddy water ROI region using a preset convolution kernel; the preset convolution kernel is a convolution kernel designed based on the Sobel operator with the Y direction from bright to dark.
[0097] Specifically, the pre-defined convolutional kernel uses the Sobel operator, defining a kernel that transitions from bright to dark in the Y direction; the purpose is to find edges with drastic grayscale changes. An example of the Sobel operator is shown below:
[0098]
[0099] Here, Gy is a convolution kernel designed based on the Sobel operator, with the Y direction from bright to dark. The first row represents positive weights, which are used to capture the brightness of the pixels above. The third row represents negative weights, which are used to capture the brightness of the pixels below. The second row has all zero weights, which means that the contribution of the pixels in the middle row of the image to the convolution result is ignored, and the focus is on the gray level difference between the pixels above (the weights in the first row) and the weights below (the weights in the third row).
[0100] Extract the mud-water settling map from the mud-water ROI region (i.e., use an image segmentation network to circle the region containing only mud-water mixture), and perform a convolution operation between the mud-water settling map and Gy to highlight the mud-water interface.
[0101] Step S3032: Construct a vertical grayscale projection function based on the mud-water ROI region after convolution operation, and perform a difference operation between the vertical grayscale projection function and the smoothed vertical grayscale projection function. Select the positions where the difference result exceeds a preset threshold as the column coordinates of the mud-water boundary line.
[0102] In an optional implementation, step S3032 includes:
[0103] Step b1: Perform grayscale projection on the muddy water ROI region, that is, vertically project the accumulated mean of each column of pixels to form a one-dimensional array, and perform integration on the one-dimensional array to obtain a smoothed integral curve.
[0104] like Figure 8 As shown, on the mud-water boundary ROI image (i.e., the ROI image highlighting the mud-water interface), a grayscale projection is performed. The mean of each column of pixels is accumulated and then projected vertically to obtain a one-dimensional array, which is represented as follows: X is a one-dimensional array. The average value calculated by summing up the pixels in each column.
[0105] Smoothing the integral curve of one-dimensional data is calculated as follows: From arrive curve
[0106] Step b2: Find the point with the largest grayscale change rate on the smoothed integral curve, and determine whether the grayscale change rate exceeds the preset threshold. If it exceeds the preset threshold, take the point with the largest grayscale change rate as the sub-pixel level mud-water boundary point, and take the coordinates of the sub-pixel level mud-water boundary point as the column coordinates of the mud-water boundary line.
[0107] Specifically, the curve Surface length To obtain the maximum result from the point set, we find the point with the largest grayscale change rate on the smoothed integral curve and determine whether the grayscale change rate exceeds a preset threshold T. We then compare this rate with the preset threshold T to determine the sub-pixel mud-water boundary point p. If the grayscale change rate exceeds the preset threshold, the point with the largest grayscale change rate is taken as the sub-pixel mud-water boundary point p. The formula for selecting the sub-pixel mud-water boundary point p is as follows:
[0108] p = [max(S) - T] (5).
[0109] The mud-water boundary detection method provided in this embodiment significantly simplifies the feature extraction dimension of the mud-water boundary and reduces computational complexity by converting the cumulative average value of column pixels in the mud-water ROI region into a one-dimensional grayscale projection array. Integrating the one-dimensional array to obtain a smooth integral curve effectively eliminates grayscale fluctuations caused by noise such as tiny suspended particles and bottle reflections, avoiding interference with boundary positioning. This method is suitable for scenarios where the color of chemical waste cement and water is similar and the boundary is easily blurred. By finding the point with the largest grayscale change rate on the smooth curve and combining it with a threshold judgment, the core location of the mud-water grayscale abrupt change is accurately located, while false positive points that are not true boundaries are eliminated. Furthermore, sub-pixel-level column coordinates are directly output, breaking through the accuracy limitations of traditional pixel-level positioning and providing crucial support for subsequent high-precision detection of the mud-water boundary.
[0110] Step S3033: Based on column coordinates, the boundary region is searched cyclically, and the boundary region is optimized using morphological algorithms in image processing to obtain the preliminary region of the mud-water boundary.
[0111] Specifically, the column coordinate loop is used to find the boundary: taking advantage of the obvious gray-level abrupt change in the vertical direction (column dimension) between mud and water, the gray-level changes of pixels are analyzed column by column (such as statistical analysis of the gray-level distribution and gradient changes of each column), and the column intervals where there is a gray-level jump from mud to water or water to mud are marked. These intervals together form the possible boundary area (but at this time the boundary may be discontinuous due to noise and interference).
[0112] Morphological algorithm optimization: Since the boundaries detected in the initial stage are easily affected by small bubbles, local reflections, etc. (resulting in gaps and false edges), morphological operations (such as expansion to fill edge gaps and erosion to eliminate small noise blocks) are used to make the boundary area more continuous and regular, and finally obtain the preliminary area of the mud-water boundary (which initially outlines the general shape of the boundary, but may still contain invalid areas outside the ROI).
[0113] Step S3034: Calculate the intersection of the mud-water ROI region after mask screening and the preliminary mud-water boundary region to obtain the initial contour of the mud-water boundary.
[0114] Specifically, the mud-water ROI region is a region of interest that is pre-defined by image segmentation (such as semantic segmentation model, threshold segmentation) and contains only the mud-water mixture (excluding irrelevant parts such as container walls and background, thus narrowing the analysis scope).
[0115] Intersection filtering calculation: Perform an intersection operation on the mud-water ROI region and the preliminary mud-water boundary region. This is equivalent to using the ROI to perform range filtering on the preliminary boundary, that is, only retain the boundary part inside the ROI and remove false detection edges outside the ROI, and finally obtain the initial contour of the mud-water boundary (which is closer to the contour shape of the real boundary and only focuses on the core mud-water region).
[0116] Step S304: Perform curve fitting on multiple detection points on the initial contour of the mud-water boundary to obtain the mud-water boundary.
[0117] Specifically, step S304 includes:
[0118] Step S3041: Extract multiple sub-pixel level mud-water boundary points on the initial contour of the mud-water boundary as multiple detection points, and use a preset curve fitting algorithm to fit the multiple detection points to obtain a continuous boundary curve.
[0119] Specifically, from the determined initial contour of the mud-water boundary, multiple sub-pixel level mud-water boundary points are selected. These points are not simple pixel-level coordinates (such as integer values x = 250), but high-precision coordinates (such as x = 250.3, y = 180.7) obtained by calculating the gray-level change rate (the point with the largest gray-level change rate on the smooth integral curve). This can break through the precision limitation of a single pixel and serve as the basic detection points for fitting.
[0120] Subsequently, a preset curve fitting algorithm (such as least squares method, B-spline curve, etc.) is used to fit these discrete sub-pixel level detection points: the algorithm calculates a continuous curve that can best approximate all detection points, corrects the local fluctuations that may exist in the initial contour (such as the offset of individual points due to noise), and finally obtains a smooth and continuous boundary curve that better fits the natural shape of the mud-water interface (avoiding the fragmentation of discrete points).
[0121] Step S3042: Extract the lowest point of the region projection corresponding to the boundary curve, and obtain the mud-water boundary line based on the lowest point of the region projection.
[0122] For the obtained continuous boundary curve, its corresponding regional projection is calculated. The corresponding regional projection refers to statistically analyzing the projection range of the curve in the vertical direction (or along the direction of gravity, due to the vertical stratification characteristics of sludge-water settling), and finding the coordinates of the lowest point within this projection range (i.e., the lowest position point of the curve in the vertical direction). Using this lowest point as a reference, combined with the fitted continuous curve, a complete and accurate sludge-water boundary is finally determined. This preserves the overall shape of the curve and anchors the core position of the boundary through the reference point, avoiding the influence of local deviations in the fitted curve on the final result.
[0123] The final mud-water boundary diagram obtained using this embodiment is shown below. Figure 9 As shown.
[0124] The mud-water boundary detection method provided in this embodiment uses sub-pixel level mud-water boundary points as detection points, ensuring high accuracy of the fitted data from the source and avoiding positioning errors caused by pixel-level points. By fitting multiple detection points with a preset curve fitting algorithm, the discrete and local fluctuations that may exist in the initial contour can be corrected into a continuous and smooth boundary curve, which conforms to the natural continuous shape of the mud-water interface during the sedimentation of chemical wastewater. Furthermore, the lowest point of the regional projection corresponding to the boundary curve is extracted to determine the final mud-water boundary, which can accurately anchor the core benchmark position of the mud-water interface, effectively avoiding the influence of local deviations of the fitted curve on the boundary determination, and finally achieving high-precision and high-reliability positioning of the mud-water boundary.
[0125] As one or more specific application embodiments of the present invention, combined with Figure 4 The method for detecting the mud-water boundary provided by the present invention will be further described in detail, such as... Figure 4 As shown, the specific process is as follows:
[0126] Step 1: When the preset conditions are met (such as timed triggering, external signal triggering, manual command, etc.), the image acquisition device (such as an industrial camera) is started to acquire image data of the muddy water area at the preset observation point, providing raw images for subsequent analysis.
[0127] Step 2, AI segmentation network: The acquired image is input into a pre-trained semantic segmentation model (such as a lightweight segformer image segmentation network). The model performs pixel-level classification of the image, distinguishes regions such as mud, water, and background, and outputs a segmentation mask or feature map to clarify the core region ROI where the mud and water are located, thus narrowing the analysis scope for edge detection.
[0128] 3. Custom Convolutional Edge Detection: A customized convolutional kernel (such as a Gy convolutional kernel optimized for vertical edges) is used to perform convolution operations on the AI-segmented results (or the muddy water region combined with the original image). By enhancing the gray-level abrupt changes in the vertical direction (or the target direction), preliminary edge information at the boundary between mud and water is extracted, resulting in a discrete set of edge points (or preliminary edge regions).
[0129] 4. Detection Point Fitting: From the initial edge points, key detection points with sub-pixel accuracy are selected (breaking through the accuracy limitations of a single pixel and improving positioning accuracy). These detection points are then fitted using curve fitting algorithms (such as least squares method, B-spline curve, etc.) to generate a continuous and smooth boundary curve, restoring the true shape of the mud-water boundary (eliminating edge fluctuations caused by local noise). In this embodiment, the key detection point with sub-pixel accuracy is the lowest point of the region projection.
[0130] 5. Results Output: The fitted continuous boundary curve (and derived information, such as boundary position, mud layer thickness, etc.) will be visualized (e.g., image annotation, curve plotting) or output as data (e.g., coordinate parameters, process control signals) to provide a basis for subsequent mud-water stratification monitoring and mud discharge decisions.
[0131] 6. Close acquisition: When the results are output, or when the preset stop conditions are met (such as the end of a single detection cycle or system command), control the image acquisition device to stop working and end the current detection process.
[0132] 7. Observation Node (Feedback Loop): A monitoring and iteration mechanism derived from the middle or end of the process. It can judge the detection accuracy based on the output results (such as whether the boundary line is reasonable), and then adjust the acquisition parameters, AI segmentation network or edge detection strategy to form a closed loop of detection → evaluation → optimization, thereby improving the system's adaptability.
[0133] The mud-water boundary detection method provided in this embodiment utilizes a neural network to segment the observed bottle to identify the Region of Interest (ROI), then designs a convolutional kernel for grayscale edge detection, subsequently revises the boundary region, performs curve fitting on the detection points, and finally calculates the optimal mud-water boundary. This embodiment employs AI image segmentation technology and image processing algorithms to achieve sub-pixel measurement standards, improving the detection of interface in cases of unclear sedimentation of mixed liquor compared to conventional detection methods. The automated process ensures stable, efficient, and accurate detection; it is not dependent on environmental changes.
[0134] This embodiment also provides a device for detecting the mud-water boundary, which is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0135] This embodiment provides a device for detecting the mud-water boundary, such as... Figure 10 As shown, it includes:
[0136] The mud-water stratification image acquisition module 1001 is used to acquire mud-water stratification images during the sedimentation process of chemical wastewater according to preset observation points.
[0137] Image segmentation module 1002 is used to obtain mud and water ROI regions based on mud and water layered images and preset image segmentation networks.
[0138] The grayscale edge detection module 1003 is used to perform grayscale edge detection on the mud-water ROI region using a preset convolution kernel to obtain the initial contour of the mud-water boundary.
[0139] The curve fitting module 1004 is used to perform curve fitting on multiple detection points on the initial contour of the mud-water boundary to obtain the mud-water boundary.
[0140] In some alternative embodiments, the mud-water boundary detection device further includes:
[0141] Image cropping preprocessing is used to crop the mud-water layered image using a sliding window. Areas whose cropped size is less than the size of the sliding window are filled with a first preset value, and the cropped mud-water layered image is output in a preset image format.
[0142] In some alternative implementations, the image segmentation module 1002 includes:
[0143] The image segmentation unit is used to input the pre-processed mud-water layered image into a preset image segmentation network for patch merging operations and attention calculation with an attention scaling factor to obtain the mud area ROI and the water area ROI.
[0144] In some alternative implementations, the detection of the mud-water boundary also includes:
[0145] The mask filtering post-processing module is used to perform mask filtering post-processing on the mud area ROI and the water level ROI, remove areas whose mask area does not meet the preset area threshold, and ensure that the ordinate of the center position between the retained mud area ROI and the water level ROI is not greater than the second preset value.
[0146] In some alternative implementations, the grayscale edge detection module 1003 includes:
[0147] The convolution unit is used to perform convolution operations on the muddy water ROI region using a preset convolution kernel; the preset convolution kernel is a convolution kernel with the Y direction from bright to dark designed based on the Sobel operator.
[0148] The grayscale projection unit is used to construct a vertical grayscale projection function based on the mud-water ROI region after convolution operation, and to perform a difference operation between the vertical grayscale projection function and the smoothed vertical grayscale projection function, and to select the position where the difference result exceeds a preset threshold as the column coordinate of the mud-water boundary.
[0149] The boundary region optimization unit is used to iteratively search for boundary regions based on column coordinates and optimize the boundary regions using morphological algorithms in image processing to obtain the preliminary region of the mud-water boundary.
[0150] The initial contour determination unit for the mud-water boundary is used to calculate the intersection of the mud-water ROI region after mask screening and the initial mud-water boundary region to obtain the initial contour of the mud-water boundary.
[0151] In some alternative implementations, the grayscale projection unit includes:
[0152] The integral curve smoothing sub-unit is used to perform grayscale projection on the muddy water ROI region. That is, the average value of each column of pixels is vertically projected to form a one-dimensional array, and the one-dimensional array is integrated to obtain the smoothed integral curve.
[0153] The sub-pixel level mud-water boundary point determination sub-unit is used to find the point with the largest grayscale change rate on the smoothed integral curve and determine whether the grayscale change rate exceeds a preset threshold. If it exceeds the preset threshold, the point with the largest grayscale change rate is taken as the sub-pixel level mud-water boundary point, and the coordinates of the sub-pixel level mud-water boundary point are taken as the column coordinates of the mud-water boundary line.
[0154] In some alternative implementations, the curve fitting module 1004 includes:
[0155] The curve fitting unit is used to extract multiple sub-pixel level mud-water boundary points on the initial contour of the mud-water boundary as multiple detection points, and to fit the multiple detection points with a preset curve fitting algorithm to obtain a continuous boundary curve.
[0156] The mud-water boundary determination unit is used to extract the lowest point of the region projection corresponding to the boundary curve, and obtain the mud-water boundary based on the lowest point of the region projection.
[0157] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0158] In this embodiment, the mud-water boundary detection device is presented in the form of a functional unit. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0159] This invention also provides a computer device having the above-described features. Figure 10 The device shown is for detecting the mud-water boundary.
[0160] Please see Figure 11 , Figure 11 This is a schematic diagram of the structure of a computer device provided in an optional embodiment of the present invention, such as... Figure 11 As shown, the computer device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 11 Take a processor 10 as an example.
[0161] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.
[0162] The memory 20 stores instructions executable by at least one processor 10 to cause the at least one processor 10 to perform the method shown in the above embodiments.
[0163] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0164] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0165] The computer device also includes an input device 30 and an output device 40. The processor 10, memory 20, input device 30, and output device 40 can be connected via a bus or other means. Figure 11 Taking the example of a connection between China and Israel via a bus.
[0166] Input device 30 can receive input numerical or character information, and generate key signal inputs related to user settings and function control of the computer device, such as a touchscreen, keypad, mouse, trackpad, touchpad, joystick, one or more mouse buttons, trackball, joystick, etc. Output device 40 may include display devices, auxiliary lighting devices (e.g., LEDs), and haptic feedback devices (e.g., vibration motors). The aforementioned display devices include, but are not limited to, liquid crystal displays, light-emitting diodes, displays, and plasma displays. In some alternative embodiments, the display device may be a touchscreen.
[0167] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.
[0168] A portion of this invention can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to the invention through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled program, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.
[0169] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A method for detecting the mud-water boundary, characterized in that, The method includes: Images of mud-water stratification during the sedimentation process of chemical wastewater were obtained according to preset observation points; Based on the mud-water layered image and the preset image segmentation network, the mud-water ROI region is obtained; A preset convolution kernel is used to perform grayscale edge detection on the mud-water ROI region to obtain the initial contour of the mud-water boundary. The step of performing grayscale edge detection on the mud-water ROI region using a preset convolution kernel to obtain the initial contour of the mud-water boundary includes: A pre-defined convolution kernel is used to perform convolution operations on the muddy water ROI region; the pre-defined convolution kernel is a convolution kernel with the Y direction from bright to dark designed based on the Sobel operator; A vertical grayscale projection function is constructed based on the mud-water ROI region after convolution operation, and the vertical grayscale projection function is differentially calculated with the smoothed vertical grayscale projection function. The positions where the differential result exceeds a preset threshold are selected as the column coordinates of the mud-water boundary line. Based on the column coordinates, the boundary region is searched cyclically, and the boundary region is optimized using morphological algorithms in image processing to obtain the preliminary region of the mud-water boundary. The intersection of the mud-water ROI region after mask filtering and the preliminary mud-water boundary region is calculated to obtain the initial outline of the mud-water boundary. Curve fitting is performed on multiple detection points on the initial contour of the mud-water boundary to obtain the mud-water boundary.
2. The method according to claim 1, characterized in that, Before using the mud-water layered image and the preset image segmentation network, the method further includes: The mud-water layered image is pre-processed by using a sliding window. Areas whose size after cropping is less than the size of the sliding window are filled with a first preset value, and the pre-processed mud-water layered image is output using a preset image format.
3. The method according to claim 1 or 2, characterized in that, The mud-water ROI region includes the mud level ROI region and the water level ROI region; the process of obtaining the mud-water ROI region based on the mud-water layered image and a preset image segmentation network includes: The pre-processed mud-water layered image is input into a preset image segmentation network for Patch Merge operation and attention calculation with an attention scaling factor to obtain the mud area ROI and water area ROI.
4. The method according to claim 3, characterized in that, The method further includes: After masking the mud area ROI and water level ROI, areas whose mask area does not meet the preset area threshold are removed, and the ordinate of the center position between the remaining mud area ROI and water level ROI is not greater than the second preset value.
5. The method according to claim 1, characterized in that, The step of performing a difference operation between the vertical grayscale projection function and the smoothed vertical grayscale projection function, and selecting the positions where the difference result exceeds a preset threshold as the column coordinates of the mud-water boundary line, includes: A grayscale projection is performed on the muddy water ROI region, that is, the average value of each column of pixels is vertically projected to form a one-dimensional array, and the one-dimensional array is integrated to obtain a smoothed integral curve. Find the point with the largest grayscale change rate on the smoothed integral curve, and determine whether the grayscale change rate exceeds a preset threshold. If it exceeds the preset threshold, take the point with the largest grayscale change rate as the sub-pixel level mud-water boundary point, and take the coordinates of the sub-pixel level mud-water boundary point as the column coordinates of the mud-water boundary line.
6. The method according to claim 5, characterized in that, The step of performing curve fitting on multiple detection points on the initial contour of the mud-water boundary to obtain the mud-water boundary includes: Multiple sub-pixel level mud-water boundary points on the initial contour of the mud-water boundary line are extracted as multiple detection points, and a preset curve fitting algorithm is used to fit the multiple detection points to obtain a continuous boundary line curve. Extract the lowest point of the region projection corresponding to the boundary curve, and obtain the mud-water boundary line based on the lowest point of the region projection.
7. A device for detecting the mud-water boundary, characterized in that, The device includes: The mud-water stratification image acquisition module is used to acquire mud-water stratification images during the sedimentation process of chemical wastewater according to preset observation points; The image segmentation module is used to obtain the mud-water ROI region based on the mud-water layered image and a preset image segmentation network; The grayscale edge detection module is used to perform grayscale edge detection on the mud-water ROI region using a preset convolution kernel to obtain the initial contour of the mud-water boundary. The grayscale edge detection module includes: The convolution unit is used to perform convolution operations on the muddy water ROI region using a preset convolution kernel; the preset convolution kernel is a convolution kernel with the Y direction from bright to dark designed based on the Sobel operator; The grayscale projection unit is used to construct a vertical grayscale projection function based on the mud-water ROI region after convolution operation, and to perform a difference operation between the vertical grayscale projection function and the smoothed vertical grayscale projection function, and to select the position where the difference result exceeds the preset threshold as the column coordinate of the mud-water boundary line. The boundary region optimization unit is used to iteratively search for boundary regions based on column coordinates and optimize the boundary regions using morphological algorithms in image processing to obtain the preliminary region of the mud-water boundary. The initial contour determination unit of the mud-water boundary is used to calculate the intersection of the mud-water ROI region after mask screening and the initial mud-water boundary region to obtain the initial contour of the mud-water boundary. The curve fitting module is used to perform curve fitting on multiple detection points on the initial contour of the mud-water boundary to obtain the mud-water boundary.
8. A computer device, characterized in that, include: A memory and a processor are interconnected, the memory storing computer instructions, and the processor executing the computer instructions to perform the mud-water boundary detection method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to perform the method for detecting the mud-water boundary as described in any one of claims 1 to 6.