Image processing method for coastal engineering water quality detection and related device
By combining high-resolution optical image acquisition and image preprocessing with a water quality identification model, the problem of low efficiency in traditional water quality monitoring has been solved, enabling rapid and accurate water quality detection and supporting marine ecological protection and public environmental safety.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SOUTHERN BRANCH OF CHINA COMM CONSTR CO LTD
- Filing Date
- 2025-12-30
- Publication Date
- 2026-04-17
AI Technical Summary
Traditional water quality monitoring methods are inefficient and cumbersome, making them difficult to respond to sudden pollution incidents.
Water quality is detected by using high-resolution optical image acquisition, image preprocessing, and a trained water quality identification model. The results are then compared and analyzed against a pre-set water quality standard database to generate a water quality test report.
It enables efficient and accurate water quality testing, allowing for rapid response to sudden pollution incidents, reducing labor costs, improving testing efficiency, and supporting marine ecological protection and public environmental safety.
Smart Images

Figure CN121883402A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of coastal engineering technology, and more particularly to an image processing method and related apparatus for coastal engineering water quality detection. Background Technology
[0002] With the development and utilization of global marine resources, the growth of maritime transportation, and the increasing demands for maritime national defense and security, rapid water quality testing has become particularly important. For example, in some coastal engineering construction areas, ship traffic can lead to the discharge of pollutants such as oil spills, heavy metals, and organic wastewater. Water quality testing can accurately locate the pollution sources and their diffusion paths. In addition, construction noise, lighting, and suspended matter can interfere with the migration of sea turtles and the reproduction of fish. Real-time monitoring of water quality changes (such as turbidity and dissolved oxygen) can assess the degree of ecological disturbance and formulate protective measures. At the same time, monitoring nutrient concentrations can provide early warning of red tide risks and prevent large-scale biological deaths caused by eutrophication.
[0003] Currently, traditional water quality monitoring methods typically employ laboratory chemical analysis. However, laboratory chemical analysis is cumbersome, lacks timeliness, and is ill-suited for responding to sudden pollution incidents.
[0004] In summary, traditional water quality monitoring methods suffer from problems such as low efficiency and complex procedures. Therefore, there is an urgent need for an efficient and accurate water quality monitoring solution for coastal engineering projects. Summary of the Invention
[0005] This application provides an image processing method and related apparatus for coastal engineering water quality detection to solve the problems existing in related technologies. The technical solution is as follows: In a first aspect, embodiments of this application provide an image processing method for coastal engineering water quality detection, including: After the water sample is placed in the sample container at regular intervals and stirred evenly, a high-resolution optical image of the water sample is acquired. The water sample is taken from the target coastal engineering construction area where water quality testing is required. The high-resolution optical image is preprocessed by noise filtering, image enhancement and geometric correction to obtain the processed high-resolution optical image. The trained water quality identification model is used to identify the processed high-resolution optical image to obtain water quality identification results, which include predicted values of each target water quality parameter. The water quality identification results are compared and analyzed with a preset water quality standard database to generate a water quality test report.
[0006] In one embodiment, after the water sample is periodically placed into a sample container and stirred evenly, a high-resolution optical image of the water sample is acquired, including: After filtering out large particulate impurities, the raw water samples obtained from the target coastal engineering construction area at regular intervals are poured into the sample container; Stir the water sample in the sample container until it is homogeneous; According to the testing requirements, high-resolution images of the water sample under different light source conditions are collected to obtain the high-resolution optical images.
[0007] In one embodiment, the high-resolution optical image is preprocessed by noise filtering, image enhancement, and geometric correction to obtain a processed high-resolution optical image, including: The high-resolution optical image is denoised by bilateral filtering to obtain a noise-filtered high-resolution optical image. An adaptive logarithmic mapping algorithm is used to perform image enhancement processing on the noise-filtered high-resolution optical image to obtain an enhanced high-resolution optical image. The high-resolution optical image after image enhancement is geometrically corrected using root mean square error to obtain the processed high-resolution optical image.
[0008] In one implementation, the trained water quality identification model is trained in the following manner: A set of target water quality features suitable for water quality classification is selected from a water body database by using recursive feature elimination combined with a random forest regression model. The water body database is a database compiled based on traditional analysis methods. A water quality identification model is constructed based on a convolutional neural network; Based on the target water quality feature set, the water quality identification model is trained using the binary cross-entropy loss function to obtain the trained water quality identification model. When the trained water quality identification model meets the specified evaluation index requirements, the trained water quality identification model is determined as the trained water quality identification model.
[0009] In one implementation, selecting a target water quality feature set suitable for water quality classification from a water body database using recursive feature elimination combined with a random forest regression model includes: Multiple water quality parameters useful for water quality classification are selected from the water body database to form a first water quality feature set; The first water quality feature set is fed into the random forest model, and the random forest model calculates the feature importance value of each water quality parameter in the first water quality feature set. Remove the water quality parameter with the lowest feature importance value from the first water quality feature set, and then combine the remaining water quality parameters to form the second water quality feature set; Replace the second water quality feature set with the first water quality feature set, return to execute the process of feeding the first water quality feature set into the random forest model, and have the random forest model calculate the feature importance value of each water quality parameter in the first water quality feature set; This process is repeated until the final M-th water quality feature set contains only N water quality features. For each water quality feature set obtained, the root mean square error of the random forest model is calculated once, and finally the water quality feature set corresponding to the minimum root mean square error is taken as the target water quality feature set.
[0010] In one embodiment, a trained water quality identification model is used to identify the processed high-resolution optical image to obtain water quality identification results, including: Using the convolutional layers of the trained water quality identification model, multi-level spatial features of the processed high-resolution optical image are extracted through multi-layer convolution and pooling operations to obtain the first set of feature maps. By utilizing the attention mechanism layer of the trained water quality identification model, the first set of feature maps is weighted and focused on information important for water quality classification, resulting in a second set of feature maps rich in discriminative information. The water quality identification result is obtained by classifying the water quality based on the second set of feature maps using the fully connected layer of the trained water quality identification model.
[0011] In one embodiment, the method further includes: An alarm is triggered when the water quality test report determines that there are abnormal pollutants in the target coastal engineering construction area.
[0012] Secondly, embodiments of this application also provide an image processing system for coastal engineering water quality detection, comprising: The acquisition unit is used to stir the water sample placed in the sample container at regular intervals, and then acquire a high-resolution optical image of the water sample, wherein the water sample is taken from the target coastal engineering construction area where water quality testing is required. The processing unit is used to perform noise filtering, image enhancement and geometric correction preprocessing on the high-resolution optical image to obtain the processed high-resolution optical image. The identification unit is used to perform identification processing on the processed high-resolution optical image using a trained water quality identification model to obtain water quality identification results, which include predicted values of each target water quality parameter. The analysis unit is used to compare and analyze the water quality identification results with a preset water quality standard database to generate a water quality test report.
[0013] In one embodiment, when the acquisition unit is used to stir the water sample placed in the sample container at regular intervals and then acquire a high-resolution optical image of the water sample, it is specifically used for: After filtering out large particulate impurities, the raw water samples obtained from the target coastal engineering construction area at regular intervals are poured into the sample container; Stir the water sample in the sample container until it is homogeneous; According to the testing requirements, high-resolution images of the water sample under different light source conditions are collected to obtain the high-resolution optical images.
[0014] In one embodiment, when the processing unit performs noise filtering, image enhancement, and geometric correction preprocessing on the high-resolution optical image to obtain a processed high-resolution optical image, it specifically performs the following: The high-resolution optical image is denoised by bilateral filtering to obtain a noise-filtered high-resolution optical image. An adaptive logarithmic mapping algorithm is used to perform image enhancement processing on the noise-filtered high-resolution optical image to obtain an enhanced high-resolution optical image. The high-resolution optical image after image enhancement is geometrically corrected using root mean square error to obtain the processed high-resolution optical image.
[0015] In one implementation, the trained water quality identification model is obtained by training the identification unit in the following manner: A set of target water quality features suitable for water quality classification is selected from a water body database by using recursive feature elimination combined with a random forest regression model. The water body database is a database compiled based on traditional analysis methods. A water quality identification model is constructed based on a convolutional neural network; Based on the target water quality feature set, the water quality identification model is trained using the binary cross-entropy loss function to obtain the trained water quality identification model. When the trained water quality identification model meets the specified evaluation index requirements, the trained water quality identification model is determined as the trained water quality identification model.
[0016] In one implementation, the identification unit, when selecting a target water quality feature set suitable for water quality classification from a water body database using recursive feature elimination combined with a random forest regression model, specifically performs the following: Multiple water quality parameters useful for water quality classification are selected from the water body database to form a first water quality feature set; The first water quality feature set is fed into the random forest model, and the random forest model calculates the feature importance value of each water quality parameter in the first water quality feature set. Remove the water quality parameter with the lowest feature importance value from the first water quality feature set, and then combine the remaining water quality parameters to form the second water quality feature set; Replace the second water quality feature set with the first water quality feature set, return to execute the process of feeding the first water quality feature set into the random forest model, and have the random forest model calculate the feature importance value of each water quality parameter in the first water quality feature set; This process is repeated until the final M-th water quality feature set contains only N water quality features. For each water quality feature set obtained, the root mean square error of the random forest model is calculated once, and finally the water quality feature set corresponding to the minimum root mean square error is taken as the target water quality feature set.
[0017] In one embodiment, when the recognition unit is used to perform recognition processing on the processed high-resolution optical image using a trained water quality recognition model to obtain a water quality recognition result, it is specifically used for: Using the convolutional layers of the trained water quality identification model, multi-level spatial features of the processed high-resolution optical image are extracted through multi-layer convolution and pooling operations to obtain the first set of feature maps. By utilizing the attention mechanism layer of the trained water quality identification model, the first set of feature maps is weighted and focused on information important for water quality classification, resulting in a second set of feature maps rich in discriminative information. The water quality identification result is obtained by classifying the water quality based on the second set of feature maps using the fully connected layer of the trained water quality identification model.
[0018] In one implementation, the analysis unit is further configured to: An alarm is triggered when the water quality test report determines that there are abnormal pollutants in the target coastal engineering construction area.
[0019] Thirdly, embodiments of this application also provide an electronic device, which includes a memory and a processor, wherein the memory stores instructions, the instructions are loaded and executed by the processor to implement the methods in any of the above embodiments, wherein the memory and the processor communicate with each other through an internal connection path.
[0020] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when run on a computer, implements the methods in any of the above-described embodiments.
[0021] The advantages or beneficial effects of the above technical solutions include at least the following: (I) Technical Aspects: High-resolution optical images of water samples are acquired after sampling (e.g., using industrial or spectral cameras), enabling more accurate acquisition of detailed features without interference from complex external environments, thus improving the stability and reliability of the acquired images. Furthermore, various preprocessing methods are employed to effectively improve image quality, laying a solid foundation for subsequent feature extraction and analysis. Additionally, a pre-trained water quality identification model (using an improved convolutional neural network algorithm combined with an attention mechanism) allows for more accurate extraction of water quality-related features. Moreover, comparative analysis with a pre-set water quality standard database enables rapid and accurate assessment of water quality conditions and the generation of water quality testing reports, facilitating rapid response to sudden pollution incidents and providing a scientific basis for water quality management and protection in coastal engineering. The entire water quality testing process is simple to operate, highly automated, reduces labor costs, improves testing efficiency, and has broad application prospects. (II) Social Level: By adopting regular monitoring of water quality changes (such as turbidity, dissolved oxygen, pollutant concentration, etc.), ecological risks such as red tides and oil spills can be quickly warned, providing data support for the protection of marine life such as sea turtle migration and fish reproduction, helping to maintain the balance of marine ecology, and ensuring the coordinated development of coastal engineering construction and ecological protection; in response to sudden pollution incidents caused by ship navigation and engineering construction, it can also quickly locate the pollution source and diffusion path, providing decision-making basis for emergency response by environmental protection, water conservancy and other departments, reducing the threat of pollutants to the drinking water safety of coastal residents and fishery production, and improving the level of public environmental safety; in addition, the visualized water quality test reports can be made public to help the public intuitively understand the marine water quality status, enhance their attention and participation in marine environmental protection, and promote the formation of a good atmosphere for the whole society to jointly protect the marine ecology.
[0022] (III) Economic Aspects: Compared with traditional laboratory chemical analysis methods and chromatography-mass spectrometry, the embodiments of this application achieve rapid water quality detection through image processing and deep learning models, reducing the consumption of chemical reagents, equipment maintenance, and manual operation costs. In addition, it can shorten the real-time monitoring response time of water quality, significantly improving efficiency compared with traditional methods, enabling rapid response to sudden pollution events, and reducing economic losses such as fishery losses and project shutdowns caused by pollution spread.
[0023] In summary, this application enables efficient and accurate water quality testing for coastal engineering projects, and allows for rapid response to sudden pollution incidents.
[0024] The above overview is for illustrative purposes only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments, and features described above, further aspects, embodiments, and features of this application will become readily apparent from the accompanying drawings and the following detailed description. Attached Figure Description
[0025] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the various drawings denote the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings depict only some embodiments disclosed in this application and should not be construed as limiting the scope of this application.
[0026] Figure 1 A flowchart illustrating an image processing method for coastal engineering water quality detection provided in this application embodiment; Figure 2 A flowchart illustrating another image processing method for coastal engineering water quality detection provided in this application embodiment; Figure 3 A structural block diagram of an image processing system for coastal engineering water quality detection provided in this application embodiment; Figure 4 This is a structural block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0027] In the following description, only certain exemplary embodiments are briefly described. As those skilled in the art will recognize, the described embodiments can be modified in various ways without departing from the spirit or scope of this application. Therefore, the drawings and description are considered to be exemplary in nature and not restrictive.
[0028] Among related technologies, existing laboratory chemical analysis methods mainly employ the following: (1) Spectroscopic analysis By detecting the absorption or emission of light at specific wavelengths in a water sample, the types and concentrations of pollutants can be accurately identified. For example, ultraviolet-visible spectroscopy (UV-Vis) can detect indicators such as chemical oxygen demand (COD) and ammonia nitrogen with an error range of less than 5%, making it particularly suitable for rapid screening of organic matter and heavy metals.
[0029] (2) Electrochemical sensing method Based on ion-selective electrodes (ISE) and voltammetry, parameters such as pH, dissolved oxygen (DO), and conductivity can be directly measured. For example, pH detection must use the electrode method, and its response time can be shortened to within 3 seconds.
[0030] (3) Biosensing method Biochemical oxygen demand (BOD) and toxic substances can be detected by utilizing the specific reactions of microorganisms or enzymes with pollutants. For example, the luminescent bacteria method can assess the overall toxicity of water samples with a sensitivity of up to 0.1 mg / L.
[0031] (4) Chromatography-mass spectrometry Gas chromatography (GC) and high-performance liquid chromatography (HPLC) combined with mass spectrometry (MS) can detect trace amounts of volatile organic compounds (VOCs) and polycyclic aromatic hydrocarbons (PAHs).
[0032] (5) Spectrophotometry The concentration is calculated by measuring the absorbance of the target substance in the sample after it reacts with a specific reagent, combined with a standard curve. For example, COD, ammonia nitrogen, and total phosphorus analyzers use this method to achieve rapid and accurate detection of COD, ammonia nitrogen, and total phosphorus.
[0033] In summary, while existing laboratory chemical analysis methods can accurately detect corresponding water quality parameters, their procedures are cumbersome, their timeliness is poor, and they are difficult to respond to sudden pollution incidents.
[0034] Based on this, the embodiments of this application provide an image processing scheme for coastal engineering water quality detection, which can realize efficient and accurate coastal engineering water quality detection, so as to quickly respond to sudden pollution events.
[0035] The relevant technical solutions provided in the embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0036] Figure 1 A flowchart illustrating an image processing method for coastal engineering water quality detection according to an embodiment of this application is shown. Figure 1 As shown, the method may include the following steps: S110. After the water sample placed in the sample container at regular intervals is stirred evenly, a high-resolution optical image of the water sample is acquired.
[0037] In practice, the water sample is taken from the target coastal engineering construction area, which is the coastal engineering construction area that requires water quality testing.
[0038] In one implementation, the sample container may be a transparent quartz container to reduce optical interference.
[0039] In one implementation, the process of step S110 may include the following sub-steps: S111. After filtering out large particulate impurities from the raw water samples obtained at regular intervals from the target coastal engineering construction area, pour the samples into a sample container.
[0040] In practice, these large particulate impurities may include, but are not limited to, mud, sand, and pebbles.
[0041] In practice, the time interval can be set according to actual needs. For example, considering that water pollution is a gradual process, it can be set to take samples from the target coastal engineering construction area every 30 minutes. This will facilitate timely monitoring of the water quality in the target coastal engineering construction area.
[0042] In this embodiment of the application, by executing sub-step S111, the detection target in the water sample can be avoided from being blocked by large particulate impurities, and at the same time, it is convenient to monitor the water quality of the target coastal engineering construction area in a timely manner.
[0043] S112. Stir the water sample in the sample container until it is homogeneous.
[0044] As an example, a hardware control device can be used to control an automatic stirrer to mix the water sample in the sample container evenly. This hardware control device can be, but is not limited to, an MCU microcontroller or an embedded motherboard (such as a Raspberry Pi). In this example, the stirring time of the automatic stirrer can be set according to actual needs, as long as it ensures the water quality of the water sample in the sample container is uniform; this embodiment of the application does not impose any limitations on this.
[0045] In this embodiment of the application, by performing step S112, it can be ensured that the water quality of the water sample is uniform before the image is acquired.
[0046] S113. According to the requirements of the detection indicators, high-resolution images of the water sample under different light source conditions are collected to obtain the high-resolution optical image.
[0047] As an example, a hardware control device can be used to automatically adjust the color and brightness of the light source illuminating the water sample, and simultaneously control an image acquisition device to capture high-resolution images of the water sample under different light source conditions, thus obtaining the high-resolution optical image. In this example, the hardware control device can be used to control the synchronous operation of the light source device and the image acquisition device.
[0048] In this example, the light source device may include, but is not limited to, uniform illumination lamps and controllable light source modules, to ensure uniform image brightness, enabling the image acquisition device to capture more details to adapt to different detection index requirements. The image acquisition device may include, but is not limited to, high-resolution industrial cameras, spectral cameras, microscope lenses, and filters, for acquiring high-resolution optical images of water samples.
[0049] In this embodiment of the application, by executing sub-step S113, the high-resolution optical image acquired can highlight the details of suspended particulate matter in the water sample, which is convenient for subsequent accurate identification.
[0050] In this embodiment of the application, by performing step S110, high-quality, high-resolution optical images can be acquired, which facilitates the accuracy of subsequent image recognition.
[0051] In an applicable scenario, equipment calibration and checks can be performed before step S110, i.e. before the task begins. For example, the automatic stirrer, hardware control device, light source device, image acquisition device, and data processing device (described below) can be calibrated and checked to ensure that the equipment is working properly.
[0052] S120. Perform noise filtering, image enhancement and geometric correction preprocessing on the high-resolution optical image to obtain the processed high-resolution optical image.
[0053] In one implementation, the process of step S120 may include the following sub-steps: S121. The high-resolution optical image is denoised by bilateral filtering to obtain a noise-filtered high-resolution optical image.
[0054] In practical applications, the high-resolution optical images (i.e., digital images) acquired are affected by noise interference from imaging equipment and the external environment during digitization and transmission. Therefore, it is necessary to perform noise filtering preprocessing on the high-resolution optical images to make them clearer.
[0055] In practice, bilateral filtering combines two weighting considerations: spatial distance and pixel value similarity. Assuming... These are the original pixel values of this high-resolution optical image. These are the filtered pixel values. It is a spatial domain Gaussian kernel, controlled by sigma space (a spatial domain parameter), which measures the spatial distance between pixels. It is a Gaussian kernel with a range, controlled by sigma Color (range parameter), which measures the similarity of pixel values. The weight calculation formula for bilateral filtering is shown in the following formula (1).
[0056] (1) in, It is a normalization factor, which is a normalization factor for all weights. The summation result serves to ensure the reasonableness of the filtering result; it is not a constant value and will vary with factors such as pixel position. This indicates the target pixel in the high-resolution optical image that needs to be filtered. Indicates at the target pixel neighborhood Other pixels within; Indicates target pixels The neighborhood range centered on the center is the region of surrounding pixels considered when performing bilateral filtering.
[0057] In this embodiment of the application, by performing sub-step S121, the high-resolution optical image can be made clearer, which facilitates the subsequent improvement of the accuracy of image recognition.
[0058] In an applicable scenario, before performing sub-step S121, the noise reduction effect of bilateral filtering can be tested using standard water sample optical images. This facilitates the removal of abnormal data and the adjustment of sigma space and sigma color to ensure that image details are not lost after noise reduction, and can also improve data processing speed.
[0059] S122. An adaptive logarithmic mapping algorithm is used to perform image enhancement processing on the noise-filtered high-resolution optical image to obtain the enhanced high-resolution optical image.
[0060] In practice, in order to enhance the useful information in the high-resolution optical image and improve its visual effect, it is necessary to perform image enhancement preprocessing on the high-resolution optical image to purposefully emphasize the overall or local characteristics of the high-resolution optical image, make the originally unclear areas in the high-resolution optical image clear or emphasize certain features of interest, expand the differences between the features of different objects in the high-resolution optical image, and suppress non-target features, thereby improving the quality of the high-resolution optical image and enriching its information content.
[0061] In practical implementation, we can assume that It is the input brightness value of the input image (i.e., the high-resolution optical image after noise filtering). It is the maximum brightness value of the input image. The output brightness value is the output image (i.e., the high-resolution optical image after image enhancement). The bias parameter controls the overall brightness tone in the adaptive logarithmic mapping algorithm. By analyzing the brightness distribution characteristics of the input image, the adaptive logarithmic mapping algorithm can intelligently adjust this parameter. Therefore, the adaptive logarithmic mapping algorithm can be used to perform image enhancement processing on the noise-filtered high-resolution optical image using the following formula (2) to obtain the image-enhanced high-resolution optical image.
[0062] (2) Where s is a scaling factor used to scale the result after logarithmic mapping to adjust the overall range of image brightness; t max is the target maximum brightness value, which is the maximum brightness level that the enhanced image is expected to achieve; p is the target brightness; c is the current brightness; is a coefficient.
[0063] In this embodiment of the application, by executing sub-step S122, the quality of the high-resolution optical image can be improved and the amount of information enriched, thereby enhancing the image interpretation and recognition effect of the high-resolution optical image and meeting the needs of analysis.
[0064] In an applicable scenario, before executing sub-step S122, the bias parameters of standard images with different brightness levels can be calibrated for the adaptive logarithmic mapping algorithm to avoid over-enhancement or brightness distortion.
[0065] S123. The root mean square error is used to perform geometric correction on the enhanced high-resolution optical image to obtain the processed high-resolution optical image.
[0066] In practice, the geometric correction accuracy of control points in the enhanced high-resolution optical image can be observed through the root mean square error (RMS), where the unit of control point is a pixel.
[0067] As an example, if and The x and y coordinates represent the reference point in the enhanced high-resolution optical image. and Let x and y represent the x and y coordinates of the corrected point in the high-resolution optical image after image enhancement. Then the expression formula for RMS can be shown in the following formula (3).
[0068] (3) In this embodiment of the application, by executing sub-step S123, the accuracy of the high-resolution optical image can be improved, thereby further enhancing the image interpretation and recognition effect of the high-resolution optical image and meeting the needs of analysis.
[0069] In this embodiment of the application, by executing step S120, the acquired high-resolution optical image can be processed and corrected, including noise filtering, image enhancement and geometric correction, so as to enhance the image interpretation and recognition effect of the high-resolution optical image and meet the needs of analysis.
[0070] S130. The trained water quality identification model is used to identify the processed high-resolution optical image to obtain the water quality identification result.
[0071] In one implementation, the water quality identification result includes predicted values for each target water quality parameter. Each target water quality parameter is the water quality parameter corresponding to the target water quality feature set described below.
[0072] In one implementation, the trained water quality identification model is obtained through the following method: 1. Feature Selection Feature selection, also known as feature subset selection or attribute selection, refers to choosing N features from M existing features to optimize a specific metric. For example, it's the process of selecting the most effective features from the original set to reduce the dimensionality of the dataset. It's an important method for improving the performance of learning algorithms. Feature selection has two main purposes: first, to reduce the number of features and dimensionality, thereby improving the model's generalization ability and reducing overfitting; second, to enhance the understanding of the relationship between features and feature values. Generally, feature selection is considered from the following two aspects: (1) Whether the feature is divergent: If a feature is not divergent, for example, if the variance is close to 0, that is, the samples are basically the same in terms of this feature, this feature is not useful for distinguishing the samples.
[0073] (2) Relevance of features to the target: This is quite obvious. Features that are highly relevant to the target should be selected first.
[0074] Based on this, the embodiments of this application employ Recursive Feature Elimination (REF) combined with a random forest regression model to select a target water quality feature set suitable for water quality classification from a water body database. The water body database is a database compiled based on traditional water quality monitoring methods.
[0075] In practice, the feature selection process may include the following sub-steps: 1.1 Select multiple water quality parameters (such as color, turbidity, pH value, conductivity, dissolved oxygen, etc.) that are useful for water quality classification from the water body database to form the first water quality feature set.
[0076] As an example, if all water quality parameters involved in the water body database can be classified, then all water quality parameters in the water body database can be selected as multiple water quality parameters to form the first water quality feature set.
[0077] 1.2 Feed the first water quality feature set into the random forest model, and the random forest model calculates the feature importance value of each water quality parameter in the first water quality feature set.
[0078] In practice, the random forest model can divide the input space (i.e., the first water quality feature set) into multiple regions using decision trees, and assign predicted values to each sample (i.e., water quality parameters) in multiple regions.
[0079] For example, suppose there is a regression problem in the first water quality feature set, where the input feature is XERT and the output target variable is yER. For each sample in the first water quality feature set, the random forest model can select the best feature ag and its splitting value t through a tree structure, thereby dividing the first water quality feature set into the following two parts: , (4) In formula (4), This indicates that at water quality parameter j, the value is less than or equal to the dividing value t. j The region formed by the samples; This indicates that at water quality parameter j, the value is greater than the cutoff value t. j The region formed by the samples; X represents the feature vector of the input sample; X j t represents the j-th water quality parameter in the feature vector of the input sample; j This represents the segmentation value of water quality parameter j.
[0080] Therefore, the predicted value output of the decision tree in the random forest model can be represented by the following formula (5).
[0081] (5) In formula (5), It is the prediction value of the decision tree for the sample vector X; It is region R k Number of internal samples; It is region R k Inner p The target variable values for each sample.
[0082] Furthermore, the predicted output of the random forest model can be represented by the following formula (6).
[0083] (6) In formula (6), This represents the final predicted value obtained by averaging the predictions of the T decision trees in the random forest model; T represents the number of decision trees in the random forest model. Let represent the prediction value of the t-th decision tree in the random forest model for the sample vector X.
[0084] During this period, the random forest model can use feature importance values as a quantitative indicator of feature importance. For example, the random forest model can use the following formula (7) to calculate the water quality parameter x, which represents the cumulative reduction in impurity. j The feature importance value.
[0085] (7) In formula (7), It is water quality parameter x j The feature importance value; This indicates the relationship between the water quality parameter x and the decision tree in the t-th decision tree. j Related splits; This represents the increment in importance resulting from splitting s in the t-th decision tree.
[0086] 1.3 Remove the water quality parameters with the lowest feature importance value from the first water quality feature set, and then combine the remaining water quality parameters to form the second water quality feature set.
[0087] That is, in each round of feature elimination, the feature importance value can be used as a criterion. To remove the water quality parameters that contribute the least, that is, to remove those with the least contribution. Minimum water quality parameter.
[0088] 1.4 Replace the second water quality feature set with the first water quality feature set, and return to execute 1.3.
[0089] 1.5. Repeat this process (i.e., repeat steps 1.2-1.4 above) until the final water quality feature set contains only N water quality features.
[0090] In specific implementation, N can be set to an integer ≥1, and its value is determined according to actual needs, such as N=2. This application embodiment does not limit this.
[0091] 1.6 For each water quality feature set obtained, calculate the root mean square error of the random forest model once, and finally take the water quality feature set corresponding to the minimum root mean square error as the target water quality feature set.
[0092] In practice, as recursive feature elimination progresses, the number of water quality parameters can be continuously reduced, and the RMSE of the random forest model is calculated after each training round. Finally, by comparing the RMSEs of all water quality feature sets, the water quality feature set with the smallest RMSE is selected as the final water quality feature set. (i.e., the target water quality feature set), this process can be represented by the following formula (8). This can be understood as, for the current water quality feature set... In this embodiment, cross-validation is used to train a random forest model, and the root mean square error (RMSE) is calculated to evaluate the model performance.
[0093] (8) In formula (8), It is the water quality feature set in the k-th round of recursive elimination; y h It is the actual value. Through water quality feature set The predicted value; H represents the water quality feature set. The number of samples.
[0094] In this embodiment, by employing recursive feature elimination (REF) combined with a random forest regression model to select the most suitable target water quality feature set for water quality classification and identification from the water body database, the efficiency of processing high-dimensional data and nonlinear relationships can be improved.
[0095] 2. Model Selection Convolutional Neural Networks (CNNs) are a type of feedforward neural network that incorporates convolutional computations and has a deep structure. CNNs were inspired by the biological mechanism of receptive fields. They are specifically designed to process data with grid-like structures.
[0096] Based on this, the embodiments of this application construct a water quality identification model based on a convolutional neural network.
[0097] 3. Model Training In practical implementation, the water quality identification model can be trained using the binary cross-entropy loss function based on the target water quality feature set to obtain the trained water quality identification model.
[0098] As an example, the binary cross-entropy loss function can be represented by the following formula (9).
[0099] (9) In formula (9), b refers to the predicted output of the water quality identification model. After processing by the sigmoid function, the probability estimate of the sample belonging to the positive class is obtained, which is between 0 and 1; d represents the true label of the sample, which is a discrete value. In binary classification tasks, it is usually taken as 0 or 1, where 1 represents the positive class and 0 represents the negative class. This represents the predicted value of the water quality identification model for the variable y.
[0100] 4. Model Evaluation Model evaluation is the process of assessing the performance of a water quality identification model to determine whether the model is capable of performing water quality classification and identification tasks.
[0101] Based on this, the evaluation index requirements of the water quality identification model can be set in advance, so that when the water quality identification model after evaluation meets the specified evaluation index requirements, the trained water quality identification model is determined as a well-trained water quality identification model.
[0102] As an example, evaluation metrics may include, but are not limited to: accuracy (the ratio of correctly predicted samples to the total number of samples), confusion matrix (a matrix showing the difference between the model's predictions and the actual results), ROC curve and AUC value (used to evaluate the performance of binary classification models), and cross-validation (evaluating the model's generalization ability by splitting the dataset multiple times).
[0103] In this embodiment of the application, the usability of the trained water quality identification model can be confirmed through model evaluation, so that the trained water quality identification model that meets the specified evaluation index requirements can be put into practical application.
[0104] In this embodiment of the application, the training method described above enables the trained water quality identification model to integrate multiple sensor data (such as pH sensor data, conductivity sensor data, dissolved oxygen sensor data, etc.) for fusion identification. Furthermore, by learning from the traditional water quality analysis database (i.e., the aforementioned water body database), a corresponding water quality identification model (i.e., the trained water quality identification model) is trained. This allows for real-time detection of water quality using the trained water quality identification model. Compared to traditional water quality monitoring methods, the procedure is simpler, takes less time, and is less expensive. At the same time, it helps verify the reliability of detection results in the traditional water quality analysis database, reducing the possibility of false detections by the trained water quality identification model.
[0105] In a suitable scenario, a dynamic task scheduling mechanism can be introduced during the training process to optimize system resources. For example, computing resources can be automatically allocated based on the amount of data to avoid a single task consuming too many resources. In addition, for model training, transfer learning methods can be used to fine-tune the pre-trained water quality identification model, reducing training time in new scenarios and improving data processing speed.
[0106] In one implementation, the process of step S130 may include the following sub-steps: S131. Using the convolutional layer of the trained water quality identification model, extract the multi-level spatial features of the processed high-resolution optical image to obtain the first set of feature maps.
[0107] In practical implementation, the convolutional layers of the trained water quality identification model can be used to extract multi-level spatial features of the processed high-resolution optical image through multi-layer convolution and pooling operations to obtain the first set of feature maps.
[0108] For example, in current CNN models for image processing, feature extraction begins with an initial set of measurement data and establishes derived values (features) designed to provide information and avoid redundancy, thereby facilitating subsequent learning and generalization steps and, in some cases, improving interpretability. The precise definition of features is often determined by the problem or application type, and in this embodiment, useful features for the user include the color, turbidity, and light refraction of the water sample.
[0109] Based on this, in the embodiments of this application, the study of image feature extraction by the convolutional layers of the trained water quality identification model can be divided into the following two types: One-dimensional curve features can be addressed using differencing, for example, since in practical applications, we often only have some known data points. Given z = 1, 2, 3, ..., Z, and without knowing the analytical expression of the function, this embodiment of the application discretizes the above formula to obtain the following approximate value of the derivative for each data point, i.e., the difference quotient: (10) In formula (10), when the increment of the independent variable is always 1, that is... , , .
[0110] The characteristics of a two-dimensional curve can be solved by gradient. For example, the gradient of a point can be represented by the vector composed of the difference between the x-axis and y-axis. Assuming that the surface equation is z=f(x,y), the two components of the gradient of a point (x,y) can be represented by the following formulas (11) and (12).
[0111] (11) (12) If we denote the image pixel matrix as im, then the feature calculation formula at point (i, j) can be simplified to the following formula (13).
[0112] (13) After the above feature extraction process, the convolutional layer of the trained water quality identification model can extract the multi-level spatial features of the processed high-resolution optical image, and obtain the first set of feature maps.
[0113] In this embodiment of the application, by executing sub-step S131, the first set of feature maps that can be extracted contains information about different positions and channels in the processed high-resolution optical image, so as to facilitate accurate identification of the water quality status of the water sample in the future.
[0114] S132. Using the attention mechanism layer of the trained water quality identification model, the information important for water quality classification in the first set of feature maps is weighted and focused to obtain a second set of feature maps rich in discriminative information.
[0115] In practical implementation, when the attention mechanism layer of the trained water quality identification model processes the first set of feature maps, it can focus on the information most relevant to water quality classification in the first set of feature maps, while ignoring less important information. For example, it can automatically learn the importance weights of different spatial locations or channels in the first set of feature maps, and perform weighted fusion or adjustment on the first set of feature maps according to these weights, thereby strengthening the response of key areas or feature channels closely related to water quality classification in the first set of feature maps, suppressing the influence of irrelevant or secondary information, and outputting a second set of feature maps rich in discriminative information.
[0116] For example, the attention mechanism layer of the trained water quality identification model can be based on the linear transformation and dot product attention mechanism formula (i.e., the formula (14) below) to achieve the second set of feature maps rich in discriminative information by weighted focusing on the information important for water quality classification in the first set of feature maps.
[0117] (14) In formula (14), Q represents the "query" information that needs to be focused on in the first set of feature maps. It can be understood as a "question" issued when wanting to obtain relevant information, which is used to match with other information (through K) to find the most relevant content; K is used to match with Q to calculate the relevance; each V has a corresponding K, and the importance of V is determined by calculating the similarity between Q and K; V is the effective information that will be focused on and extracted in the first set of feature maps; when Q and K match with high relevance, the corresponding V will be given a higher weight, thus occupying a more important position in the output of the attention mechanism.
[0118] In this embodiment of the application, by executing sub-step S132, the features ultimately used for classification in the processed high-resolution optical image can focus more on information about which regions.
[0119] S133. Using the fully connected layer of the trained water quality identification model, classification is performed based on the second set of feature maps to obtain the water quality identification results.
[0120] In practice, the second set of feature maps can be flattened (or global pooling can be performed first and then flattened) to convert it into a one-dimensional feature vector (which incorporates attention information). This feature vector is then input into the fully connected layer of the trained water quality identification model. The fully connected layer performs comprehensive analysis and mapping based on this feature vector and finally outputs the water quality identification result.
[0121] In this embodiment of the application, by executing sub-step S133, the current accurate water quality identification result can be output.
[0122] That is, step S130 above includes data processing procedures such as image segmentation, feature extraction, binarization, morphological operations and image fusion.
[0123] As an example, steps S120 and S130 described above can be performed using a data processing device, which includes a high-performance computer deployed with the trained water quality identification model described above.
[0124] S140. Compare and analyze the water quality identification results with the preset water quality standard database to generate a water quality test report.
[0125] In one implementation, the water quality test report may include detailed information on water quality status, such as whether the water is polluted (if so, whether the degree of pollution is light, moderate or heavy), water quality grade, predicted values of each target water quality parameter, and information on abnormal indicators (target water quality parameters whose predicted values are abnormal).
[0126] In practice, the water quality identification results can be compared and analyzed with a preset water quality standard database to determine the water quality status and generate a water quality test report.
[0127] In this embodiment of the application, by executing step S140, a water quality test report of the target coastal engineering construction area can be obtained in a timely manner, realizing rapid detection of marine water quality. It has real-time and high efficiency, can quickly respond to sudden pollution events, meets various marine engineering needs, and can thus provide support for marine development and management.
[0128] In an applicable scenario, wireless communication methods (such as 5G wireless communication) can be used to transmit the high-resolution optical image in step S110, the processed high-resolution optical image in step S120, the water quality identification result in step S130, and the water quality test report in step S140 to the background database in real time. The background database will then store these data in a high-capacity storage device (such as a solid-state drive) to facilitate the retrieval, analysis, and application of this data, and to ensure the security and integrity of this data.
[0129] As an example, step S140 described above can also be performed using a data processing device.
[0130] In an applicable scenario, combined with Figure 1 and Figure 2 As shown in the embodiments of this application, the image processing method for coastal engineering water quality detection may further include the following steps: S150. When an abnormality in pollutants is determined to exist in the target coastal engineering construction area based on the water quality test report, an alarm is triggered.
[0131] For example, if the water quality test report can include the following information: the degree of water pollution is moderate or severe, and the predicted value of the abnormal indicator is greater than the preset threshold, then it can be determined that there is an abnormality of pollutants in the target coastal engineering construction area, and an alarm can be triggered, such as sending alarm information to the monitoring center or the terminal of the monitoring personnel in the target coastal engineering construction area, and / or triggering the buzzer in the monitoring center to sound an alarm.
[0132] In this embodiment of the application, by executing step S150, the monitoring personnel of the target coastal engineering construction area can promptly detect abnormal water quality in the target coastal engineering construction area, and further respond quickly to sudden pollution incidents.
[0133] As an example, step S150 described above can also be performed using a data processing device.
[0134] In summary, the image processing method for coastal engineering water quality detection provided in this application embodiment can achieve the following effects: (I) Technical Aspects: High-resolution optical images of water samples are acquired after sampling (e.g., using industrial or spectral cameras), enabling more accurate acquisition of detailed features without interference from complex external environments, thus improving the stability and reliability of the acquired images. Furthermore, various preprocessing methods are employed to effectively improve image quality, laying a solid foundation for subsequent feature extraction and analysis. Additionally, a pre-trained water quality identification model (using an improved convolutional neural network algorithm combined with an attention mechanism) allows for more accurate extraction of water quality-related features. Moreover, comparative analysis with a pre-set water quality standard database enables rapid and accurate assessment of water quality conditions and the generation of water quality testing reports, facilitating rapid response to sudden pollution incidents and providing a scientific basis for water quality management and protection in coastal engineering. The entire water quality testing process is simple to operate, highly automated, reduces labor costs, improves testing efficiency, and has broad application prospects. (II) Social Level: By adopting regular monitoring of water quality changes (such as turbidity, dissolved oxygen, pollutant concentration, etc.), ecological risks such as red tides and oil spills can be quickly warned, providing data support for the protection of marine life such as sea turtle migration and fish reproduction, helping to maintain the balance of marine ecology, and ensuring the coordinated development of coastal engineering construction and ecological protection; in response to sudden pollution incidents caused by ship navigation and engineering construction, it can also quickly locate the pollution source and diffusion path, providing decision-making basis for emergency response by environmental protection, water conservancy and other departments, reducing the threat of pollutants to the drinking water safety of coastal residents and fishery production, and improving the level of public environmental safety; in addition, the visualized water quality test reports can be made public to help the public intuitively understand the marine water quality status, enhance their attention and participation in marine environmental protection, and promote the formation of a good atmosphere for the whole society to jointly protect the marine ecology.
[0135] (III) Economic Aspects: Compared with traditional laboratory chemical analysis methods and chromatography-mass spectrometry, the embodiments of this application achieve rapid water quality detection through image processing and deep learning models, reducing the consumption of chemical reagents, equipment maintenance, and manual operation costs. In addition, it can shorten the real-time monitoring response time of water quality, significantly improving efficiency compared with traditional methods, enabling rapid response to sudden pollution events, and reducing economic losses such as fishery losses and project shutdowns caused by pollution spread.
[0136] In summary, the image processing method for coastal engineering water quality detection provided in this application embodiment can achieve efficient and accurate coastal engineering water quality detection and can quickly respond to sudden pollution events.
[0137] Figure 3 This diagram illustrates the structural block diagram of an image processing system for coastal engineering water quality detection according to an embodiment of this application. Figure 3 As shown, the system may include: The acquisition unit 210 is used to stir the water sample placed in the sample container at regular intervals, and then acquire a high-resolution optical image of the water sample. The water sample is taken from the target coastal engineering construction area where water quality testing is required. Processing unit 220 is used to perform noise filtering, image enhancement and geometric correction preprocessing on high-resolution optical images to obtain processed high-resolution optical images; The recognition unit 230 is used to perform recognition processing on the processed high-resolution optical image using a trained water quality recognition model to obtain water quality recognition results, which include predicted values of each target water quality parameter. The analysis unit 240 is used to compare and analyze the water quality identification results with a preset water quality standard database and generate a water quality test report.
[0138] In one embodiment, when the acquisition unit 210 is used to acquire a high-resolution optical image of the water sample after it has been stirred and homogenized in a sample container at regular intervals, it is specifically used for: After filtering out large particulate impurities, the raw water samples obtained from the target coastal engineering construction area at regular intervals are poured into the sample container. Stir the water sample in the sample container until it is thoroughly mixed; According to the testing requirements, high-resolution images of water samples were collected under different light source conditions to obtain high-resolution optical images.
[0139] In one embodiment, when processing unit 220 performs noise filtering, image enhancement, and geometric correction preprocessing on a high-resolution optical image to obtain a processed high-resolution optical image, it specifically performs the following: Bilateral filtering is used to reduce noise in high-resolution optical images to obtain noise-filtered high-resolution optical images. An adaptive logarithmic mapping algorithm is used to perform image enhancement processing on the noise-filtered high-resolution optical image to obtain the enhanced high-resolution optical image. The root mean square error is used to perform geometric correction on the enhanced high-resolution optical image to obtain the processed high-resolution optical image.
[0140] In one implementation, the trained water quality identification model is obtained by the identification unit 230 through the following method: A recursive feature elimination combined with a random forest regression model is used to select a target water quality feature set suitable for water quality classification from a water body database. The water body database is a database compiled based on traditional analysis methods. A water quality identification model is constructed based on a convolutional neural network; Based on the target water quality feature set, the water quality identification model is trained using the binary cross-entropy loss function to obtain the trained water quality identification model. When the trained water quality identification model meets the specified evaluation index requirements, the trained water quality identification model is determined as the well-trained water quality identification model.
[0141] In one implementation, when the identification unit 230 selects a target water quality feature set suitable for water quality classification from a water body database using recursive feature elimination combined with a random forest regression model, it is specifically used for: Multiple water quality parameters useful for water quality classification are selected from the water body database to form the first water quality feature set; The first water quality feature set is fed into the random forest model, and the random forest model calculates the feature importance value of each water quality parameter in the first water quality feature set. Remove the water quality parameters with the lowest feature importance value from the first water quality feature set, and then combine the remaining water quality parameters to form the second water quality feature set; Replace the second water quality feature set with the first water quality feature set, return to execute the process of feeding the first water quality feature set into the random forest model, and have the random forest model calculate the feature importance value of each water quality parameter in the first water quality feature set; This process is repeated until the final M-th water quality feature set contains only N water quality features. For each water quality feature set obtained, the root mean square error of the random forest model is calculated once, and finally the water quality feature set corresponding to the minimum root mean square error is taken as the target water quality feature set.
[0142] In one embodiment, when the identification unit 230 performs identification processing on the processed high-resolution optical image using a trained water quality identification model to obtain a water quality identification result, it is specifically used for: Using the convolutional layers of the trained water quality identification model, multi-level spatial features of the processed high-resolution optical image are extracted through multi-layer convolution and pooling operations to obtain the first set of feature maps. By utilizing the attention mechanism layer of the trained water quality identification model, the information important for water quality classification in the first set of feature maps is weighted and focused to obtain a second set of feature maps rich in discriminative information. The water quality identification result is obtained by classifying the water quality based on the second set of feature maps using the fully connected layer of the trained water quality identification model.
[0143] In one implementation, the analysis unit 240 is further configured to: An alarm is triggered when an abnormality in pollutants is determined based on a water quality test report in the target coastal engineering construction area.
[0144] The functions of each unit in the image processing system for coastal engineering water quality detection in this application embodiment can be found in the corresponding description in the above method, and will not be repeated here.
[0145] Figure 4 A structural block diagram of an electronic device according to an embodiment of this application is shown. Figure 4 As shown, the electronic device includes a memory 310 and a processor 320. The memory 310 stores instructions, which are loaded and executed by the processor 320 to implement the image processing method for coastal engineering water quality detection in the above embodiment. The number of memories 310 and processors 320 can be one or more.
[0146] The electronic device also includes: The communication interface 330 is used to communicate with external devices and perform data exchange and transmission.
[0147] If the memory 310, processor 320, and communication interface 330 are implemented independently, they can be interconnected via a bus to communicate with each other. This bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 4The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0148] Optionally, in a specific implementation, if the memory 310, processor 320 and communication interface 330 are integrated on a single chip, the memory 310, processor 320 and communication interface 330 can communicate with each other through an internal interface.
[0149] This application provides a computer-readable storage medium storing a computer program. When the computer program is run on a computer, it implements the method provided in this application.
[0150] This application also provides a chip, which includes a processor for calling and executing instructions stored in a memory, causing a communication device with the chip installed to perform the method provided in this application.
[0151] This application also provides a chip, including: an input interface, an output interface, a processor, and a memory. The input interface, output interface, processor, and memory are connected through an internal connection path. The processor is used to execute code in the memory. When the code is executed, the processor is used to execute the method provided in the application embodiment.
[0152] It should be understood that the aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. General-purpose processors can be microprocessors or any conventional processor. It is worth noting that the processor can be a processor supporting Advanced Reduced Instruction Set Machines (ARM) architecture.
[0153] Further, optionally, the aforementioned memory may include read-only memory and random access memory, and may also include non-volatile random access memory. The memory may be volatile or non-volatile, or may include both. Non-volatile memory may include read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may include random access memory (RAM), which serves as an external cache. Many forms of RAM are available by way of example, but not limitation. Examples include static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).
[0154] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to this application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another.
[0155] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of those different embodiments or examples.
[0156] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "a plurality of" means two or more, unless otherwise explicitly specified.
[0157] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process. Furthermore, the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functionality involved.
[0158] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus or device (such as a computer-based system, a processor-included system or other system that can fetch and execute instructions from, an instruction execution system, apparatus or device).
[0159] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. All or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware, the program being stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiments.
[0160] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. This storage medium can be a read-only memory, a disk, or an optical disk, etc.
[0161] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various variations or substitutions within the technical scope disclosed in this application, and these should all be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for image processing of water quality detection in coastal engineering, characterized in that, include: After the water sample is placed in the sample container at regular intervals and stirred evenly, a high-resolution optical image of the water sample is acquired. The water sample is taken from the target coastal engineering construction area where water quality testing is required. The high-resolution optical image is preprocessed by noise filtering, image enhancement and geometric correction to obtain the processed high-resolution optical image. The trained water quality identification model is used to identify the processed high-resolution optical image to obtain water quality identification results, which include predicted values of each target water quality parameter. The water quality identification results are compared and analyzed with a preset water quality standard database to generate a water quality test report.
2. The method of claim 1, wherein, After the water sample is placed in the sample container at regular intervals and stirred evenly, a high-resolution optical image of the water sample is acquired, including: After filtering out large particulate impurities, the raw water samples obtained from the target coastal engineering construction area at regular intervals are poured into the sample container; Stir the water sample in the sample container until it is homogeneous; According to the testing requirements, high-resolution images of the water sample under different light source conditions are collected to obtain the high-resolution optical images.
3. The method of claim 1, wherein, The high-resolution optical image is preprocessed by noise filtering, image enhancement, and geometric correction to obtain the processed high-resolution optical image, which includes: The high-resolution optical image is denoised by bilateral filtering to obtain a noise-filtered high-resolution optical image. An adaptive logarithmic mapping algorithm is used to perform image enhancement processing on the noise-filtered high-resolution optical image to obtain an enhanced high-resolution optical image. The high-resolution optical image after image enhancement is geometrically corrected using root mean square error to obtain the processed high-resolution optical image.
4. The method of claim 1, wherein, The trained water quality identification model was obtained through the following method: A set of target water quality features suitable for water quality classification is selected from a water body database by using recursive feature elimination combined with a random forest regression model. The water body database is a database compiled based on traditional analysis methods. A water quality identification model is constructed based on a convolutional neural network; Based on the target water quality feature set, the water quality identification model is trained using the binary cross-entropy loss function to obtain the trained water quality identification model. When the trained water quality identification model meets the specified evaluation index requirements, the trained water quality identification model is determined as the trained water quality identification model.
5. The method according to claim 4, characterized in that, The recursive feature elimination combined with a random forest regression model is used to select a target water quality feature set suitable for water quality classification from a water body database. This set includes: Multiple water quality parameters useful for water quality classification are selected from the water body database to form a first water quality feature set; The first water quality feature set is fed into the random forest model, and the random forest model calculates the feature importance value of each water quality parameter in the first water quality feature set. Remove the water quality parameter with the lowest feature importance value from the first water quality feature set, and then combine the remaining water quality parameters to form the second water quality feature set; Replace the second water quality feature set with the first water quality feature set, return to execute the process of feeding the first water quality feature set into the random forest model, and have the random forest model calculate the feature importance value of each water quality parameter in the first water quality feature set; This process is repeated until the final M-th water quality feature set contains only N water quality features. For each water quality feature set obtained, the root mean square error of the random forest model is calculated once, and finally the water quality feature set corresponding to the minimum root mean square error is taken as the target water quality feature set.
6. The method according to claim 1, characterized in that, The trained water quality identification model is used to perform identification processing on the processed high-resolution optical image to obtain water quality identification results, including: Using the convolutional layers of the trained water quality identification model, multi-level spatial features of the processed high-resolution optical image are extracted through multi-layer convolution and pooling operations to obtain the first set of feature maps. By utilizing the attention mechanism layer of the trained water quality identification model, the information important for water quality classification in the first set of feature maps is weighted and focused to obtain a second set of feature maps rich in discriminative information. The water quality identification result is obtained by classifying the water quality based on the second set of feature maps using the fully connected layer of the trained water quality identification model.
7. The method according to any one of claims 1-6, characterized in that, The method further includes: An alarm is triggered when the water quality test report determines that there are abnormal pollutants in the target coastal engineering construction area.
8. An image processing system for coastal engineering water quality detection, characterized in that, include: The acquisition unit is used to stir the water sample placed in the sample container at regular intervals, and then acquire a high-resolution optical image of the water sample, wherein the water sample is taken from the target coastal engineering construction area where water quality testing is required. The processing unit is used to perform noise filtering, image enhancement and geometric correction preprocessing on the high-resolution optical image to obtain the processed high-resolution optical image. The identification unit is used to perform identification processing on the processed high-resolution optical image using a trained water quality identification model to obtain water quality identification results, which include predicted values of each target water quality parameter. The analysis unit is used to compare and analyze the water quality identification results with a preset water quality standard database to generate a water quality test report.
9. An electronic device, characterized in that, include: A memory and a processor, wherein the memory stores instructions which are loaded and executed by the processor to implement the method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when run on a computer, implements the method as described in any one of claims 1-7.