Floccule identification and positioning method based on improved Yolov7 algorithm
By improving the floc recognition and positioning method of the Yolov7 algorithm, the problem of inability to distinguish the out-of-focus flocs and the cumbersome recognition process in the prior art is solved, and high accuracy and fast floc recognition are achieved.
Patent Information
- Application Number
- CN202510032520.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-09
- Publication Date
- 2025-03-07
AI Technical Summary
The prior art cannot effectively distinguish out-of-focus flocs when identifying silt and sand flocs, and the image processing process is cumbersome and the recognition accuracy is low.
The flocculus identification and positioning method based on the improved Yolov7 algorithm is adopted to identify and locate the sediment flocculus in the water through the steps of image acquisition, preprocessing, instance segmentation, thresholding processing and data information extraction.
It improves the accuracy and speed of flocculation recognition, simplifies the identification and positioning process, is suitable for the processing of large amounts of sediment flocculation, and the algorithm model occupies little memory and has a fast detection speed.
Smart Images

Figure CN119579913A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of fine-grained sediment floc identification and positioning, and in particular to a floc identification and positioning method based on an improved Yolov7 algorithm. Background Art
[0002] Fine-grained sediment flocs are the basis for studying sediment movement and the evolution of rivers, coasts, and waterways. At present, particle image technology is mainly used for floc identification. However, the above methods involve background removal, Gaussian filtering, thresholding and other operations when identifying flocs. Different parameters need to be adjusted for different samples, and multiple methods need to be used in combination. There are large errors and it takes too much time. Existing methods have major defects in the identification of sediment flocs, that is, they cannot distinguish out-of-focus flocs well. There are different solutions to this problem, such as binarizing the image by calculating pixel gradients or selecting appropriate thresholds, but the above methods all involve the adjustment of various parameters. The actual implementation process is relatively cumbersome, and the accuracy of floc identification is low.
[0003] To this end, we designed a floc identification and positioning method based on the improved Yolov7 algorithm to solve the above problems. Summary of the invention
[0004] The purpose of the present invention is to solve the shortcomings of the prior art that the identification of sediment flocs cannot distinguish out-of-focus flocs well, and the adjustment process of various parameters involved in image processing is cumbersome and the accuracy of floc identification is low. A floc identification and positioning method based on an improved Yolov7 algorithm is proposed, which analyzes and identifies the images of sediment flocs in water bodies and is suitable for processing a large number of sediment flocs.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] A floc identification and positioning method based on an improved Yolov7 algorithm comprises the following steps:
[0007] Step S1, using an image acquisition device to collect images of sediment flocs in a water body;
[0008] Step S2, preprocessing the sediment floc image to reduce noise interference in the sediment floc image;
[0009] In step S3, the pre-processed sediment floc image is segmented using the Yolov7 algorithm to identify the target of the sediment floc image, and a separate image is segmented and saved as a mask layer image;
[0010] Step S4, outputting the mask layer image after instance segmentation, and performing thresholding processing on the mask layer image;
[0011] In step S5, based on the mask layer image, data information on the equivalent particle size, center coordinates and density of the target flocs is determined.
[0012] Further preferably, in step S1, the image acquisition device includes a camera, a sedimentation barrel and a light-emitting board, the camera is arranged on the left side of the sedimentation barrel, and the light-emitting board is arranged on the right side of the sedimentation barrel, the camera is a high-resolution high-speed camera, and the light-emitting board is a large-area square light source;
[0013] The method of collecting images of sediment flocs in water bodies using an image acquisition device is as follows:
[0014] Pour the water with silt flocs into the sedimentation barrel, turn on the light-emitting board, take a picture of the sedimentation barrel with a camera, and collect the image of the silt flocs in the water in the sedimentation barrel.
[0015] Further preferably, in step S2, a Gaussian filter operation is used to perform filter preprocessing on the sediment floc image, and the formula of the Gaussian function is expressed as:
[0016] ;
[0017] in, Represents the distance from the filter center to the current pixel, is the standard deviation of the Gaussian distribution, which controls the degree of blur. The pixel value of the filtered sediment floc image is calculated using the following formula:
[0018] ;
[0019] In the formula, represents the pixel value of the processed sediment floc image, represents the pixel value of the original image of the sediment floc image, Represents the x-coordinates of other pixels centered around the currently filtered pixel. Represents the y coordinates of other pixels centered on the currently filtered pixel. is the radius of the Gaussian kernel, is the value of the Gaussian function.
[0020] Further preferably, in step S3, the improved Yolov7 algorithm is used to perform instance segmentation on the preprocessed sediment floc image, identify the target of the sediment floc image, and segment a separate image as a mask layer image in the following manner:
[0021] The improved Yolov7 algorithm includes input layer, convolution layer, pooling layer, spatial pyramid pooling cross-stage partial connection, ELAN structure, upsampling, feature fusion, backbone feature extraction network, neck network and detection head;
[0022] The preprocessed sediment floc image is input into the model of the improved Yolov7 algorithm with a fixed size through the input layer. The backbone feature extraction network extracts multi-scale features of the input sediment floc image. First, it is subjected to two convolutional layers for preliminary feature extraction, and then it is subjected to multiple ELAN structures for feature information integration. Then, features of different scales are extracted through the combination of three convolutional layers and residual modules. Then, a fixed-size feature vector is generated by performing a maximum pooling operation through partial connection of the spatial pyramid pooling cross stage. The feature vector is input into the ELAN structure, and the multi-scale features extracted by the neck network and the backbone feature extraction network are deeply fused. The fused feature vector is output through the ELAN structure for upsampling to ensure that the high-dimensional features and low-dimensional features used for feature fusion have the same size. After upsampling, multiple feature fusions are performed through the combination of convolutional layers and pooling layers to achieve deep fusion of high-dimensional features and low-dimensional features at different scales. Finally, the fused features are passed to the detection head, which is responsible for predicting the fused features to obtain a mask layer image containing the target position information and category information of the sediment floc image.
[0023] Further preferably, the detection head of the improved Yolov7 algorithm includes three detection heads of different scales; the detection head contains two parallel links: the first link extracts features through multi-layer convolution and feature splicing operations, and finally generates target position information (bounding box) through a bounding box prediction module; the second link extracts features through multi-layer convolution and feature splicing operations, and finally generates target category information through a classification prediction module. These two links work together through feature fusion and feature maps of different scales to achieve target detection and classification.
[0024] Further preferably, the three detection heads of different scales include a P3 / 8 detection head, a P4 / 16 detection head and a P5 / 32 detection head. The pixel size of the feature detection image corresponding to the P3 / 8 detection head is 80*80, which is used to detect targets larger than 8*8. The pixel size of the feature detection image corresponding to the P4 / 16 detection head is 40*40, which is used to detect targets larger than 16*16. The pixel size of the feature detection image corresponding to the P5 / 32 detection head is 20*20, which is used to detect targets larger than 32*32.
[0025] Further preferably, the improved Yolov7 algorithm includes a SE attention mechanism (Squeeze and ExcitationAttention, selective compression and excitation mechanism), which extracts and learns the dependencies between feature channels on a global scale by introducing adaptive channel weights, and applies it to feature extraction of sediment floc images by assigning different weights to each channel, selectively emphasizing key features and suppressing secondary features.
[0026] Further preferably, the improved Yolov7 algorithm uses the mpDIoU loss function (mpDIoU: minimum pointDistance based Intersection over Union), considering the distance between the bounding box of the predicted target position information and the center point of the true bounding box, and increasing the distance penalty term so that the closer the center point is, the higher the mpDIoU loss function value is. The mpDIoU loss function introduces border normalization processing to accelerate the convergence speed of the algorithm model when detecting targets of different scales and shapes in sediment floc images.
[0027] Further preferably, in step S4, the process of performing thresholding processing on the mask layer image is as follows:
[0028] Step S41: treat the mask layer image as a The size of the matrix is , each value is the pixel value, the target and background segmentation threshold is recorded as optimal, and the proportion of the number of pixels belonging to the target to the entire image is recorded as , the average grayscale of the target pixel is recorded as , the ratio of background pixels to the entire image is recorded as , the average grayscale of the background pixels is recorded as , the total average grayscale of the image is recorded as , the inter-class variance is recorded as maximum, and the number of pixels in the image whose grayscale value is less than the segmentation threshold optimal is recorded as , the number of pixels whose grayscale value is greater than the segmentation threshold optimal is recorded as , calculated using the following formula:
[0029] ;
[0030] ;
[0031] ;
[0032] ;
[0033] ;
[0034] ;
[0035] The equivalent formula is: ;
[0036] In step S42, a traversal method is used to find the optimal segmentation threshold that maximizes the maximum inter-class variance, which is the grayscale value threshold. After the grayscale value threshold is obtained, the grayscale value of the pixel point whose grayscale value is greater than the grayscale value threshold is set to 1, and the grayscale value of the pixel point whose grayscale value is less than the grayscale value threshold is set to 0, thereby obtaining a binary image.
[0037] Further preferably, in step S5, the data information of the equivalent particle size, center coordinates and density of the target flocs is determined as follows:
[0038] Step S51, the process of determining the target floc centroid coordinates and the target floc area is as follows:
[0039] In the binary image, the connected area, i.e. the location of the target floc, is identified after filtering;
[0040] Calculate the coordinates of the target floc center , the calculation formula is:
[0041] ;
[0042] ;
[0043] in, is the coordinate of each pixel in the target area, is the total number of pixels in the target area, is the number of pixels in the target area;
[0044] The built-in function of Python is used to calculate the convex hull area of the connected region, that is, the target floc area;
[0045] Step S52, calculate the target floc equivalent particle size and density:
[0046] The target flocs are equivalent to circles, and their equivalent particle size is:
[0047] ;
[0048] in, is the target floc area, is the equivalent particle size;
[0049] Since the number of black pixels in a binary image is the area of the connected region, the density is calculated as: .
[0050] Compared with the prior art, the beneficial effects of the present invention are as follows: the floc identification and positioning method based on the improved Yolov7 algorithm proposed in the present invention extracts and analyzes features of sediment floc images existing in water bodies, is suitable for processing a large number of sediment flocs, and the algorithm model occupies little memory and has a fast detection speed, which is suitable for floc identification scenarios; through the algorithm model, fewer parameters are involved, the identification and positioning process is simplified, and the accuracy of floc identification is improved by using neural networks, especially for the elimination of out-of-focus flocs, which greatly improves the speed and accuracy of floc identification. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 A schematic diagram of a floc identification and positioning method based on an improved Yolov7 algorithm proposed in the present invention;
[0052] Figure 2 This is a schematic diagram of the arrangement of an image acquisition device in a floc identification and positioning method based on an improved Yolov7 algorithm proposed in the present invention;
[0053] Figure 3 This is a schematic diagram of the test results of the algorithm model in the present invention without introducing the mpDIoU loss function and adding the attention mechanism;
[0054] Figure 4 This is a schematic diagram of the test results of the algorithm model introducing the mpDIoU loss function in the present invention;
[0055] Figure 5 This is a schematic diagram of the test results of the algorithm model that introduces the mpDIoU loss function and adds the attention mechanism in the present invention.
[0056] The numbers in the figure are: 1. camera; 2. sedimentation barrel; 3. light-emitting panel. DETAILED DESCRIPTION
[0057] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.
[0058] Reference Figure 1 This embodiment proposes a floc identification and positioning method based on an improved Yolov7 algorithm, the method comprising the following steps:
[0059] In step S1, an image acquisition device is used to acquire images of sediment flocs in a water body.
[0060] The method of collecting images of sediment flocs in water bodies using an image acquisition device is as follows:
[0061] The water body with the silt flocs is injected into the sedimentation barrel 2 , the light-emitting panel 3 is turned on, and the sedimentation barrel 2 is photographed by the camera 1 to collect the image of the silt flocs in the water body in the sedimentation barrel 2 .
[0062] Among them, Figure 2 As shown, the image acquisition device used in this embodiment includes a camera 1, a sedimentation barrel 2 and a light-emitting panel 3. The camera 1 is arranged on the left side of the sedimentation barrel 2, and the light-emitting panel 3 is arranged on the right side of the sedimentation barrel 2. The camera 1 adopts a high-resolution high-speed camera, and the light-emitting panel 3 is a square light source with a large area, which can provide sufficient illumination for the image acquisition device and ensure the uniformity of illumination, thereby improving the quality of the captured image.
[0063] In step S2, the sand and flocculation image is pre-processed by filtering operation to reduce noise interference in the sand and flocculation image. In this step, Gaussian filtering is used to effectively reduce image noise and details, better smooth the image while retaining edge details, and the smoothing effect is more uniform, avoiding the problem of uneven smoothing. At the same time, the degree of smoothing can be controlled by adjusting the standard deviation, which is more flexible.
[0064] The Gaussian filter operation is used to filter the sediment floc image for preprocessing. The formula of the Gaussian function is expressed as:
[0065] ;
[0066] in, Represents the distance from the filter center to the current pixel, is the standard deviation of the Gaussian distribution, which controls the degree of blur. The pixel value of the filtered sediment floc image is calculated using the following formula:
[0067] ;
[0068] In the formula, represents the pixel value of the processed sediment floc image, represents the pixel value of the original image of the sediment floc image, Represents the x-coordinates of other pixels centered around the currently filtered pixel. Represents the y coordinates of other pixels centered on the currently filtered pixel. is the radius of the Gaussian kernel, is the value of the Gaussian function.
[0069] Since the selection of filtering parameters will affect the quality of the filtered image and the retention of details, smaller The value can reduce the blurring effect of Gaussian filtering, so that the details of small targets can be preserved. If it is too large, the image will be over-smoothed and small targets may be blurred, making them difficult to detect. Considering that floc particles are small, the standard deviation is selected as 1 and the Gaussian kernel size is 3*3.
[0070] In step S3, the Yolov7 algorithm is used to perform instance segmentation on the preprocessed sediment floc image, identify the target of the sediment floc image, and segment the individual image to save it as a mask layer image.
[0071] The improved Yolov7 algorithm includes input layer, convolution layer, pooling layer, spatial pyramid pooling cross-stage partial connection (SPPCSPC module), ELAN structure, upsampling, feature fusion, backbone feature extraction network, neck network and detection head;
[0072] The preprocessed sediment floc image is input into the model of the improved Yolov7 algorithm with a fixed size through the input layer. The backbone feature extraction network extracts multi-scale features of the input sediment floc image. First, it is subjected to two convolutional layers for preliminary feature extraction, and then it is subjected to multiple ELAN structures for feature information integration to enrich the feature information. Then, features of different scales are extracted through the combination of three convolutional layers and residual modules. Then, a fixed-size feature vector is generated by the maximum pooling operation through the partial connection of the spatial pyramid pooling cross stage. The feature vector is input into the ELAN structure, and the feature vector is deeply fused with the multi-scale features extracted by the backbone feature extraction network by using the neck network. The fused feature vector is output through the ELAN structure for upsampling to ensure that the high-dimensional features and low-dimensional features used for feature fusion have the same size. After upsampling, multiple feature fusions are performed through the combination of convolutional layers and pooling layers to achieve deep fusion of high-dimensional features and low-dimensional features at different scales. Finally, the fused features are passed to the detection head, which is responsible for predicting the fused features to obtain a mask layer image containing the target position information and category information of the sediment floc image.
[0073] The detection heads of the improved Yolov7 algorithm include three detection heads of different scales, which are used to detect targets as small as 8 pixels, medium-sized 16 pixels, and larger than 32 pixels. Pixel (px) is the basic unit of an image, which is used to describe the resolution and size of an image. For example, a 40*40 pixel image means that the image has 40 pixels in the horizontal direction and 40 pixels in the vertical direction.
[0074] The three detection heads of different scales include P3 / 8 detection head, P4 / 16 detection head and P5 / 32 detection head. The pixel size of the feature detection map corresponding to the P3 / 8 detection head is 80*80 (the width of the image is 80 pixels and the height is 80 pixels), which is used to detect targets larger than 8*8. The pixel size of the feature detection map corresponding to the P4 / 16 detection head is 40*40 (the width of the image is 40 pixels and the height is 40 pixels), which is used to detect targets larger than 16*16. The pixel size of the feature detection map corresponding to the P5 / 32 detection head is 20*20 (the width of the image is 20 pixels and the height is 20 pixels), which is used to detect targets larger than 32*32.
[0075] The detection head contains two parallel links: the first link extracts features through multi-layer convolution and feature concatenation operations, and finally generates target location information (bounding box) through the bounding box prediction module; the second link extracts features through multi-layer convolution and feature concatenation operations, and finally generates target category information through the classification prediction module. These two links work together through feature fusion and feature maps of different scales to achieve target detection and classification.
[0076] Reference Figure 3-Figure 5 The improved Yolov7 algorithm includes the SE attention mechanism (Squeeze and Excitation Attention). By introducing adaptive channel weights, the SE attention mechanism extracts and learns the dependencies between feature channels globally. By assigning different weights to each channel, it is applied to the feature extraction of sediment floc images, selectively emphasizing key features and suppressing secondary features. This mechanism enables the network to adaptively adjust to different types of inputs. The SE attention mechanism is lightweight and easy to integrate, does not significantly increase computational overhead, and can significantly improve the accuracy and robustness of the model in multiple tasks.
[0077] In addition, the improved Yolov7 algorithm uses the mpDIoU loss function (mpDIoU: minimum point distancebased intersection over union, loss function for bounding box regression). The mpDIoU loss function provides a more comprehensive and accurate bounding box similarity measurement compared to the default IoU. First, it considers the distance between the bounding box of the predicted target location information and the center point of the real bounding box. By adding the distance penalty term, the closer the center point is, the higher the mpDIoU value is, thereby improving the positioning accuracy. Secondly, the mpDIoU loss function introduces the border normalization process, making it more stable in the detection of objects of different scales and shapes. This improvement not only accelerates the convergence speed of the algorithm model, but also reduces the error in the case of aspect ratio mismatch. In addition, in dense targets and overlapping scenes, the mpDIoU loss function can more effectively distinguish which bounding box is closer to the real position, improving the detection performance of the model in complex scenes. Through these improvements, the mpDIoU loss function significantly enhances the robustness and accuracy of target detection.
[0078] In step S4, the mask layer image after instance segmentation is output and threshold processing is performed on the mask layer image, using the following steps:
[0079] Step S41: treat the mask layer image as a The size of the matrix is , each value is the pixel value, the target and background segmentation threshold is recorded as optimal, and the proportion of the number of pixels belonging to the target to the entire image is recorded as , the average grayscale of the target pixel is recorded as , the ratio of background pixels to the entire image is recorded as , the average grayscale of the background pixels is recorded as , the total average grayscale of the image is recorded as , the inter-class variance is recorded as maximum, and the number of pixels in the image whose grayscale value is less than the segmentation threshold optimal is recorded as , the number of pixels whose grayscale value is greater than the segmentation threshold optimal is recorded as , calculated using the following formula:
[0080] ;
[0081] ;
[0082] ;
[0083] ;
[0084] ;
[0085] ;
[0086] The equivalent formula is: ;
[0087] In step S42, a traversal method is used to find the optimal segmentation threshold that maximizes the maximum inter-class variance, which is the grayscale value threshold. After the grayscale value threshold is obtained, the grayscale value of the pixel point whose grayscale value is greater than the grayscale value threshold is set to 1, and the grayscale value of the pixel point whose grayscale value is less than the grayscale value threshold is set to 0, thereby obtaining a binary image.
[0088] Step S5 is to determine the data information of the equivalent particle size, center coordinates and density of the target flocs. The specific steps are as follows:
[0089] Step S51, the process of determining the target floc centroid coordinates and the target floc area is as follows:
[0090] In the binary image, the connected area, i.e. the location of the target floc, is identified after filtering;
[0091] Calculate the coordinates of the target floc center , the calculation formula is:
[0092] ;
[0093] ;
[0094] in, is the coordinate of each pixel in the target area, is the total number of pixels in the target area, is the number of pixels in the target area;
[0095] The built-in function of Python is used to calculate the convex hull area of the connected region, that is, the target floc area;
[0096] Step S52 calculates the equivalent particle size and density of the flocs:
[0097] The target flocs are equivalent to circles, and their equivalent particle size is:
[0098] ;
[0099] in, is the target floc area, is the equivalent particle size;
[0100] Since the number of black pixels in a binary image is the area of the connected region, the density can be calculated as: .
[0101] In step S6, the relevant data collected and calculated in the above steps are stored.
[0102] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A floc identification and positioning method based on an improved Yolov7 algorithm, characterized in that: The following steps are involved: Step S1, using an image acquisition device to collect images of sediment flocs in a water body; Step S2, preprocessing the sediment floc image to reduce noise interference in the sediment floc image; In step S3, the improved Yolov7 algorithm is used to perform instance segmentation on the preprocessed sediment floc image, identify the target of the sediment floc image, and segment the individual image to save it as a mask layer image; Step S4, outputting the mask layer image after instance segmentation, and performing thresholding processing on the mask layer image; In step S5, based on the mask layer image, data information on the equivalent particle size, center coordinates and density of the target flocs is determined.
2. The floc identification and positioning method based on the improved Yolov7 algorithm according to claim 1 is characterized in that: In step S1, the image acquisition device comprises a camera (1), a sedimentation barrel (2) and a light-emitting panel (3), wherein the camera (1) is arranged on the left side of the sedimentation barrel (2), and the light-emitting panel (3) is arranged on the right side of the sedimentation barrel (2), the camera (1) is a high-resolution high-speed camera, and the light-emitting panel (3) is a square light source; The method of collecting images of sediment flocs in water bodies using an image acquisition device is as follows: The water body with the silt flocs is injected into the sedimentation barrel (2), the light-emitting panel (3) is turned on, and the sedimentation barrel (2) is photographed by the camera (1) to collect the image of the silt flocs in the water body in the sedimentation barrel (2).
3. The floc identification and positioning method based on the improved Yolov7 algorithm according to claim 1 is characterized in that: In step S2, the Gaussian filter operation is used to filter the sediment floc image for preprocessing. The formula of the Gaussian function is expressed as: ; in, Represents the distance from the filter center to the current pixel, is the standard deviation of the Gaussian distribution, and the pixel value of the filtered sediment floc image is calculated using the following formula: ; In the formula, represents the pixel value of the processed sediment floc image, represents the pixel value of the original image of the sediment floc image, Represents the x-coordinates of other pixels centered around the currently filtered pixel. Represents the y coordinates of other pixels centered on the currently filtered pixel. is the radius of the Gaussian kernel, is the value of the Gaussian function.
4. The floc identification and positioning method based on the improved Yolov7 algorithm according to claim 1 is characterized in that: In step S3, the improved Yolov7 algorithm includes input layer, convolution layer, pooling layer, spatial pyramid pooling cross-stage partial connection, ELAN structure, upsampling, feature fusion, backbone feature extraction network, neck network and detection head; The preprocessed sediment floc image is input into the model of the improved Yolov7 algorithm with a fixed size through the input layer. The backbone feature extraction network performs multi-scale feature extraction on the input sediment floc image. First, the convolution layer performs preliminary feature extraction, and then the ELAN structure performs feature information integration. Then, the features of different scales are extracted through the combination of the convolution layer and the residual module. The maximum pooling operation is performed through the partial connection of the cross stage of the spatial pyramid pooling to generate a fixed-size feature vector. The feature vector is input into the ELAN structure, and the neck network is used to deeply fuse the feature vector with the multi-scale feature. The fused feature vector is output through the ELAN structure for upsampling so that the size of the high-dimensional features and low-dimensional features of the feature fusion are the same. After upsampling, multiple feature fusions are performed through the combination of the convolution layer and the pooling layer to achieve deep fusion of high-dimensional features and low-dimensional features at different scales. Finally, the fused features are passed to the detection head, which predicts the fused features to obtain a mask layer image containing the target position information and category information of the sediment floc image.
5. The floc identification and positioning method based on the improved Yolov7 algorithm according to claim 4 is characterized in that: The detection head of the improved Yolov7 algorithm includes three detection heads of different scales; The detection head contains two parallel links: the first link extracts features through multi-layer convolution and feature splicing operations, and finally generates the target position information through the bounding box prediction module; the second link extracts features through multi-layer convolution and feature splicing operations, and finally generates the target category information through the classification prediction module.
6. The method for floc identification and positioning based on the improved Yolov7 algorithm according to claim 5, characterized in that: The detection head includes a P3 / 8 detection head, a P4 / 16 detection head and a P5 / 32 detection head. The pixel size of the feature detection image corresponding to the P3 / 8 detection head is 80*80, which is used to detect targets larger than 8*8. The pixel size of the feature detection image corresponding to the P4 / 16 detection head is 40*40, which is used to detect targets larger than 16*16. The pixel size of the feature detection image corresponding to the P5 / 32 detection head is 20*20, which is used to detect targets larger than 32*32.
7. The method for floc identification and positioning based on the improved Yolov7 algorithm according to claim 4, characterized in that: The improved Yolov7 algorithm includes the SE attention mechanism, which extracts and learns the dependencies between feature channels on a global scale by introducing adaptive channel weights. By assigning different weights to each channel, it is applied to the feature extraction of sediment floc images to selectively emphasize key features and suppress secondary features.
8. The method for floc identification and positioning based on the improved Yolov7 algorithm according to claim 4, characterized in that: The improved Yolov7 algorithm uses the mpDIoU loss function, considering the distance between the bounding box of the predicted target location information and the center point of the true bounding box. By adding the distance penalty term, the closer the center point is, the higher the mpDIoU value is. The mpDIoU loss function introduces border normalization processing to detect targets of different scales and shapes in sediment floc images, thereby accelerating the convergence speed of the algorithm.
9. The method for floc identification and positioning based on the improved Yolov7 algorithm according to claim 1, characterized in that: In step S4, the mask layer image is thresholded, and the process is as follows: Step S41: treat the mask layer image as a The size of the matrix is , each value is the pixel value, the target and background segmentation threshold is recorded as optimal, and the proportion of the number of pixels belonging to the target to the entire image is recorded as , the average grayscale of the target pixel is recorded as , the ratio of background pixels to the entire image is recorded as , the average grayscale of the background pixels is recorded as , the total average grayscale of the image is recorded as , the inter-class variance is recorded as maximum, and the number of pixels in the image whose grayscale value is less than the segmentation threshold optimal is recorded as , the number of pixels whose grayscale value is greater than the segmentation threshold optimal is recorded as , calculated using the following formula: ; ; ; ; ; ; The equivalent formula is: ; In step S42, a traversal method is used to find the optimal segmentation threshold that maximizes the maximum inter-class variance, that is, the grayscale value threshold. After the grayscale value threshold is obtained, the grayscale value of the pixel point whose grayscale value is greater than the grayscale value threshold is set to 1, and the grayscale value of the pixel point whose grayscale value is less than the grayscale value threshold is set to 0, thereby obtaining a binary image.
10. The method for floc identification and positioning based on the improved Yolov7 algorithm according to claim 1, characterized in that: In step S5, the data information of the equivalent particle size, center coordinates and density of the target flocs is determined, and the process is as follows: Step S51, the process of determining the target floc centroid coordinates and the target floc area is as follows: In the binary image, the connected area, i.e. the location of the target floc, is identified after filtering; Calculate the coordinates of the target floc center , the calculation formula is: ; ; in, is the coordinate of each pixel in the target area, is the total number of pixels in the target area, is the number of pixels in the target area; The built-in function of Python is used to calculate the convex hull area of the connected region, that is, the target floc area; Step S52, calculate the target floc equivalent particle size and density: The target flocs are equivalent to circles, and their equivalent particle size is: ; in, is the target floc area, is the equivalent particle size; The number of black pixels in the binary image is the area of the connected region, and the density is calculated: .
Citation Information
Patent Citations
Coagulation floc character acquisition method and acquisition system
CN113628194A
Abnormal cell detection method based on improved YOLOv7 and Swinin-Unet
CN115965602A
Pipeline defect detecting and tracking method and device
CN116703826A
Waste drilling fluid flocculation recognition system
CN118397247A
Floc evaluation method
JP2022079796A