CN116168026B - Water quality detection method and system based on computer vision - Google Patents

Water quality detection method and system based on computer vision Download PDF

Info

Publication number
CN116168026B
CN116168026B CN202310442603.6A CN202310442603A CN116168026B CN 116168026 B CN116168026 B CN 116168026B CN 202310442603 A CN202310442603 A CN 202310442603A CN 116168026 B CN116168026 B CN 116168026B
Authority
CN
China
Prior art keywords
value
denoising
calculating
obtaining
difference
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310442603.6A
Other languages
Chinese (zh)
Other versions
CN116168026A (en
Inventor
王暖霞
纪祥龙
贺晓云
刘清亮
孙艳丽
周秀芝
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shandong Baier Detection Ltd By Share Ltd
Original Assignee
Shandong Baier Detection Ltd By Share Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shandong Baier Detection Ltd By Share Ltd filed Critical Shandong Baier Detection Ltd By Share Ltd
Priority to CN202310442603.6A priority Critical patent/CN116168026B/en
Publication of CN116168026A publication Critical patent/CN116168026A/en
Application granted granted Critical
Publication of CN116168026B publication Critical patent/CN116168026B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T5/70
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/54Extraction of image or video features relating to texture
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/762Arrangements for image or video recognition or understanding using pattern recognition or machine learning using clustering, e.g. of similar faces in social networks
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02ATECHNOLOGIES FOR ADAPTATION TO CLIMATE CHANGE
    • Y02A20/00Water conservation; Efficient water supply; Efficient water use
    • Y02A20/152Water filtration

Abstract

The invention relates to the technical field of image processing, in particular to a water quality detection method and system based on computer vision. Firstly, obtaining water surface images after denoising with different preset initial thresholds, and obtaining regional rough characteristic values and texture difference values of pixel points according to gray scale characteristics of the pixel points in the water surface images; and obtaining the water spray probability value of the pixel point according to the water spray region distribution characteristics. Obtaining a noise probability value and a noise concentration degree according to the region rough characteristic value, the texture difference value and the water spray probability value, and further obtaining a denoising characterization value; and obtaining a detail representation value according to the edge characteristics before and after denoising and the gray level change characteristics. And obtaining the denoising anomaly degree and the optimal water surface image according to the denoising characterization value and the detail characterization value, and finishing water quality turbidity detection. The optimal denoising effect is selected in a self-adaptive mode through the characteristics of the water surface image, and finally the accuracy of water quality turbidity detection is improved.

Description

Water quality detection method and system based on computer vision
Technical Field
The invention relates to the technical field of image processing, in particular to a water quality detection method and system based on computer vision.
Background
In water quality analysis, water quality turbidity is one of important indexes for measuring water quality state, and water quality purification and filtration effects are all measured by depending on water quality turbidity, so that the detection accuracy of water quality turbidity is important. For large-scale waters, the unmanned aerial vehicle can obtain the image of the surface of water in the water sky, according to the quality of water turbidity of image analysis waters through neural network.
In the process of collecting the image of the water surface above the water area, the unmanned aerial vehicle may generate image noise, and a common image denoising method is a threshold denoising method. If the threshold value is selected too large in the threshold value denoising method, the noise is not thoroughly removed; if the threshold value is selected too small, the loss of image details and edges can be caused, so if the threshold value is selected unreasonably in the threshold value denoising method, the image denoising effect is poor, and the detection accuracy of water quality turbidity and the accuracy of water quality analysis are further affected.
Disclosure of Invention
In order to solve the technical problems that the image denoising effect is poor and the accuracy of water turbidity detection is affected due to improper threshold selection in the threshold denoising method, the invention aims to provide a water quality detection method and system based on computer vision, and the adopted technical scheme is as follows:
acquiring a water surface image after denoising according to a preset initial threshold; in the water surface image, obtaining a region roughness characteristic value according to gray level differences and gradient differences of the pixel points and other pixel points in a preset first neighborhood range; obtaining texture characteristic values and local texture characteristic values according to gray distribution characteristics in a preset second neighborhood range of the pixel points; obtaining a texture difference value of the pixel point according to the difference characteristic of the texture feature value and the difference characteristic of the local texture feature value;
clustering according to the gray values and positions of the pixel points to obtain different water surface areas, and dividing the water surface areas according to a preset gray average value to obtain water spray areas; obtaining a water spray probability value of the pixel point according to the distance characteristic of the pixel point and the nearest water spray region and the area characteristic of the corresponding water spray region;
obtaining a noise probability value and a noise concentration degree according to the region roughness characteristic value, the texture difference value and the water bloom probability value of the pixel point; obtaining a denoising characterization value according to the noise probability value and the noise concentration; obtaining a detail representation value according to the difference of the number of the long edge lines and the difference of the length of the edge lines before and after denoising the water surface image and the gray level difference of the pixel points;
obtaining denoising abnormal degrees corresponding to the initial threshold according to the denoising characterization value and the detail characterization value; selecting an optimal threshold value and an optimal water surface image corresponding to the optimal threshold value from different initial threshold values according to the denoising anomaly degree; and analyzing the water turbidity according to the optimal water surface image.
Further, the step of obtaining the region roughness feature value includes:
and calculating the gray difference absolute value and the gradient difference absolute value of the pixel point and other pixel points in a preset first neighborhood range, calculating the product of the gray difference absolute value and the corresponding gradient difference absolute value to obtain a rough feature, and calculating the sum value of the rough feature of the pixel point and all other pixel points in the preset first neighborhood range to obtain an area rough feature value.
Further, the step of obtaining the texture feature value and the local texture feature value includes:
obtaining texture characteristic values of the pixel points according to gray distribution of a preset second neighborhood range of the pixel points through an LBP algorithm; and obtaining the local texture characteristic value of the pixel point according to the texture characteristic value in the preset second neighborhood range of the pixel point through an LBP algorithm.
Further, the step of obtaining the texture difference value includes:
calculating a texture characteristic value average value and a local texture characteristic value average value of the water surface image; calculating the absolute value of the difference between the texture characteristic value of the pixel point and the average value of the texture characteristic value to obtain a texture characteristic difference; calculating the absolute value of the difference between the local texture characteristic value of the pixel point and the average value of the local texture characteristic value to obtain a local texture characteristic difference;
and calculating the product of the texture feature difference and the local texture feature difference of the pixel points to obtain the texture difference value.
Further, the obtaining step of the water bloom probability value includes:
calculating Euclidean distance between the pixel point and the nearest water spray region boundary and the area of the water spray region; when the pixel point is in the water spray area, the Euclidean distance is a preset non-negative small value; and calculating the ratio of the Euclidean distance to the corresponding area to obtain the water bloom probability value of the pixel point.
Further, the obtaining step of the noise probability value and the noise concentration degree includes:
calculating the product of the rough characteristic value of the region of the pixel point and the texture difference value to obtain an abnormal characteristic; calculating the ratio of the abnormal characteristic of the pixel point to the corresponding water spray probability value to obtain the noise probability value;
calculating the noise probability values of all pixel points in the water surface image to obtain a noise probability image, and dividing the noise probability image by an Ojin threshold method to obtain suspected noise points;
dividing the water surface image into a preset number of sub-areas on average, and calculating the average value of suspected noise points of all the sub-areas; and calculating the absolute value of the difference between the number of the suspected noise points in the subarea and the average value of the suspected noise points to obtain noise distribution characteristics, and calculating the average value of the noise distribution characteristics to obtain the noise concentration.
Further, the step of obtaining the denoising characterization value includes:
and calculating the average value of the noise probability values of all the pixel points in the water surface image, and calculating the product of the average value of the noise probability values and the noise concentration degree to obtain the denoising characterization value.
Further, the step of obtaining the detail characterization value includes:
calculating the sum of the absolute values of gray differences of all corresponding pixel points before and after denoising the water surface image to obtain a denoising gray change index; calculating the quantity difference of the long edge lines before and after denoising the water surface image to obtain a denoising edge quantity change index; calculating the sum of absolute values of length difference values of corresponding edge lines before and after denoising the water surface image to obtain a denoising edge length change index;
and calculating the product of the denoising gray scale change index, the denoising edge quantity change index and the denoising edge length change index of the water surface image to obtain the detail representation value.
Further, the step of obtaining the optimal water surface image includes:
calculating the product of a preset first weight and the normalized denoising characterization value to obtain a first degree of anomaly; calculating the product of a preset second weight and the normalized detail representation value to obtain a second degree of anomaly; calculating the sum value of the first degree of abnormality and the second degree of abnormality to obtain the denoising degree of abnormality;
and calculating the denoising anomaly degree obtained by denoising each preset initial threshold value of the water surface image, selecting the initial threshold value with the minimum denoising anomaly degree as an optimal threshold value, and denoising the image according to the optimal threshold value to obtain the optimal water surface image.
The invention also provides a water quality detection system based on computer vision, which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor executes the computer program to realize the steps of any one of the methods.
The invention has the following beneficial effects:
in the embodiment of the invention, the region roughness characteristic value can represent the possibility that the pixel point is a noise point according to the gray level difference and the gradient difference of the pixel point and other pixel points in a preset first neighborhood range; the texture difference value can represent the possibility that the pixel point is a noise point according to the texture characteristic value and the local texture characteristic value of the pixel point. Because part of pixel points are easily mistaken as noise points due to shooting reasons and water spray characteristics, the false recognition rate of the noise points is reduced by calculating the water spray probability value of the pixel points. The noise probability value can represent the possibility that the pixel point is a noise point; the noise concentration degree can represent the reliability degree of the noise probability value according to the uniformly dispersed noise distribution characteristics; the denoising characterization value can reflect the denoising effect of the water surface image. Because the advantages and disadvantages of the denoising effect are also related to the retention degree of the details of the image, a detail characterization value is obtained through the gray scale change characteristics of the pixel points before and after denoising and the change characteristics of the image edge line, and the retention degree of the details is reflected through the detail characterization value. Therefore, the denoising effect of the water surface image can be comprehensively and accurately analyzed through the denoising characterization value and the detail characterization value. And finally, the best water surface image with the best denoising effect is selected to identify the water quality turbidity, so that the accuracy of water quality turbidity detection is improved.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions and advantages of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are only some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a water quality detection method based on computer vision according to an embodiment of the present invention.
Detailed Description
The invention provides a water quality detection method and a water quality detection system based on computer vision.
Referring to fig. 1, a flow chart of a computer vision-based water quality detection method according to an embodiment of the invention is shown, the method comprises the following steps:
step S1, acquiring a water surface image after denoising according to a preset initial threshold; in the water surface image, obtaining a region roughness characteristic value according to gray level differences and gradient differences of the pixel points and other pixel points in a preset first neighborhood range; obtaining texture characteristic values and local texture characteristic values according to gray distribution characteristics of pixel points in a preset second neighborhood range; and obtaining the texture difference value of the pixel point according to the difference characteristic of the texture characteristic value and the difference characteristic of the local texture characteristic value.
In the embodiment of the invention, the implementation scene is the analysis of the image denoising effect for detecting the turbidity of the water quality. For large-scale waters, the unmanned aerial vehicle can acquire images above the water area, and the water quality turbidity is detected through computer vision and a neural network. Because noise is carried in the process of acquiring the image, the accuracy of water turbidity detection can be affected, and therefore the image needs to be denoised. The threshold denoising method is a conventional common image denoising method, and the main principle is that wavelet transform is performed on an image according to the fact that wavelet transform coefficients corresponding to the image and noise have opposite distribution characteristics, so that the wavelet transform coefficients are obtained, the set threshold is utilized to select and reject the wavelet transform coefficients, an estimated value of the wavelet transform coefficients is obtained, and finally wavelet inverse transform is performed on the estimated wavelet transform coefficients, so that a restored image is obtained. The threshold selection in the threshold denoising method can influence the denoising effect of the image, and if the threshold is selected too large, the noise removal is incomplete; if the selected threshold value is too small, the loss of image details and edge information is caused, so that the effect of image denoising can be improved by reasonably selecting the threshold value, and the accuracy of water quality turbidity detection is further ensured. Therefore, the embodiment of the invention needs to analyze the denoising effect of different thresholds in the threshold denoising method, so that the best threshold can be selected in a self-adaptive manner according to the image needing to be denoised to finish denoising, and the accuracy of water turbidity detection is improved.
Firstly, the original image of the water area acquired by the unmanned aerial vehicle is subjected to graying treatment, in the embodiment of the present invention, the graying treatment is performed by a weighted average method, and it is to be noted that the weighted average method belongs to the prior art, specific steps are not described in detail, and an implementer can select other methods, such as a maximum value method, to perform the graying treatment, which is not limited herein. Further, after the original image is grayed, denoising is needed through a threshold denoising method, an initial threshold is preset first, the range of the initial threshold is 1 to 15 in the embodiment of the invention, then denoising is conducted through a threshold denoising method according to different preset initial thresholds, and the water surface image after denoising of different preset initial thresholds is obtained. So far, the denoised water surface images are obtained, the denoising effect of each water surface image is required to be analyzed in the follow-up process, and the water surface image with the best denoising effect is selected to carry out water quality turbidity detection.
According to the characteristic that the water surface in a large water area is smooth and similar, the overall characteristic of the acquired water surface image is smooth and similar, if noise occurs, the noise area in the water surface image is not smooth and is rough, so that the rough characteristic value of the area can be obtained according to the gray level difference and the gradient difference between the pixel point and other pixels in the preset first neighborhood range, and the method specifically comprises the following steps: calculating the gray difference absolute value and the gradient difference absolute value of the pixel point and other pixel points in a preset first neighborhood range, calculating the product of the gray difference absolute value and the corresponding gradient difference absolute value to obtain a rough feature, and calculating the sum value of the rough feature of the pixel point and all other pixel points in the preset first neighborhood range to obtain an area rough feature value. The acquiring formula of the regional roughness characteristic value specifically comprises the following steps:
Figure SMS_1
in the method, in the process of the invention,
Figure SMS_2
the rough characteristic value of the area representing the pixel point in the water surface image,
Figure SMS_5
representing different other pixels in the preset first neighborhood range,
Figure SMS_7
the method and the device represent the number of other pixel points in the preset first neighborhood rangeIn the embodiment, the pixel is taken as the center, the area with the size of 5*5 is taken as the preset first neighborhood range, the number of other pixels is 24, and the implementer can determine the preset first neighborhood range according to the implementation scene.
Figure SMS_4
Represent the first
Figure SMS_6
The absolute value of the gray difference between each other pixel and the pixel,
Figure SMS_8
represent the first
Figure SMS_9
The absolute value of the gradient value difference between each other pixel and the pixel is to be explained, the calculating method of the gradient value belongs to the prior art, and specific steps are not repeated.
Figure SMS_3
Representing a roughness feature.
Regarding the acquisition of the rough characteristic value of the area of the pixel point in the water surface image, when the gray level difference between the pixel point and other pixel points in the preset first neighborhood range is smaller and the gradient difference is smaller, the smoother and similar pixel point area is, and the less possibility that the pixel point is a noise point is provided; when the gray level difference between the pixel point and other pixel points in the preset first neighborhood range is larger, the gradient difference is larger, which means that the pixel point area is smoother and coarser, and the possibility that the pixel point is a noise point is higher.
Since the corresponding pixel point cannot be completely determined as the noise point only according to the rough characteristic value, other characteristics capable of reflecting the noise point need to be analyzed. Because the original texture information in the water surface image can be destroyed by the existence of noise, and noise points are isolated in the water surface image, texture characteristic values and local texture characteristic values can be obtained according to gray distribution characteristics of pixel points in a preset second neighborhood range, and the method specifically comprises the following steps: obtaining texture characteristic values of the pixel points according to gray distribution of a preset second neighborhood range of the pixel points through an LBP algorithm; and obtaining the local texture characteristic value of the pixel point according to the texture characteristic value in the preset second neighborhood range of the pixel point through an LBP algorithm. It should be noted that, the LBP full scale Local Binary Pattern refers to a local binary pattern, the LBP algorithm is an existing algorithm for describing image textures, and can reflect the difference and contrast information between a certain pixel point and surrounding pixel points, in a preset second neighborhood range of a pixel point, if the gray value of the neighboring pixel point is greater than or equal to the pixel point, the neighboring pixel point is marked as 1, otherwise, the neighboring pixel point in the upper left corner in the preset second neighborhood range is marked as 0, and the algorithm prescribes that the neighboring pixel point in the upper left corner in the preset second neighborhood range is taken as a starting point, and is rotated clockwise to obtain a string of binary numbers, the binary numbers are converted into decimal numbers, so that the LBP value is obtained, and the calculation step of the specific LBP value is not repeated. In the embodiment of the invention, the preset second neighborhood range refers to eight neighborhoods of the pixel point, and an implementer can determine according to implementation scenes. The obtaining of the texture characteristic value refers to an LBP value obtained through an LBP algorithm according to gray value distribution in a preset second neighborhood range of the pixel point; and for obtaining the local texture characteristic value, firstly changing the gray value of the pixel point in the preset second neighborhood range of the pixel point into a corresponding texture characteristic value, and obtaining an LBP value through an LBP algorithm according to the distribution of the texture characteristic value in the preset second neighborhood range of the pixel point.
For the texture characteristic value of the pixel, if the pixel is a noise point, the LBP value of the pixel is larger or smaller than that of other pixels in the water surface image due to the difference of gray scale and texture, i.e. the texture characteristic value is larger or smaller. Meanwhile, if the pixel point is a noise point, the texture distribution of the pixel point in the preset second neighborhood range is different from that of the pixel point, so that even if the texture characteristic value of the pixel point is similar to that of other noise points in the water surface image, the local texture characteristic value of the pixel point obtained by presetting the texture characteristic value in the second neighborhood range is different from that of the other noise points. Further, the texture difference value of the pixel point can be obtained according to the difference feature of the texture feature value and the difference feature of the local texture feature value, which specifically comprises: calculating a texture characteristic value average value and a local texture characteristic value average value of the water surface image; calculating the absolute value of the difference between the texture characteristic value of the pixel point and the average value of the texture characteristic value to obtain the texture characteristic difference; calculating the absolute value of the difference between the local texture characteristic value of the pixel point and the average value of the local texture characteristic value to obtain the local texture characteristic difference; and calculating the product of the texture feature difference and the local texture feature difference of the pixel points to obtain a texture difference value. The acquisition formula of the texture difference value specifically comprises:
Figure SMS_10
in the method, in the process of the invention,
Figure SMS_11
representing texture feature values of pixel points in the water surface image,
Figure SMS_12
represents the average value of texture characteristic values of the water surface image,
Figure SMS_13
representing local texture feature values of pixel points in the water surface image,
Figure SMS_14
the average value of the local texture feature values of the water surface image is represented.
Figure SMS_15
The difference in the characteristics of the texture is indicated,
Figure SMS_16
representing local texture feature differences.
Regarding the acquisition of the texture difference value, according to the characteristic that if a pixel point is a noise point, the texture characteristic value and the local texture characteristic value of the pixel point are different from other pixel points in the water surface image, and when the texture characteristic difference of the pixel point is larger, the possibility that the pixel point is the noise point is larger; the greater the local texture feature difference of the pixel, the greater the likelihood that the pixel is noisy, so the greater the texture difference value, the greater the likelihood that the pixel is noisy.
Thus, the regional roughness value and the texture difference value of the pixel point in the water surface image are obtained, and the possibility that the pixel point is noise can be reflected through the regional roughness value and the texture difference value. The subsequent steps need to further analyze the situation that some pixels are mistaken for noise.
Step S2, clustering is carried out according to gray values and positions of pixel points to obtain different water surface areas, and the water surface areas are divided according to a preset gray average value to obtain water bloom areas; and obtaining the water spray probability value of the pixel point according to the distance characteristic of the pixel point and the nearest water spray region and the area characteristic of the corresponding water spray region.
Because in the shooting process, light reflection may occur on the horizontal plane due to sunlight reflection and other reasons, when water fluctuates, some water may form highlight areas with different sizes due to reflection, wherein smaller highlight areas and the surrounding areas form larger gray level differences and gradient differences, and further the noise points are mistaken. Therefore, the pixel points need to be further analyzed, and the false recognition rate of the noise points is reduced. Firstly, clustering is carried out according to gray values and positions of pixel points to obtain different water surface areas, and the water surface areas are divided according to a preset gray average value to obtain water spray areas. In the embodiment of the invention, clustering is performed according to gray values and positions of pixel points by a DBSCAN algorithm to obtain different water surface areas, and it is to be noted that the DBSCAN algorithm is a density-based clustering algorithm, the clusters are defined as the maximum set of points connected in density, and the areas with high enough density can be divided into clusters, and preset parameters are needed in the embodiment of the invention: setting a neighborhood radius EPS as 3, wherein the purpose of the neighborhood radius EPS is to select one point in a clustering space, and finding out all the nearby points in the neighborhood radius range; the number of objects in the neighborhood threshold MinPts is set to 2, the purpose of the number of objects in the neighborhood threshold MinPts is to determine whether the object is a core object, and an implementer can set the number according to the implementation scene, because the DBSCAN algorithm belongs to the existing clustering algorithm, and specific clustering steps are not repeated. So far, in the water surface image, different water surface areas are obtained through clustering, some areas are calm water surface areas, some areas are water spray areas, because the gray values of the water spray areas and other areas are obviously different, all the water surface areas obtained through clustering can be divided according to a preset gray level average value, the water surface areas with the gray level value average value of the water surface areas being larger than the preset gray level average value are used as the water spray areas, and an implementer can automatically determine the gray level of the preset gray level average value according to implementation scenes.
Further, after obtaining the splash zone, the splash probability value of the pixel point can be obtained according to the distance characteristic of the pixel point and the nearest splash zone and the area characteristic of the corresponding splash zone, which specifically comprises: calculating Euclidean distance between a pixel point and the nearest water spray region boundary and the area of the water spray region; when the pixel point is in the splash area, the Euclidean distance is a preset non-negative electrode small value, and in the embodiment of the invention, the preset non-negative electrode small value is 0.1, and an implementer can define according to implementation scenes; and calculating the ratio of the Euclidean distance to the area of the corresponding water bloom area to obtain the water bloom probability value of the pixel point. When the pixel is far from the nearest water spray area, the probability value of the pixel as water spray is lower; when the area of the nearest water spray area of the pixel point is larger, the more reliable the referenced nearest water spray area of the pixel point is, and the more reliable the result of representing the water spray probability value can be further. Therefore, when the more recent water bloom area of the pixel point is larger, the smaller the corresponding euclidean distance is, the smaller the water bloom probability value of the pixel point is. When the pixel is inside the splash zone, the splash probability value of the pixel is infinite, which means that the possibility that the pixel is a noise point is zero.
After obtaining the water spray probability value of the pixel point in the water surface image, the possibility that the pixel point is a noise point can be analyzed by combining the region roughness characteristic value and the texture difference value corresponding to the pixel point, and then the denoising effect is analyzed.
Step S3, obtaining a noise probability value and a noise concentration degree according to the region roughness characteristic value, the texture difference value and the water bloom probability value of the pixel points; obtaining a denoising characterization value according to the noise probability value and the noise concentration; and obtaining a detail representation value according to the difference of the number of the long edge lines and the difference of the lengths of the edge lines before and after denoising the water surface image and the difference of the gray scales of the pixel points.
The region roughness characteristic value and the texture difference value of the pixel point in the water surface image can be characterized as the possibility of noise points, and the water spray probability value can be characterized as the possibility of water spray, so that the noise point probability value and the noise point concentration degree can be obtained according to the region roughness characteristic value, the texture difference value and the water spray probability value of the pixel point, and the method specifically comprises the following steps: calculating the product of the rough characteristic value and the texture difference value of the region of the pixel point to obtain an abnormal characteristic; and calculating the ratio of the abnormal characteristic of the pixel point to the corresponding water spray probability value to obtain the noise probability value. For obtaining the noise probability value, when the rough characteristic value and the texture difference value of the pixel point are smaller, namely the abnormal characteristic value is smaller, and meanwhile, the water spray probability value of the pixel point is smaller, the probability that the pixel point is the noise point is smaller, and when the rough characteristic value and the texture difference value of the pixel point are larger, namely the abnormal characteristic value is larger, and meanwhile, the water spray probability value of the pixel point is larger, the probability that the pixel point is the water spray is larger; when the rough characteristic value and the texture difference value of the pixel point are larger, namely the abnormal characteristic value is larger, and meanwhile, the water spray probability value of the pixel point is smaller, the probability that the pixel point is a noise point is larger. I.e. the larger the noise probability value, the greater the likelihood that the pixel is a noise.
Further, the step of obtaining the noise concentration degree includes: calculating noise probability values of all pixel points in the water surface image, obtaining a noise probability image, and dividing the noise probability image by an Ojin threshold method to obtain suspected noise points; it should be noted that, the oxford thresholding method belongs to the prior art, and specific steps are not repeated. The water surface image is divided into a preset number of sub-areas on average, and the preset number is 25 in the embodiment of the invention, so that an implementer can determine according to implementation scenes. Calculating the average value of suspected noise points of all the subareas; and calculating the absolute value of the difference between the number of the suspected noise points in the subarea and the average value of the suspected noise points to obtain noise distribution characteristics, and calculating the average value of the noise distribution characteristics to obtain the noise concentration. For noise concentration, when the number of noise in each sub-region is more similar, i.e., the smaller the noise distribution feature is, the smaller the noise concentration is, meaning that the noise distribution is more uniform. Because the noise points of the image obtained by the unmanned aerial vehicle are globally random, if the calculated noise point concentration degree is smaller, the noise point distribution is more uniform and discrete, which means that the acquisition of the noise points is more accurate.
Therefore, the denoising characterization value can be obtained according to the noise probability value and the noise concentration degree, and specifically comprises the following steps: and calculating the average value of the noise probability values of all the pixel points in the water surface image, and calculating the product of the average value of the noise probability values and the concentration degree of the noise points to obtain the denoising characterization value. The acquisition formula of the denoising characterization value specifically comprises:
Figure SMS_17
in the method, in the process of the invention,
Figure SMS_18
represents the denoising characteristic value of the water surface image,
Figure SMS_19
the degree of noise concentration is represented by the degree of noise concentration,
Figure SMS_20
representing the number of pixels in the surface image,
Figure SMS_21
representing the different pixel points of the display,
Figure SMS_22
represent the first
Figure SMS_23
Noise probability values for individual pixels,
Figure SMS_24
and the average value of noise probability values of the water surface image is represented. The smaller the noise concentration is, the more accurate the noise acquisition is, and the smaller the average value of the noise probability values is, the less the possibility that the pixel point in the water surface image is noise is. Therefore, when the noise point is obtained more accurately and the possibility that the pixel point is noise is smaller, the denoising characterization value is smaller, which means that the denoising effect of the current preset initial threshold value is better.
And because the loss of details of the water surface image can influence the detection accuracy of the water turbidity in the image recognition process, the more the details are, the more the impurities in the water surface image to be detected are, the greater the water turbidity is, and the image denoising can influence the reservation degree of the details of the image, so that the image denoising not only needs to ensure the denoising effect, but also needs to reserve the details of the image as much as possible. Therefore, the detail retention degree of the water surface image needs to be analyzed, so that a detail representation value is obtained according to the difference of the number of long edge lines, the difference of the length of the edge lines and the difference of the gray level of pixel points before and after denoising the water surface image, and the detail representation value specifically comprises the following steps: calculating the sum of the absolute values of gray differences of all corresponding pixel points before and after denoising the water surface image to obtain a denoising gray change index; calculating the number difference of long edge lines before and after denoising the water surface image to obtain a denoising edge number change index; calculating the sum of absolute values of length difference values of corresponding edge lines before and after denoising the water surface image to obtain a denoising edge length change index; and calculating the product of the denoising gray scale change index, the denoising edge quantity change index and the denoising edge length change index of the water surface image to obtain a detail representation value. The acquisition formula of the detail characterization value specifically comprises the following steps:
Figure SMS_25
in the method, in the process of the invention,
Figure SMS_27
represents the detail representation value of the water surface image,
Figure SMS_31
represent the first
Figure SMS_34
The absolute value of the difference between the gray values before and after denoising the pixel points,
Figure SMS_28
represents the change index of the de-noising gray scale,
Figure SMS_29
representing the number of long edge lines before and after denoising the water surface imageIn the embodiment of the invention, the long edge line is defined as an edge line with the length of the edge line being greater than 10, and the length of the edge line is the number of pixels forming the edge line, so that an operator can define the length limit of the long edge line according to the implementation scene.
Figure SMS_32
Represents the number of edge lines acquired by edge detection before denoising the water surface image,
Figure SMS_35
representing the different edge lines thereof,
Figure SMS_26
represent the first
Figure SMS_30
The difference in length of the edge lines before and after denoising,
Figure SMS_33
indicating the denoising edge length variation index. It should be noted that, the edge line may be obtained by an existing edge detection technology, and specific steps are not described herein.
Regarding the acquisition of the detail representation value, when the number of denoising edges and the length of the denoising edges are changed to be smaller before and after denoising the water surface image and the denoising gray level is changed to be smaller, the detail preservation is better, and when the detail representation value is smaller, the integrity of the detail preservation of the denoised image is better.
The denoising effect of the image is reflected through the denoising characterization value and the detail characterization value, and the water surface image with the best denoising effect is required to be selected for water quality turbidity detection in the subsequent steps.
S4, obtaining denoising abnormal degrees corresponding to the initial threshold values according to the denoising characterization values and the detail characterization values; selecting an optimal threshold value and an optimal water surface image corresponding to the optimal threshold value from different initial threshold values according to the denoising anomaly degree; and analyzing the turbidity of the water quality according to the optimal water surface image.
So far, the denoising characterization value and the detail characterization value of the water surface images with different denoising effects are obtained, the denoising effects can be analyzed and compared according to the denoising characterization value and the detail characterization value of each water surface image, and the best threshold and the best water surface image corresponding to the best threshold are selected from different initial thresholds according to the denoising anomaly degree, and the method specifically comprises the following steps: calculating the product of a preset first weight and the normalized denoising characterization value to obtain a first degree of anomaly; calculating the product of a preset second weight and the normalized detail representation value to obtain a second anomaly degree; calculating the sum value of the first anomaly degree and the second anomaly degree to obtain a denoising anomaly degree; the denoising abnormal degrees obtained by denoising all the water surface images with the preset initial threshold values are calculated, the smaller the denoising abnormal degrees are, the denoising effect is guaranteed, the image details are reserved to the greatest extent, so that the preset initial threshold value with the smallest denoising abnormal degree is selected as the optimal threshold value, the water surface image with the smallest denoising abnormal degree is taken as the optimal water surface image according to the optimal threshold value, and the accuracy of water quality turbidity detection is improved. In the embodiment of the invention, the denoising characterization values of all the water surface images are normalized through the existing range normalization; the detail representation values of all the water surface images are normalized through the existing range normalization, specific normalization steps are not repeated, and an implementer can select other mathematical operation methods such as hyperbolic tangent functions for normalization, so that the normalization is not limited. The first weight is preset to be 0.7, the second weight is preset to be 0.3, the purpose is to measure the importance degree of the denoising characterization value and the detail characterization value, and an implementer can determine according to implementation scenes.
So far, the best water surface image with the best denoising effect is selected, and then the best water surface image is used for detecting the water quality turbidity. The training process of the residual error network comprises the following steps: the water surface images are manually labeled, and the turbidity grade corresponding to each water quality image is marked, and in the embodiment of the invention, the turbidity grade is divided into one to ten, and an operator can define the water surface images according to the implementation scene, and the turbidity is higher as the grade is higher. Iterative training is performed by a cross entropy loss function. The network input is the best water surface image after denoising, and the output is the corresponding turbidity level. It should be noted that, the residual network belongs to the existing neural network, and detailed training steps are not repeated. So far, the optimal denoising threshold value is selected in a self-adaptive mode according to the water surface image to be detected, so that the denoised optimal water surface image is obtained, namely, the denoising effect is ensured, and meanwhile, the image details are reserved to the greatest extent. Thereby improving the detection accuracy of the turbidity of the water quality.
In summary, the embodiment of the invention provides a water quality detection method based on computer vision. Firstly, obtaining water surface images after denoising with different preset initial thresholds, and obtaining regional rough characteristic values and texture difference values of pixel points according to gray scale characteristics of the pixel points in the water surface images; and obtaining the water spray probability value of the pixel point according to the water spray region distribution characteristics. Obtaining a noise probability value and a noise concentration degree according to the region rough characteristic value, the texture difference value and the water spray probability value, and further obtaining a denoising characterization value; and obtaining a detail representation value according to the edge characteristics before and after denoising and the gray level change characteristics. And obtaining the denoising anomaly degree and the optimal water surface image according to the denoising characterization value and the detail characterization value, and finishing water quality turbidity detection. The optimal denoising effect is selected in a self-adaptive mode through the characteristics of the water surface image, and finally the accuracy of water quality turbidity detection is improved.
The invention also provides a water quality detection system based on computer vision, which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor executes the computer program to realize any one of the steps of the water quality detection method based on computer vision.

Claims (10)

1. A water quality detection method based on computer vision is characterized by comprising the following steps:
acquiring a water surface image after denoising according to a preset initial threshold; in the water surface image, obtaining a region roughness characteristic value according to gray level differences and gradient differences of the pixel points and other pixel points in a preset first neighborhood range; obtaining texture characteristic values and local texture characteristic values according to gray distribution characteristics in a preset second neighborhood range of the pixel points; obtaining a texture difference value of the pixel point according to the difference characteristic of the texture feature value and the difference characteristic of the local texture feature value;
clustering according to the gray values and positions of the pixel points to obtain different water surface areas, and dividing the water surface areas according to a preset gray average value to obtain water spray areas; obtaining a water spray probability value of the pixel point according to the distance characteristic of the pixel point and the nearest water spray region and the area characteristic of the corresponding water spray region;
obtaining a noise probability value and a noise concentration degree according to the region roughness characteristic value, the texture difference value and the water bloom probability value of the pixel point; obtaining a denoising characterization value according to the noise probability value and the noise concentration; obtaining a detail representation value according to the difference of the number of the long edge lines and the difference of the length of the edge lines before and after denoising the water surface image and the gray level difference of the pixel points;
obtaining denoising abnormal degrees corresponding to the initial threshold according to the denoising characterization value and the detail characterization value; selecting an optimal threshold value and an optimal water surface image corresponding to the optimal threshold value from different initial threshold values according to the denoising anomaly degree; and analyzing the water turbidity according to the optimal water surface image.
2. The method for detecting water quality based on computer vision according to claim 1, wherein the step of obtaining the regional roughness feature value comprises:
and calculating the gray difference absolute value and the gradient difference absolute value of the pixel point and other pixel points in a preset first neighborhood range, calculating the product of the gray difference absolute value and the corresponding gradient difference absolute value to obtain a rough feature, and calculating the sum value of the rough feature of the pixel point and all other pixel points in the preset first neighborhood range to obtain an area rough feature value.
3. The method for detecting water quality based on computer vision as claimed in claim 1, wherein the step of obtaining the texture feature value and the local texture feature value comprises:
obtaining texture characteristic values of the pixel points according to gray distribution of a preset second neighborhood range of the pixel points through an LBP algorithm; and obtaining the local texture characteristic value of the pixel point according to the texture characteristic value in the preset second neighborhood range of the pixel point through an LBP algorithm.
4. The method for detecting water quality based on computer vision according to claim 1, wherein the step of obtaining the texture difference value comprises:
calculating a texture characteristic value average value and a local texture characteristic value average value of the water surface image; calculating the absolute value of the difference between the texture characteristic value of the pixel point and the average value of the texture characteristic value to obtain a texture characteristic difference; calculating the absolute value of the difference between the local texture characteristic value of the pixel point and the average value of the local texture characteristic value to obtain a local texture characteristic difference;
and calculating the product of the texture feature difference and the local texture feature difference of the pixel points to obtain the texture difference value.
5. The computer vision based water quality detection method according to claim 1, wherein the obtaining step of the water spray probability value comprises:
calculating Euclidean distance between the pixel point and the nearest water spray region boundary and the area of the water spray region; when the pixel point is in the water spray area, the Euclidean distance is a preset non-negative small value; and calculating the ratio of the Euclidean distance to the corresponding area to obtain the water bloom probability value of the pixel point.
6. The computer vision based water quality detection method according to claim 1, wherein the obtaining of the noise probability value and the noise concentration degree comprises:
calculating the product of the rough characteristic value of the region of the pixel point and the texture difference value to obtain an abnormal characteristic; calculating the ratio of the abnormal characteristic of the pixel point to the corresponding water spray probability value to obtain the noise probability value;
calculating the noise probability values of all pixel points in the water surface image to obtain a noise probability image, and dividing the noise probability image by an Ojin threshold method to obtain suspected noise points;
dividing the water surface image into a preset number of sub-areas on average, and calculating the average value of suspected noise points of all the sub-areas; and calculating the absolute value of the difference between the number of the suspected noise points in the subarea and the average value of the suspected noise points to obtain noise distribution characteristics, and calculating the average value of the noise distribution characteristics to obtain the noise concentration.
7. The method for detecting water quality based on computer vision according to claim 1, wherein the step of obtaining the denoising characterization value comprises:
and calculating the average value of the noise probability values of all the pixel points in the water surface image, and calculating the product of the average value of the noise probability values and the noise concentration degree to obtain the denoising characterization value.
8. The method for detecting water quality based on computer vision according to claim 1, wherein the step of obtaining the detail characterization value comprises:
calculating the sum of the absolute values of gray differences of all corresponding pixel points before and after denoising the water surface image to obtain a denoising gray change index; calculating the quantity difference of the long edge lines before and after denoising the water surface image to obtain a denoising edge quantity change index; calculating the sum of absolute values of length difference values of corresponding edge lines before and after denoising the water surface image to obtain a denoising edge length change index;
and calculating the product of the denoising gray scale change index, the denoising edge quantity change index and the denoising edge length change index of the water surface image to obtain the detail representation value.
9. The computer vision based water quality testing method according to claim 1, wherein the step of obtaining the optimal water surface image comprises:
calculating the product of a preset first weight and the normalized denoising characterization value to obtain a first degree of anomaly; calculating the product of a preset second weight and the normalized detail representation value to obtain a second degree of anomaly; calculating the sum value of the first degree of abnormality and the second degree of abnormality to obtain the denoising degree of abnormality;
and calculating the denoising anomaly degree obtained by denoising each preset initial threshold value of the water surface image, selecting the initial threshold value with the minimum denoising anomaly degree as an optimal threshold value, and denoising the image according to the optimal threshold value to obtain the optimal water surface image.
10. A computer vision based water quality detection system comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein execution of the computer program by the processor implements the steps of the method according to any one of claims 1-9.
CN202310442603.6A 2023-04-24 2023-04-24 Water quality detection method and system based on computer vision Active CN116168026B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310442603.6A CN116168026B (en) 2023-04-24 2023-04-24 Water quality detection method and system based on computer vision

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310442603.6A CN116168026B (en) 2023-04-24 2023-04-24 Water quality detection method and system based on computer vision

Publications (2)

Publication Number Publication Date
CN116168026A CN116168026A (en) 2023-05-26
CN116168026B true CN116168026B (en) 2023-06-27

Family

ID=86413546

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310442603.6A Active CN116168026B (en) 2023-04-24 2023-04-24 Water quality detection method and system based on computer vision

Country Status (1)

Country Link
CN (1) CN116168026B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116579954B (en) * 2023-07-12 2023-09-05 南京晨新医疗科技有限公司 Intelligent enhancing method for ultra-high definition endoscope image
CN116630425B (en) * 2023-07-21 2023-09-22 长春市天之城科技有限公司 Intelligent food detection system based on X rays
CN116612126B (en) * 2023-07-21 2023-09-19 青岛国际旅行卫生保健中心(青岛海关口岸门诊部) Container disease vector biological detection early warning method based on artificial intelligence
CN116823809B (en) * 2023-08-23 2023-11-24 威海迈尼生物科技有限公司 Visual detection method for speckle reduction effect of microneedle patch technology
CN116778431B (en) * 2023-08-25 2023-11-10 青岛娄山河水务有限公司 Automatic sludge treatment monitoring method based on computer vision
CN116863323B (en) * 2023-09-04 2023-11-24 济宁鑫惠生水产养殖专业合作社 Visual detection method and system for pollution of water source for fishery culture
CN117253144B (en) * 2023-09-07 2024-04-12 建研防火科技有限公司 Fire risk grading management and control method
CN116912820B (en) * 2023-09-13 2023-12-12 青岛君盛食品股份有限公司 Visual inspection method for infant food safety
CN116996675B (en) * 2023-09-27 2023-12-19 河北天英软件科技有限公司 Instant messaging system and information processing method
CN117036353B (en) * 2023-10-09 2024-01-30 东莞市盈圆合创新材料有限公司 Temperature-resistant foam coating detection method for new energy battery

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2005050564A2 (en) * 2003-11-24 2005-06-02 Koninklijke Philips Electronics N.V. Detection of local visual space-time details in a video signal
CN102288166A (en) * 2011-05-13 2011-12-21 河海大学 Video-based multi-model combined surface ship detection method
CN108921800A (en) * 2018-06-26 2018-11-30 成都信息工程大学 Non-local mean denoising method based on form adaptive search window
CN110443806A (en) * 2019-04-30 2019-11-12 浙江大学 A kind of transparent floating harmful influence image partition method of the water surface based on targets improvement processing
CN112241692A (en) * 2020-09-25 2021-01-19 天津大学 Channel foreign matter intelligent detection and classification method based on aerial image super-pixel texture
CN112712467A (en) * 2021-01-11 2021-04-27 郑州科技学院 Image processing method based on computer vision and color filter array
WO2022110804A1 (en) * 2020-11-24 2022-06-02 海南大学 Image noise measurement method and device based on local statistical information
CN115170574A (en) * 2022-09-09 2022-10-11 南通市赛孚环保科技有限公司 Sewage detection method and system based on threshold segmentation
CN115829883A (en) * 2023-02-16 2023-03-21 汶上县恒安钢结构有限公司 Surface image denoising method for dissimilar metal structural member

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11508037B2 (en) * 2020-03-10 2022-11-22 Samsung Electronics Co., Ltd. Systems and methods for image denoising using deep convolutional networks
US20220375038A1 (en) * 2021-05-07 2022-11-24 GE Precision Healthcare LLC Systems and methods for computed tomography image denoising with a bias-reducing loss function

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2005050564A2 (en) * 2003-11-24 2005-06-02 Koninklijke Philips Electronics N.V. Detection of local visual space-time details in a video signal
CN102288166A (en) * 2011-05-13 2011-12-21 河海大学 Video-based multi-model combined surface ship detection method
CN108921800A (en) * 2018-06-26 2018-11-30 成都信息工程大学 Non-local mean denoising method based on form adaptive search window
CN110443806A (en) * 2019-04-30 2019-11-12 浙江大学 A kind of transparent floating harmful influence image partition method of the water surface based on targets improvement processing
CN112241692A (en) * 2020-09-25 2021-01-19 天津大学 Channel foreign matter intelligent detection and classification method based on aerial image super-pixel texture
WO2022110804A1 (en) * 2020-11-24 2022-06-02 海南大学 Image noise measurement method and device based on local statistical information
CN112712467A (en) * 2021-01-11 2021-04-27 郑州科技学院 Image processing method based on computer vision and color filter array
CN115170574A (en) * 2022-09-09 2022-10-11 南通市赛孚环保科技有限公司 Sewage detection method and system based on threshold segmentation
CN115829883A (en) * 2023-02-16 2023-03-21 汶上县恒安钢结构有限公司 Surface image denoising method for dissimilar metal structural member

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
Dynamic texture representation based on oriented magnitudes of Gaussian gradients;Thanh Tuan Nguyen 等;《Journal of Visual Communication and Image Representation》;第81卷;1-17 *
一种基于航天图像的舰船目标检测和船速估计方法;曾蕾 等;《光电工程》;第40卷(第12期);65-72 *
基于高分遥感影像的水库变化检测方法研究;左梦颖;《中国优秀硕士学位论文全文数据库 工程科技Ⅱ辑》;第2020年卷(第6期);C028-46 *
自然场景下船舶水线提取算法的研究;宋涛 等;《光学技术》;第43卷(第1期);61-65 *

Also Published As

Publication number Publication date
CN116168026A (en) 2023-05-26

Similar Documents

Publication Publication Date Title
CN116168026B (en) Water quality detection method and system based on computer vision
CN115861135B (en) Image enhancement and recognition method applied to panoramic detection of box body
CN110276754B (en) Surface defect detection method, terminal device and storage medium
CN115272346A (en) PCB production process online detection method based on edge detection
CN110781885A (en) Text detection method, device, medium and electronic equipment based on image processing
CN116110053B (en) Container surface information detection method based on image recognition
CN110766689A (en) Method and device for detecting article image defects based on convolutional neural network
CN115619793B (en) Power adapter appearance quality detection method based on computer vision
CN116664559B (en) Machine vision-based memory bank damage rapid detection method
CN116777916B (en) Defect detection method based on metal shell of pump machine
CN114494210A (en) Plastic film production defect detection method and system based on image processing
CN115063430B (en) Electric pipeline crack detection method based on image processing
CN116977358B (en) Visual auxiliary detection method for corrugated paper production quality
CN116735612B (en) Welding defect detection method for precise electronic components
CN116452589B (en) Intelligent detection method for surface defects of artificial board based on image processing
CN115330767A (en) Method for identifying production abnormity of corrosion foil
CN116152115B (en) Garbage image denoising processing method based on computer vision
CN116152242B (en) Visual detection system of natural leather defect for basketball
CN116883408A (en) Integrating instrument shell defect detection method based on artificial intelligence
CN115526885A (en) Product image defect detection method, system, device and medium
CN116128873A (en) Bearing retainer detection method, device and medium based on image recognition
CN116664565A (en) Hidden crack detection method and system for photovoltaic solar cell
CN112950594A (en) Method and device for detecting surface defects of product and storage medium
CN116777917B (en) Defect detection method and system for optical cable production
CN112926695A (en) Image recognition method and system based on template matching

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant