A method for treating electrophoresis line discharge cleaning wastewater based on machine vision
By processing electrophoresis wastewater images using machine vision technology, and constructing a standard matching template using superpixel segmentation and color shift calculation, the problems of long time consumption and high cost of traditional detection methods are solved, and rapid and accurate wastewater treatment detection is achieved.
Patent Information
- Application Number
- CN202511500747.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-21
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2045-10-21
AI Technical Summary
Traditional wastewater treatment and testing methods for electrophoresis lines are time-consuming, costly, and inaccurate, making it difficult to accurately determine whether the wastewater meets the standards.
A machine vision-based approach is used to acquire images of the wastewater pool in the electrophoresis line, perform preprocessing, superpixel segmentation, and maximum inscribed rectangle processing, calculate the turbidity index and color shift of the water surface, construct a standard matching template, and judge the similarity of wastewater treatment to determine whether it meets the standards.
It enables rapid and accurate determination of whether wastewater treatment in electrophoresis lines meets standards, improving detection efficiency and accuracy while reducing detection costs.
Smart Images

Figure CN120976223B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine vision technology, and in particular to a method for treating wastewater from electrophoresis line discharge based on machine vision. Background Technology
[0002] With the continuous development of electrophoresis technology, electrophoretic coating has gradually replaced the original electroplating process and become one of the main processes for coating metal parts due to its advantages such as environmental protection, high efficiency, and high quality. Because the electrophoresis process requires a large amount of water as a carrier, medium, and for cleaning the metal coating, a large amount of wastewater is generated on the electrophoretic coating line. To improve the environmental performance of the coating line, various physical, chemical, and biological methods are usually used for wastewater treatment. Finally, the treated wastewater that meets the standards is recycled or discharged, improving the environmental friendliness of the coating line.
[0003] Traditional methods for determining whether wastewater treatment in electrophoresis lines meets standards require manual wastewater sampling, sending the samples to a professional testing laboratory, and then using chemical and spectroscopic methods to detect impurities, precipitates, heavy metal ions, etc. in the water. However, this method is time-consuming, costly, and the spectra are easily affected by the external environment, resulting in inaccurate results. Summary of the Invention
[0004] In view of the above problems, this application provides a machine vision-based method for treating wastewater from electrophoresis lines, which can accurately identify whether the wastewater treatment of electrophoresis lines meets the standards.
[0005] This application provides a method for treating cleaning wastewater discharged from an electrophoresis line based on machine vision, including:
[0006] Acquire a first initial image and a second initial image. The first initial image is an image of wastewater in the wastewater tank of the qualified electrophoresis line, and the second initial image is an image of wastewater in the wastewater tank of the electrophoresis line to be tested.
[0007] The first initial image is preprocessed to obtain a first image and a second image; the second initial image is preprocessed to obtain a third image and a fourth image; the first image and the third image are grayscale images, and the second image and the fourth image are images based on the HSV color space;
[0008] The third image is subjected to superpixel segmentation and maximum inscribed rectangle processing to obtain multiple detection regions to be matched. The first image is subjected to superpixel segmentation and maximum inscribed rectangle processing to obtain a standard matching template.
[0009] For each of the detection areas to be matched, the water surface turbidity is calculated to obtain the water surface turbidity index of the detection area to be matched, the color shift is calculated based on the fourth image to obtain the first color shift degree, and the first wastewater metal deposition degree is calculated based on the water surface turbidity index and the first color shift degree of the detection area to be matched.
[0010] For the standard matching template, a second color shift degree is obtained by calculating the color shift based on the second image, and a second degree of metal deposition in the wastewater is obtained by calculating the second color shift degree.
[0011] For each of the detection regions to be matched, the deformation adjustment parameters of the matching window are calculated based on the rectangle size of the detection region to be matched and the standard matching template, and the wastewater treatment similarity is calculated based on the degree of metal deposition in the first wastewater, the degree of metal deposition in the second wastewater, and the deformation adjustment parameters of the matching window.
[0012] The similarity of the wastewater treatment is used to determine whether the wastewater treatment of the electrophoresis line meets the standards.
[0013] In one possible implementation, the preprocessing of the first initial image to obtain a first image and a second image, and the preprocessing of the second initial image to obtain a third image and a fourth image, includes:
[0014] The first initial image is converted into a grayscale image and an image based on the HSV color space;
[0015] The grayscale image obtained by converting the first initial image is subjected to denoising and image sharpening to obtain the first image;
[0016] The image based on the HSV color space obtained by converting the first initial image is subjected to denoising and image sharpening to obtain the second image;
[0017] The second initial image is converted into a grayscale image and an image based on the HSV color space;
[0018] The grayscale image obtained by converting the second initial image is subjected to denoising and image sharpening to obtain the third image;
[0019] The image based on the HSV color space obtained by converting the second initial image is subjected to denoising and image sharpening to obtain the fourth image.
[0020] In one possible implementation, the superpixel segmentation and maximum inscribed rectangle processing of the third image to obtain multiple regions to be matched and detected, and the superpixel segmentation and maximum inscribed rectangle processing of the first image to obtain a standard matching template, include:
[0021] The third image is subjected to superpixel segmentation to obtain multiple first superpixel blocks. Each first superpixel block is subjected to maximum inscribed rectangle processing to obtain multiple regions to be matched and detected.
[0022] The first image is subjected to superpixel segmentation to obtain multiple second superpixel blocks. One second superpixel block to be processed is selected from the multiple second superpixel blocks, and the second superpixel block to be processed is subjected to maximum inscribed rectangle processing to obtain a standard matching template.
[0023] In one possible implementation, calculating the turbidity index of each of the detection areas to be matched includes:
[0024] For each detection area to be matched, perform pixel grayscale statistics to obtain a first grayscale value and a second grayscale value. Based on the average of the first grayscale value and the second grayscale value, divide the pixels of the detection area to be matched into sediment particles and dust particles. The first grayscale value is the largest pixel grayscale value in the detection area to be matched, and the second grayscale value is the smallest pixel grayscale value in the detection area to be matched.
[0025] For each of the regions to be matched for detection, the precipitation colloidal index of the region to be matched for detection is calculated. The formula for calculating the precipitation colloidal index is as follows:
[0026]
[0027] in, The sedimentation gel index of the region to be matched for detection. For the first in the region to be matched for detection The average Euclidean distance between a precipitate particle and other precipitate particles in its eight-neighborhood. The number of precipitated particles in the detection area to be matched;
[0028] For each of the areas to be matched for testing, the turbidity index of the water surface in the area to be matched for testing is calculated based on the sedimentation colloidal index. The formula for calculating the turbidity index is as follows:
[0029]
[0030] in, For the first The water turbidity index of the area to be matched for testing The average sedimentation gel index of all regions to be matched in the third image. For the first The sedimentation gel index of the detection area to be matched.
[0031] In one possible implementation, the step of calculating the first color shift based on the fourth image includes:
[0032] For each of the detection regions to be matched, a first color change gradient for each pixel in the detection region to be matched is calculated based on the fourth image. The formula for calculating the first color change gradient is:
[0033]
[0034] in, The first detection region to be matched The first color change gradient of each pixel The fourth image is the first The coordinates of each pixel;
[0035] For each of the detection regions to be matched, a first color shift is calculated based on the first color change gradient of each pixel. The formula for calculating the first color shift is as follows:
[0036]
[0037] in, This represents the first color offset. The number of pixels in the detection area to be matched. For the first detection region to be matched The first color change gradient of each pixel It is the average value of the first color change gradient of all pixels in the detection area to be matched.
[0038] In one possible implementation, calculating the degree of metal deposition in the first wastewater based on the turbidity index of the detection area to be matched and the first color shift includes:
[0039] For each of the detection areas to be matched, the degree of metal deposition in the first wastewater is calculated based on the turbidity index of the water surface and the first color shift of the detection area to be matched. The formula for calculating the degree of metal deposition in the first wastewater is as follows:
[0040]
[0041] in, For the first The degree of metal deposition in the first wastewater of the area to be matched for detection. The first color offset of the detection area to be matched. The turbidity index of the water surface in the area to be matched for detection.
[0042] In one possible implementation, the step of calculating the second color shift based on the second image using the standard matching template to obtain the second color shift degree includes:
[0043] For the standard matching template, the second color change gradient of each pixel of the standard matching template is calculated based on the second image. The formula for calculating the second color change gradient is:
[0044]
[0045] in, For the standard matching template of the first The second color gradient of each pixel For the second image, the first The coordinates of each pixel;
[0046] For the standard matching template, the second color shift is calculated based on the second color change gradient of each pixel. The formula for calculating the second color shift is:
[0047]
[0048] in, This is the second color offset. The number of pixels in the standard matching template. For the first standard matching template The second color gradient of each pixel It is the average value of the second color change gradient of all pixels in the standard matching template.
[0049] In one possible implementation, calculating the degree of metal deposition in the second wastewater based on the second color shift includes:
[0050] For the standard matching template, the degree of metal deposition in the second wastewater is calculated based on the second color offset. The formula for calculating the degree of metal deposition in the second wastewater is as follows:
[0051]
[0052] in, The degree of metal deposition in the second wastewater. This is the second color offset. The turbidity index of the standard matching template is 1.
[0053] In one possible implementation, for each of the detection regions to be matched, calculating the deformation adjustment parameter of the matching window based on the rectangle size of the detection region to be matched and the standard matching template, and calculating the wastewater treatment similarity based on the first wastewater metal deposition degree, the second wastewater metal deposition degree, and the matching window deformation adjustment parameter, includes:
[0054] For each of the regions to be matched and detected, the deformation adjustment parameters of the matching window are calculated based on the rectangular size of the region to be matched and the rectangular size of the standard matching template. The calculation formula for the deformation adjustment parameters of the matching window is as follows:
[0055]
[0056] in, Adjust the deformation parameters for the matching window. For the first The size of the rectangle of the detection region to be matched. The rectangle size of the standard matching template;
[0057] For each of the regions to be matched, the wastewater treatment similarity is calculated based on the degree of metal deposition in the first wastewater, the degree of metal deposition in the second wastewater, and the deformation adjustment parameter of the matching window. The formula for calculating the wastewater treatment similarity is as follows:
[0058]
[0059] in, The similarity of the wastewater treatment process is... Adjust the deformation parameters for the matching window. For the first The degree of metal deposition in the first wastewater of the area to be matched for detection. This represents the degree of metal deposition in the second wastewater.
[0060] In one possible implementation, determining whether the wastewater treatment of the electrophoresis line meets the standards based on the wastewater treatment similarity includes:
[0061] Based on the wastewater treatment similarity, the number of compliant areas that meet the standards among the multiple areas to be matched for detection is determined, and the wastewater treatment of the electrophoresis line is judged to meet the standards based on the ratio of the compliant areas to the total number of areas to be matched for detection.
[0062] The beneficial effects of this application are as follows: by detecting the image of the wastewater pool of the electrophoresis line, the optimal region of the treated wastewater image that meets the standards is obtained using prior knowledge as a standard matching template, and then the degree of metal precipitation in the wastewater is constructed according to the amount of metal precipitation in the wastewater of the electrophoresis line. Finally, the similarity judgment criteria in the template matching algorithm are modified to achieve wastewater treatment detection of the electrophoresis line based on machine vision. Attached Figure Description
[0063] Figure 1 This is a flowchart illustrating the steps of a machine vision-based electrophoresis line discharge cleaning wastewater treatment method provided in an embodiment of this application. Detailed Implementation
[0064] To make the above-mentioned objectives, features, and advantages of this application more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art are within the scope of protection of this application.
[0065] The terminology used in the implementation section of this application is for the purpose of explaining specific embodiments of this application only, and is not intended to limit this application.
[0066] It should be noted that the terms "a" and "a plurality of" used in this application are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0067] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0068] The wastewater generated by electrophoresis lines has a complex composition, typically containing heavy metal ions, suspended solids, and industrial impurities. It is usually treated using methods such as flocculation sedimentation and biological treatment. RO reverse osmosis membranes are particularly effective at treating wastewater from electrophoresis lines, producing better quality water compared to other methods. However, RO membranes themselves experience wear and tear during wastewater treatment. If the RO membrane is damaged after a certain period of use, the treated wastewater may not meet water recycling or discharge standards. Therefore, it is necessary to conduct water quality testing on the treated wastewater from electrophoresis lines to determine if it meets the standards.
[0069] When the RO membrane is damaged, wastewater permeates through it, allowing heavy metal ions, suspended solids, and precipitates from previous wastewater treatment processes to pass through and enter the treated wastewater tank. In particular, because electrophoresis primarily uses various materials for metal coating, and these materials require surface cleaning before coating, the wastewater generated from electrophoresis contains a relatively high concentration of heavy metal ions, significantly impacting water quality. The precipitates of these metal ions are mainly colloidal, floating in the water. When exposed to strong light, they exhibit a Tyndall effect-like phenomenon, ultimately causing localized turbidity in the wastewater.
[0070] See Figure 1 As shown in the figure, this application discloses a method for treating cleaning wastewater discharged from an electrophoresis line based on machine vision, including:
[0071] Step S11: Obtain a first initial image and a second initial image. The first initial image is an image of wastewater in the wastewater pool of the qualified electrophoresis line, and the second initial image is an image of wastewater in the wastewater pool of the electrophoresis line to be tested.
[0072] Step S12: Preprocess the first initial image to obtain a first image and a second image; preprocess the second initial image to obtain a third image and a fourth image; the first image and the third image are grayscale images, and the second image and the fourth image are images based on the HSV color space;
[0073] Step S13: Perform superpixel segmentation and maximum inscribed rectangle processing on the third image to obtain multiple detection regions to be matched; perform superpixel segmentation and maximum inscribed rectangle processing on the first image to obtain a standard matching template.
[0074] Step S14: For each of the detection areas to be matched, perform water turbidity calculation to obtain the water turbidity index of the detection area to be matched, perform color shift calculation based on the fourth image to obtain the first color shift degree, and calculate the first wastewater metal deposition degree based on the water turbidity index of the detection area to be matched and the first color shift degree.
[0075] Step S15: For the standard matching template, calculate the second color shift based on the second image to obtain the second color shift degree, and calculate the second wastewater metal deposition degree based on the second color shift degree.
[0076] Step S16: For each of the detection regions to be matched, calculate the deformation adjustment parameter of the matching window based on the rectangle size of the detection region to be matched and the standard matching template, and calculate the wastewater treatment similarity based on the first wastewater metal deposition degree, the second wastewater metal deposition degree and the matching window deformation adjustment parameter;
[0077] Step S17: Determine whether the wastewater treatment of the electrophoresis line meets the standards based on the wastewater treatment similarity.
[0078] In the above embodiment steps, a first initial image and a second initial image are acquired. The first initial image is an image of the wastewater in the wastewater tank of the qualified electrophoresis line, and the second initial image is an image of the wastewater in the wastewater tank of the electrophoresis line to be tested. Since the wastewater tank of the electrophoresis line is generally dark, making it difficult to observe the internal conditions, an industrial light source is placed inside the edge of the wastewater tank before image capture. It is turned on one second before image capture to illuminate and cover the wastewater tank, and then turned off after image capture. Then, a wastewater area that has been judged to be compliant based on extensive prior experience is manually selected. A CMOS camera is placed above this compliant wastewater area, and a panoramic image of the compliant wastewater area is captured under sufficient light and a stable water surface to obtain an RGB image of the compliant electrophoresis line wastewater area. Under the same lighting and water surface conditions, a CMOS camera is used to capture an image of the wastewater area above the treated wastewater tank to obtain an RGB image of the wastewater area of the electrophoresis line to be tested. Besides a CMOS camera, other image acquisition devices can also be used, and no specific limitations are made here.
[0079] The RGB images of the compliant electrophoresis line wastewater area and the RGB images of the electrophoresis line wastewater area to be tested are preprocessed respectively. Specifically, the first initial image is preprocessed to obtain a first image and a second image; the second initial image is preprocessed to obtain a third image and a fourth image; the first image and the third image are grayscale images, and the second image and the fourth image are images based on the HSV color space.
[0080] To perform template matching, a standard matching template needs to be obtained within the qualified electrophoresis line wastewater image through superpixel segmentation and maximum inscribed rectangle processing. Within the electrophoresis line wastewater image to be detected, the detection region to be matched is determined through superpixel segmentation and maximum inscribed rectangle processing. Specifically, the third image is subjected to superpixel segmentation and maximum inscribed rectangle processing to obtain multiple detection regions to be matched, and the first image is subjected to superpixel segmentation and maximum inscribed rectangle processing to obtain the standard matching template.
[0081] Based on the wastewater characteristics of the electrophoresis process, the turbidity index of the area to be matched for detection is first calculated, then the first color shift is calculated, and finally the degree of metal deposition in the wastewater, which characterizes the amount of metal deposition in the area to be matched for detection, is calculated using the turbidity index and the first color shift. Specifically, for each area to be matched for detection, the turbidity index of the area to be matched for detection is calculated, the first color shift is calculated based on the fourth image, and the degree of metal deposition in the wastewater is calculated based on the turbidity index and the first color shift of the area to be matched for detection.
[0082] Similarly, based on the wastewater characteristics of the electrophoresis process, a second color shift is calculated. The second color shift is used to calculate the degree of metal precipitation in the second wastewater, which characterizes the amount of metal precipitation in the standard matching template. Specifically, for the standard matching template, a second color shift is calculated based on the second image to obtain the second color shift, and the degree of metal deposition in the second wastewater is calculated based on the second color shift.
[0083] Considering the inconsistency in area size between the standard matching template and the detection area to be matched, a matching window deformation adjustment parameter is constructed. Then, based on the first metal deposition degree of the detection area to be matched and the second wastewater metal deposition degree of the standard matching template, the wastewater treatment similarity of the template matching is constructed. Specifically, for each detection area to be matched, the matching window deformation adjustment parameter is calculated based on the rectangle size of the detection area to be matched and the standard matching template, and the wastewater treatment similarity is calculated based on the first wastewater metal deposition degree, the second wastewater metal deposition degree, and the matching window deformation adjustment parameter.
[0084] Wastewater treatment similarity can be used as a template matching similarity judgment index for wastewater detection in electrophoresis lines. Therefore, the wastewater treatment similarity is used to determine whether the wastewater treatment in electrophoresis lines meets the standards.
[0085] In an optional embodiment of this application, the preprocessing of the first initial image to obtain a first image and a second image, and the preprocessing of the second initial image to obtain a third image and a fourth image, includes:
[0086] The first initial image is converted into a grayscale image and an image based on the HSV color space;
[0087] The grayscale image obtained by converting the first initial image is subjected to denoising and image sharpening to obtain the first image;
[0088] The image based on the HSV color space obtained by converting the first initial image is subjected to denoising and image sharpening to obtain the second image;
[0089] The second initial image is converted into a grayscale image and an image based on the HSV color space;
[0090] The grayscale image obtained by converting the second initial image is subjected to denoising and image sharpening to obtain the third image;
[0091] The image based on the HSV color space obtained by converting the second initial image is subjected to denoising and image sharpening to obtain the fourth image.
[0092] In the above embodiment steps, the initial RGB image (including images of wastewater in the wastewater tank of the qualified electrophoresis line and images of wastewater in the wastewater tank of the electrophoresis line to be tested) is converted into a grayscale image and an image based on the HSV color space, and then denoising and image sharpening are performed to obtain the first image. Second image Third image and the fourth image Denoising can be achieved using bilateral filtering or other conventional denoising methods; no specific limitations are imposed here. Image sharpening can be achieved using Laplacian-based image sharpening or other conventional image sharpening methods; no specific limitations are imposed here.
[0093] In an optional embodiment of this application, the step of performing superpixel segmentation and maximum inscribed rectangle processing on the third image to obtain multiple regions to be matched and detected, and performing superpixel segmentation and maximum inscribed rectangle processing on the first image to obtain a standard matching template, includes:
[0094] The third image is subjected to superpixel segmentation to obtain multiple first superpixel blocks. Each first superpixel block is subjected to maximum inscribed rectangle processing to obtain multiple regions to be matched and detected.
[0095] The first image is subjected to superpixel segmentation to obtain multiple second superpixel blocks. One second superpixel block to be processed is selected from the multiple second superpixel blocks, and the second superpixel block to be processed is subjected to maximum inscribed rectangle processing to obtain a standard matching template.
[0096] In the steps of the above embodiments, the third image of the wastewater to be tested Superpixel segmentation is performed to obtain multiple first superpixel blocks in the third image of the wastewater to be detected. The maximum inscribed rectangle is then processed within each first superpixel block, and the resulting rectangle represents the detection region to be matched. Its size is recorded as... Then, the first image of the compliant wastewater. Superpixel segmentation was performed to obtain the first image of the compliant wastewater. Multiple second superpixel blocks are processed. Then, the best-quality, clearest, and most uniformly distributed wastewater texture second superpixel block is manually selected from these (if multiple matching blocks exist, one is randomly selected for subsequent processing). This second superpixel block is then subjected to maximum inscribed rectangle processing. The resulting rectangular region is set as the standard matching template, and its size is recorded as follows: .
[0097] In an optional embodiment of this application, the step of calculating the water surface turbidity index of each of the detection areas to be matched includes:
[0098] For each detection area to be matched, perform pixel grayscale statistics to obtain a first grayscale value and a second grayscale value. Based on the average of the first grayscale value and the second grayscale value, divide the pixels of the detection area to be matched into sediment particles and dust particles. The first grayscale value is the largest pixel grayscale value in the detection area to be matched, and the second grayscale value is the smallest pixel grayscale value in the detection area to be matched.
[0099] For each of the regions to be matched for detection, the precipitation colloidal index of the region to be matched for detection is calculated. The formula for calculating the precipitation colloidal index is as follows:
[0100]
[0101] in, The sedimentation gel index of the region to be matched for detection. For the first in the region to be matched for detection The average Euclidean distance between a precipitate particle and other precipitate particles in its eight-neighborhood. The number of precipitated particles in the detection area to be matched;
[0102] For each of the areas to be matched for testing, the turbidity index of the water surface in the area to be matched for testing is calculated based on the sedimentation colloidal index. The formula for calculating the turbidity index is as follows:
[0103]
[0104] in, For the first The water turbidity index of the area to be matched for testing The average sedimentation gel index of all regions to be matched in the third image. For the first The sedimentation gel index of the detection area to be matched.
[0105] In the above embodiment steps, since the turbidity of the electrophoresis wastewater mainly originates from precipitates produced by metal ions, each detection area to be matched is first divided into particle sizes. Due to the illumination of the wastewater tank, the particles in the electrophoresis wastewater in the detection area are mainly of two types: one is fine impurities generated during wastewater treatment and transportation, such as dust particles; the other is precipitate particles obtained after chemical treatment of heavy metal ions. When the precipitate particles reach a certain concentration, they will aggregate, forming localized colloidal precipitates, causing turbidity in this area. Because the metal precipitate particles are relatively large, they have a larger reflective surface and are more noticeable in the detection area under illumination, while other impurity particles are relatively small and have lower light sensitivity under illumination. Based on this characteristic, pixel grayscale statistics are performed on each detection area, and the pixel with the largest grayscale value is recorded as [value missing]. The smallest pixel grayscale value is recorded as Maximum grayscale value With minimum gray value The average of the two values is set as the threshold T for classifying dust particles and sediment particles; pixels with gray values greater than the threshold T are classified as sediment particles, and pixels with gray values less than T are classified as dust particles.
[0106] For each precipitate particle, calculate its Euclidean distance to other precipitates within its eight-neighborhood. Then, the average Euclidean distance between each precipitate particle and other precipitate particles in its eight-neighborhood is calculated. For each region to be matched for detection, calculate the sedimentation / colloidal index of that region. It should be noted that when the precipitate colloidal index... The larger the precipitate colloidal index, the smaller the sum of the average spacings of the precipitate particles within the detection area, indicating a more concentrated distribution and a greater likelihood of forming localized colloidal precipitates; when the precipitate colloidal index... The smaller the value, the larger the sum of the average spacing between the precipitated particles in the area to be matched for detection, the more dispersed the distribution, and the less likely it is to form localized colloidal precipitates.
[0107] Then, for each of the regions to be matched for detection, the mean value of the precipitation colloidal index is calculated for all regions based on the precipitation colloidal index within that region. As an indicator of the impact of sedimentation on water surface clarity within the detection area to be matched, the water surface turbidity index of the detection area to be matched was finally calculated. It should be noted that the higher the turbidity index of the water surface, the more severe the turbidity. The sedimentation index of the area to be matched for detection is higher than the average of the entire image, indicating that the water surface in that area is relatively turbid; the lower the turbidity index, the more turbid the water surface. The gelatinous sedimentation index in this area is lower than the average of the entire image, indicating that the water surface in this area to be matched and detected is relatively clear.
[0108] In an optional embodiment of this application, the step of calculating the first color shift based on the fourth image includes:
[0109] For each of the detection regions to be matched, a first color change gradient for each pixel in the detection region to be matched is calculated based on the fourth image. The formula for calculating the first color change gradient is:
[0110]
[0111] in, The first detection region to be matched The first color change gradient of each pixel The fourth image is the first The coordinates of each pixel;
[0112] For each of the detection regions to be matched, a first color shift is calculated based on the first color change gradient of each pixel. The formula for calculating the first color shift is as follows:
[0113]
[0114] in, This represents the first color offset. The number of pixels in the detection area to be matched. For the first detection region to be matched The first color change gradient of each pixel It is the average value of the first color change gradient of all pixels in the detection area to be matched.
[0115] When metal precipitates aggregate to form a colloidal substance, they can also cause changes in the color of the local water surface. Color change analysis is performed based on the HSV image (fourth image) of the wastewater area to be tested. Specifically, in the steps of the above embodiment, for each of the areas to be matched for detection, a first color change gradient is calculated based on the HSV value of each pixel, centered on each pixel. It should be noted that when the first color changes gradient... The larger the value, the greater the HSV value variation at that pixel location, potentially indicating the formation of metallic gel-like deposits in a localized area; when the first color change gradient... The smaller the value, the smaller the HSV value change at the location of the pixel, and the less or no gelatinous deposits are produced in the local area.
[0116] For the area to be matched for detection, when there is no metallic colloidal precipitate, the gradient of the first color change is relatively uniform; however, when metallic colloidal precipitate appears on the water surface within the area, the gradient of the first color change fluctuates significantly. Based on the gradient of the first color change... The average value of the first color change gradient of all pixels in the detection region is obtained by averaging all pixels within the detection region window. Based on the first color change gradient of pixels within the detection region window to be matched The average value of the first color change gradient of all pixels in the detection region to be matched The first color shift of the detection region to be matched is calculated. It should be noted that the greater the first color shift in the detection area to be matched, the more pixels there are with a large gradient of the first color change within the window, and the greater the possibility of metallic gel-like deposits within the window; conversely, the smaller the first color shift in the detection area to be matched, the fewer pixels there are with a large gradient of the first color change within the window, and the less likely there are metallic gel-like deposits within the window.
[0117] In an optional embodiment of this application, the calculation of the first wastewater metal deposition degree based on the water surface turbidity index of the detection area to be matched and the first color shift includes:
[0118] For each of the detection areas to be matched, the degree of metal deposition in the first wastewater is calculated based on the turbidity index of the water surface and the first color shift of the detection area to be matched. The formula for calculating the degree of metal deposition in the first wastewater is as follows:
[0119]
[0120] in, For the first The degree of metal deposition in the first wastewater of the area to be matched for detection. The first color offset of the detection area to be matched. The turbidity index of the water surface in the area to be matched for detection.
[0121] In the above embodiment steps, for each of the detection areas to be matched, the water surface turbidity index of the detection area to be matched is used as a basis. and the first color offset The degree of metal deposition in the first wastewater was calculated. It should be noted that when the degree of metal deposition in the first wastewater... The larger the value, the greater the likelihood of metallic colloidal precipitates in the wastewater from the electrophoresis line, and the lower the completeness of wastewater treatment; when the degree of metal deposition in the first wastewater... The smaller the value, the less likely there is a metallic colloidal precipitate in the electrophoresis line area, and the greater the completeness of wastewater treatment.
[0122] In an optional embodiment of this application, the step of calculating the second color shift degree based on the second image using the standard matching template includes:
[0123] For the standard matching template, the second color change gradient of each pixel of the standard matching template is calculated based on the second image. The formula for calculating the second color change gradient is:
[0124]
[0125] in, For the standard matching template of the first The second color gradient of each pixel For the second image, the first The coordinates of each pixel;
[0126] For the standard matching template, the second color shift is calculated based on the second color change gradient of each pixel. The formula for calculating the second color shift is:
[0127]
[0128] in, This is the second color offset. The number of pixels in the standard matching template. For the first standard matching template The second color gradient of each pixel It is the average value of the second color change gradient of all pixels in the standard matching template.
[0129] In the above embodiment steps, considering that the aggregation of metal precipitates to form a gel can also cause changes in the color of the local water surface, color change analysis is performed based on the HSV image (second image) of the compliant wastewater area. For the standard matching template, the second color change gradient is calculated based on the HSV value of each pixel, centered on each pixel. For the standard matching template, the gradient is adjusted according to the second hue. The average value of the second color change gradient of all pixels in the standard matching template is obtained by averaging all pixels within the standard matching template window. Based on the gradient of the second color change of pixels within the standard matching template window The average value of the second hue gradient of all pixels matching the standard template The second color offset of the standard matching template is calculated. .
[0130] In an optional embodiment of this application, the calculation of the second wastewater metal deposition degree based on the second color shift includes:
[0131] For the standard matching template, the degree of metal deposition in the second wastewater is calculated based on the second color offset. The formula for calculating the degree of metal deposition in the second wastewater is as follows:
[0132]
[0133] in, The degree of metal deposition in the second wastewater. This is the second color offset. The turbidity index of the standard matching template is 1.
[0134] In the steps of the above embodiments, the water surface turbidity index is based on the standard matching template. and the second color offset The degree of metal deposition in the first wastewater was calculated. In the standard matching template, since the qualified wastewater may contain a very small amount of sediment particles, the water surface is relatively clear. The sedimentation colloidal index of the standard matching template is 0, so the water surface turbidity index of the standard matching template is 1.
[0135] In an optional embodiment of this application, the step of calculating a matching window deformation adjustment parameter based on the rectangular size of the detection region to be matched and the standard matching template for each of the detection regions to be matched, and calculating the wastewater treatment similarity based on the first wastewater metal deposition degree, the second wastewater metal deposition degree, and the matching window deformation adjustment parameter, includes:
[0136] For each of the regions to be matched and detected, the deformation adjustment parameters of the matching window are calculated based on the rectangular size of the region to be matched and the rectangular size of the standard matching template. The calculation formula for the deformation adjustment parameters of the matching window is as follows:
[0137]
[0138] in, Adjust the deformation parameters for the matching window. For the first The size of the rectangle of the detection region to be matched. The rectangle size of the standard matching template;
[0139] For each of the regions to be matched, the wastewater treatment similarity is calculated based on the degree of metal deposition in the first wastewater, the degree of metal deposition in the second wastewater, and the deformation adjustment parameter of the matching window. The formula for calculating the wastewater treatment similarity is as follows:
[0140]
[0141] in, The similarity of the wastewater treatment process is... Adjust the deformation parameters for the matching window. For the first The degree of metal deposition in the first wastewater of the area to be matched for detection. This represents the degree of metal deposition in the second wastewater.
[0142] The degree of metal deposition in the first wastewater of the region to be matched and the degree of metal deposition in the second wastewater of the standard matching template are used to construct the similarity criterion for template matching. However, since the sizes of the regions to be matched and the standard matching template segmented by superpixels may not be consistent, the size of the matching region also needs to be adjusted. If the two comparison regions (the region to be matched and the standard matching template) are different in size, the amount of feature information contained in the region may be too much or too little, thus failing to fully represent the region features. To address this, during the matching process, when the region to be matched is larger than the region of the standard matching template, the standard matching template is expanded to match the size of the region to be matched; when the region to be matched is smaller than the region of the standard template, the region to be matched is expanded to match the size of the standard matching template. The purpose is to ensure that no feature information in the image is missed when the matching is completed. Therefore, in the steps of the above embodiment, for each region to be matched, the deformation adjustment parameter of the matching window is calculated based on the rectangular size of the region to be matched and the rectangular size of the standard matching template. It should be noted that when The larger the value, the greater the size difference between the two windows (the detection area to be matched and the standard matching template), and the greater the adjustment required; when The smaller the value, the smaller the size difference between the two windows, and the less room for adjustment is needed.
[0143] Then, for each of the regions to be matched, the wastewater treatment similarity is calculated based on the degree of metal deposition in the first wastewater, the degree of metal deposition in the second wastewater, and the deformation adjustment parameter of the matching window. It should be noted that when... The larger the value, the higher the similarity between the two regions (the region to be matched and the standard matching template), and the closer the water surface condition of the region to be matched is to the compliant water surface condition; when The smaller the value, the lower the similarity between the two areas (the area to be matched and the standard matching template). The water surface condition of the area to be matched is worse than that of the compliant water surface, which may result in RO membrane damage and incomplete wastewater treatment.
[0144] In an optional embodiment of this application, determining whether the wastewater treatment of the electrophoresis line meets the standards based on the wastewater treatment similarity includes:
[0145] Based on the wastewater treatment similarity, the number of compliant areas that meet the standards among the multiple areas to be matched for detection is determined, and the wastewater treatment of the electrophoresis line is judged to meet the standards based on the ratio of the compliant areas to the total number of areas to be matched for detection.
[0146] In the above embodiment steps, based on the wastewater treatment similarity Determine the number of compliant areas that meet the standards among the multiple areas to be matched for testing, and then determine whether the wastewater treatment of the electrophoresis line meets the standards based on the ratio of compliant areas to all areas to be matched for testing.
[0147] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0148] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0149] The above provides a detailed description of a machine vision-based method for treating cleaning wastewater from an electrophoresis line. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and its core ideas. At the same time, those skilled in the art will recognize that there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for treating cleaning wastewater discharged from an electrophoresis line based on machine vision, characterized in that, include: Acquire a first initial image and a second initial image. The first initial image is an image of wastewater in the wastewater tank of the qualified electrophoresis line, and the second initial image is an image of wastewater in the wastewater tank of the electrophoresis line to be tested. The first initial image is preprocessed to obtain a first image and a second image; The second initial image is preprocessed to obtain a third image and a fourth image; the first image and the third image are grayscale images, and the second image and the fourth image are images based on the HSV color space; The third image is subjected to superpixel segmentation and maximum inscribed rectangle processing to obtain multiple detection regions to be matched. The first image is subjected to superpixel segmentation and maximum inscribed rectangle processing to obtain a standard matching template. For each of the detection areas to be matched, the water surface turbidity is calculated to obtain the water surface turbidity index of the detection area to be matched, the color shift is calculated based on the fourth image to obtain the first color shift degree, and the first wastewater metal deposition degree is calculated based on the water surface turbidity index and the first color shift degree of the detection area to be matched. For the standard matching template, a second color shift degree is obtained by calculating the color shift based on the second image, and a second degree of metal deposition in the wastewater is obtained by calculating the second color shift degree. For each of the detection regions to be matched, the deformation adjustment parameters of the matching window are calculated based on the rectangle size of the detection region to be matched and the standard matching template, and the wastewater treatment similarity is calculated based on the degree of metal deposition in the first wastewater, the degree of metal deposition in the second wastewater, and the deformation adjustment parameters of the matching window. Based on the wastewater treatment similarity, determine whether the wastewater treatment of the electrophoresis line meets the standards; The step of calculating the turbidity index of each of the detection areas to be matched includes: For each detection area to be matched, perform pixel grayscale statistics to obtain a first grayscale value and a second grayscale value. Based on the average of the first grayscale value and the second grayscale value, divide the pixels of the detection area to be matched into sediment particles and dust particles. The first grayscale value is the largest pixel grayscale value in the detection area to be matched, and the second grayscale value is the smallest pixel grayscale value in the detection area to be matched. For each of the regions to be matched for detection, the precipitation colloidal index of the region to be matched for detection is calculated. The formula for calculating the precipitation colloidal index is as follows: in, The sedimentation gel index of the region to be matched for detection. For the first in the region to be matched for detection The average Euclidean distance between a precipitate particle and other precipitate particles in its eight-neighborhood. The number of precipitated particles in the detection area to be matched; For each of the areas to be matched for testing, the turbidity index of the water surface in the area to be matched for testing is calculated based on the sedimentation colloidal index. The formula for calculating the turbidity index is as follows: in, For the first The water turbidity index of the area to be matched for testing The average sedimentation gel index of all regions to be matched in the third image. For the first The sedimentation gel index of the detection area to be matched.
2. The method for treating cleaning wastewater from an electrophoresis line based on machine vision according to claim 1, characterized in that, The first initial image is preprocessed to obtain a first image and a second image; The second initial image is preprocessed to obtain the third and fourth images, including: The first initial image is converted into a grayscale image and an image based on the HSV color space; The grayscale image obtained by converting the first initial image is subjected to denoising and image sharpening to obtain the first image; The image based on the HSV color space obtained by converting the first initial image is subjected to denoising and image sharpening to obtain the second image; The second initial image is converted into a grayscale image and an image based on the HSV color space; The grayscale image obtained by converting the second initial image is subjected to denoising and image sharpening to obtain the third image; The image based on the HSV color space obtained by converting the second initial image is subjected to denoising and image sharpening to obtain the fourth image.
3. The method for treating cleaning wastewater from an electrophoresis line based on machine vision according to claim 1, characterized in that, The process of performing superpixel segmentation and maximum inscribed rectangle processing on the third image to obtain multiple regions to be matched and detected, and performing superpixel segmentation and maximum inscribed rectangle processing on the first image to obtain a standard matching template, includes: The third image is subjected to superpixel segmentation to obtain multiple first superpixel blocks. Each first superpixel block is subjected to maximum inscribed rectangle processing to obtain multiple regions to be matched and detected. The first image is subjected to superpixel segmentation to obtain multiple second superpixel blocks. One second superpixel block to be processed is selected from the multiple second superpixel blocks, and the second superpixel block to be processed is subjected to maximum inscribed rectangle processing to obtain a standard matching template.
4. The method for treating cleaning wastewater from an electrophoresis line based on machine vision according to claim 1, characterized in that, The calculation of the first color shift degree based on the fourth image includes: For each of the detection regions to be matched, a first color change gradient for each pixel in the detection region to be matched is calculated based on the fourth image. The formula for calculating the first color change gradient is: in, The first detection region to be matched The first color change gradient of each pixel The fourth image is the first The coordinates of each pixel; For each of the detection regions to be matched, a first color shift is calculated based on the first color change gradient of each pixel. The formula for calculating the first color shift is as follows: in, This represents the first color offset. The number of pixels in the detection area to be matched. For the first detection region to be matched The first color change gradient of each pixel It is the average value of the first color change gradient of all pixels in the detection area to be matched.
5. The method for treating cleaning wastewater from an electrophoresis line based on machine vision according to claim 1, characterized in that, The calculation of the first wastewater metal deposition degree based on the water surface turbidity index and the first color shift of the detection area to be matched includes: For each of the detection areas to be matched, the degree of metal deposition in the first wastewater is calculated based on the turbidity index of the water surface and the first color shift of the detection area to be matched. The formula for calculating the degree of metal deposition in the first wastewater is as follows: in, For the first The degree of metal deposition in the first wastewater of the area to be matched for detection. The first color offset of the detection area to be matched. The turbidity index of the water surface in the area to be matched for detection.
6. The method for treating cleaning wastewater from an electrophoresis line based on machine vision according to claim 1, characterized in that, The step of calculating the second color shift degree based on the second image using the standard matching template includes: For the standard matching template, the second color change gradient of each pixel of the standard matching template is calculated based on the second image. The formula for calculating the second color change gradient is: in, For the standard matching template of the first The second color change gradient of each pixel For the second image, the first The coordinates of each pixel; For the standard matching template, the second color shift is calculated based on the second color change gradient of each pixel. The formula for calculating the second color shift is: in, This is the second color offset. The number of pixels in the standard matching template. For the first standard matching template The second color change gradient of each pixel It is the average value of the second color change gradient of all pixels in the standard matching template.
7. The method for treating cleaning wastewater from an electrophoresis line based on machine vision according to claim 1, characterized in that, The calculation of the second wastewater metal deposition degree based on the second color shift includes: For the standard matching template, the degree of metal deposition in the second wastewater is calculated based on the second color offset. The formula for calculating the degree of metal deposition in the second wastewater is as follows: in, The degree of metal deposition in the second wastewater. This is the second color offset. The turbidity index of the standard matching template is 1.
8. The method for treating cleaning wastewater from an electrophoresis line based on machine vision according to claim 1, characterized in that, For each of the detection regions to be matched, a matching window deformation adjustment parameter is calculated based on the rectangle size of the detection region to be matched and the standard matching template. The wastewater treatment similarity is calculated based on the degree of metal deposition in the first wastewater, the degree of metal deposition in the second wastewater, and the matching window deformation adjustment parameter, including: For each of the regions to be matched and detected, the deformation adjustment parameters of the matching window are calculated based on the rectangular size of the region to be matched and the rectangular size of the standard matching template. The calculation formula for the deformation adjustment parameters of the matching window is as follows: in, Adjust the deformation parameters for the matching window. For the first The size of the rectangle of the detection region to be matched. The rectangle size of the standard matching template; For each of the regions to be matched, the wastewater treatment similarity is calculated based on the degree of metal deposition in the first wastewater, the degree of metal deposition in the second wastewater, and the deformation adjustment parameter of the matching window. The formula for calculating the wastewater treatment similarity is as follows: in, The similarity of the wastewater treatment process is... Adjust the deformation parameters for the matching window. For the first The degree of metal deposition in the first wastewater of the area to be matched for detection. This represents the degree of metal deposition in the second wastewater.
9. The method for treating cleaning wastewater from an electrophoresis line based on machine vision according to claim 1, characterized in that, The method of determining whether the wastewater treatment of the electrophoresis line meets the standards based on the wastewater treatment similarity includes: Based on the wastewater treatment similarity, the number of compliant areas that meet the standards among the multiple areas to be matched for detection is determined, and the wastewater treatment of the electrophoresis line is judged to meet the standards based on the ratio of the compliant areas to the total number of areas to be matched for detection.
Citation Information
Patent Citations
Sewage treatment detection method based on template matching
CN114882040A