Fast detection and false positive discrimination method and system based on RGB chroma ratio
Patent Information
- Application Number
- CN202610715793.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-22
- Publication Date
- 2026-09-04
AI Technical Summary
然而,这种方法容易受到假阳性区域与目标区域相似性影响,导致漏检或误检
[0041] Analysis of the above-mentioned rapid detection and false positive identification method and system based on RGB colorimetric ratio provided by the present invention shows that, in specific applications, this method achieves efficient identification of target areas and accurate elimination of interference in test strip sample images through rapid detection and false positive identification based on RGB colorimetric ratio; this scheme obtains the image to be detected by color correction and color rendering area extraction of the original digital image, providing a reliable basis for subsequent analysis;
Smart Images

Figure CN122695005A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of images, and more particularly to a rapid detection and false positive identification method and system based on RGB chromaticity ratio. Background Technology
[0002] Object detection technology has wide applications in various fields, including medical diagnosis, environmental monitoring, and industrial production. Common image detection methods rely on different image processing techniques, such as color space conversion, texture analysis, feature extraction, and classification algorithms. Traditional object detection methods often depend on color, shape, or edge features, while giving less consideration to background noise and false positives. In test strip detection, especially for interfering objects of different colors (such as air bubbles), traditional detection methods struggle to effectively distinguish between targets and interfering objects, easily leading to false positive results.
[0003] Color is one of the most fundamental features in image processing. Analyzing images using color spaces such as RGB and HSV can effectively extract the color features of a target. However, factors such as background noise and changes in ambient lighting can easily cause color information to shift, affecting detection accuracy. Traditional color analysis methods mostly rely on directly comparing color values, which can easily lead to false positives or false negatives when processing images against complex backgrounds.
[0004] Traditional methods for identifying false positives typically rely on single features (such as grayscale or morphology). However, this approach is susceptible to the similarity between the false positive region and the target region, leading to missed or false positives. Multi-channel analysis based on color features, especially the G (green) and B (blue) channels in the RGB color space, can effectively distinguish interfering substances with specific color patterns, improving the accuracy of false positive identification. Summary of the Invention
[0005] The purpose of this invention is to provide a rapid detection and false positive identification method and system based on RGB color ratio, which solves the above-mentioned technical problems pointed out in the prior art.
[0006] This invention provides a rapid detection and false positive identification method based on RGB chromaticity ratio, the specific operation steps of which include:
[0007] The target test strip sample is collected to obtain a raw digital image, and the raw digital image is preprocessed to obtain the image to be detected;
[0008] The image to be detected is subjected to a sliding window to extract the gray values of pixels and calculate the texture intensity value to generate an abnormal connected region mask; the abnormal connected region mask is analyzed in the HSV color space to extract a first enhanced image; a gray-level histogram is constructed on the first enhanced image, and the mountain peaks are identified to determine the interference source region through the constructed gray-level histogram; the color values of the G and B channels in the RBG color space are extracted from the interference source region to identify the false positive region.
[0009] Preferably, the grayscale values of pixels are extracted using a sliding window to calculate the texture intensity value of the image to be detected, generating an abnormal connected region mask; the abnormal connected region mask is then analyzed in the HSV color space to extract the first enhanced image. The specific operation steps are as follows:
[0010] The image to be detected is converted into a grayscale image to be detected. A sliding window is formed on the grayscale image to be detected according to a preset window size. Grayscale values are extracted from all pixels in the sliding window. The maximum and minimum grayscale values in the sliding window are selected. The difference between the grayscale values is calculated as the texture intensity value of the pixel and a texture feature distribution map is generated.
[0011] A preset texture intensity threshold is set. If the texture intensity value of a pixel in the texture feature distribution map is greater than the texture intensity threshold, all adjacent pixels with a texture intensity value greater than the threshold are merged and binarized to obtain an abnormal connected region mask. Based on the abnormal connected region mask, the coordinate position of the corresponding pixel in the image to be detected is located. Based on the coordinate position of the pixel, the corresponding pixel is cropped from the image to be detected and recorded as an abnormal color region. The abnormal color region is converted to the HSV color space, and the V channel is extracted to obtain the luminance channel image. The luminance channel image is uniformly divided into grids, and a first grayscale histogram is constructed for the grayscale values of the pixels in each grid.
[0012] A preset cropping threshold is set; the pixel frequency of each gray value in the first gray-level histogram is determined sequentially; if the pixel frequency of each gray value in the first gray-level histogram is greater than the cropping threshold, the gray-level pixels in the first gray-level histogram that are greater than the cropping threshold are cropped, and the gray-level values of the cropped pixels are evenly distributed to all gray-level histograms; all the redistributed first gray-level histograms are equalized, and bilinear interpolation is used to stitch all the equalized first gray-level histograms together to convert them into RPG space to obtain the first enhanced image.
[0013] Preferably, a grayscale histogram is constructed on the first enhanced image, and the mountain peaks are identified and the interference source region is determined by using the constructed grayscale histogram; the color values of the G and B channels in the RGB color space are extracted from the interference source region to identify false positive regions. The specific operation steps are as follows:
[0014] A second grayscale histogram is reconstructed from all the first enhanced images; the grayscale mean of each pixel in the second grayscale histogram is calculated; and the grayscale deviation between each pixel's grayscale value and the grayscale mean is further calculated as the skewness of the second grayscale histogram; if the skewness is greater than or equal to 0, the first enhanced image is determined to have an interference source; the peak value of the mountain is determined from the second grayscale histogram; if the peak value of the mountain is less than a preset kurtosis significance threshold, the second grayscale histogram is determined to have an interference source.
[0015] For all second grayscale histograms, identify mountain peaks and calculate the inter-peak distance between all mountain peaks; if the inter-peak distance is less than a preset inter-peak distance threshold, determine that the mountain peaks are separate double peaks and identify them as sources of interference; determine the pixel positions in the corresponding grayscale histograms of all sources of interference to obtain the interference source region;
[0016] Based on the interference source region, corresponding pixels are extracted from the image to be detected. The color values of the G and B channels in the RGB color space are extracted from these pixels to construct a chromaticity response curve. Sampling points are obtained from the chromaticity response curve, and the slope of each sampling point is calculated. The sampling point with the largest slope is selected as the chromaticity change inflection point. The slopes corresponding to all chromaticity change inflection points are used as the dynamic interference threshold. The pixels in the image to be detected are divided into sub-windows, and the chromaticity difference index is calculated for each sub-window. The chromaticity difference index is used to select sub-windows as non-uniform local chromaticity abrupt change regions. Positive initial screening regions are selected based on the slope of each pixel in the image to be detected and the dynamic interference threshold. False positive regions are then selected from the corresponding positive initial screening regions within the local chromaticity abrupt change regions.
[0017] Preferably, based on the interference source region, corresponding pixels are extracted from the image to be detected. The color values of the G and B channels in the RGB color space are extracted from these pixels to construct a chromaticity response curve. Sampling points are obtained from the chromaticity response curve, the slope of the sampling points is calculated, and the sampling point with the largest slope is selected as the inflection point of chromaticity change. The specific operation steps are as follows:
[0018] In the image to be detected, the coordinate positions of all interference source regions are determined, and the color values of the G and B channels in the RBG color space are extracted to construct a chromaticity scatter plot. The color value of the G channel of each pixel in the chromaticity scatter plot is used as the independent variable, and the color value of the B channel is used as the dependent variable. The independent and dependent variables of the pixels are subjected to nonlinear fitting to obtain the chromaticity response curve.
[0019] The chromaticity response curve is sampled at preset intervals, and the slope of each sample point is calculated. The absolute value of the slope of each sample point is obtained, and the sample point with the largest slope is selected. The coordinates of the sample point are taken as the inflection point of chromaticity change.
[0020] Preferably, the slope corresponding to all chromaticity change inflection points is used as the dynamic interference threshold; the pixels in the image to be detected are divided into sub-windows, and the chromaticity difference index of each pixel in the sub-window is calculated; the chromaticity difference index is used to filter the sub-windows as non-uniform local chromaticity change regions; positive initial screening regions are determined based on the slope of each pixel in the image to be detected and the dynamic interference threshold. The specific operation steps are as follows:
[0021] The absolute value of the slope corresponding to the inflection point of the chromaticity change is used as the base value of the dynamic interference threshold; a preset relaxation coefficient is obtained; the dynamic interference threshold is calculated by multiplying the relaxation coefficient and the base value.
[0022] For each pixel in the image to be detected, the slope is calculated to construct a two-dimensional matrix of slopes; the two-dimensional matrix of slopes is divided according to the preset side length of the sub-window to obtain multiple sub-windows; the mean slope and standard deviation of the slope are calculated for the pixels in each sub-window; the mean slope and standard deviation of the slope are weighted and summed to obtain the chromaticity heterogeneity index; if the chromaticity heterogeneity index is greater than the preset chromaticity anomaly threshold, the sub-window is determined to be a non-uniform local chromaticity abrupt change region;
[0023] If the slope of each pixel in the image to be detected is greater than the dynamic interference threshold, then the pixel is determined to be a positive pixel. All adjacent positive pixels are then connected to form a positive initial screening area.
[0024] Preferably, false positive regions are screened from the corresponding positive screening regions in the local color change regions. The specific operation steps are as follows:
[0025] The positive initial screening region is extracted from the corresponding position on the local color change region as the positive connected region; the circularity of the positive connected region is calculated based on the total number of pixels in the positive connected region; the pixel coordinates of the edge of the positive connected region are determined, the convex hull vertices of the positive connected region are extracted, and the convex hull ratio is further calculated; the morphological features of the positive connected region are determined based on the circularity and convex hull ratio, and the false positive regions to be verified are screened out through the morphological features; a multimodal feature vector is constructed based on the circularity, convex hull ratio, and slope corresponding to the pixels of the false positive regions to be verified; the multimodal feature vector is input into a pre-built and trained classifier to output the true positive regions and false positive regions.
[0026] Preferably, the positive initial screening region is extracted from the corresponding position on the local color change region as the positive connected region; the circularity of the positive connected region is calculated based on the total number of pixels in the positive connected region; the pixel coordinates of the edge of the positive connected region are determined, the convex hull vertices of the positive connected region are extracted, and the convex hull ratio is further calculated. The specific operation steps are as follows:
[0027] For the local color change region and the positive initial screening region, determine the internal pixels. Retain the positive initial screening regions that overlap with the local color change region. Binarize the overlapping positive initial screening regions to obtain positive binary regions. Connect adjacent pixels between all positive binary regions to obtain multiple positive connected regions. Calculate the number of pixels in each positive connected region as its area. Calculate the total number of pixels at the edge of each positive connected region as its perimeter. Calculate the circularity of the positive connected regions using the area and perimeter of each positive connected region.
[0028] Determine the pixel coordinates of the edges of the positive connected region, and select the pixel of the edge with the smallest y-axis coordinate as the starting point; calculate the direction angle based on the starting point and the pixels of all edges; sort all direction angles in ascending order, extract the pixels of the edges with the same direction angle as the starting point, and select convex hull vertices based on the pixels of the edges; connect the convex hull vertices according to the coordinates of each convex hull vertex to form a polygon, and calculate the area of the polygon; calculate the convex hull ratio using the area of the positive connected region and the area of the polygon.
[0029] Preferably, the morphological features of the positive connected regions are determined based on their circularity and convex hull ratio, and false positive regions to be verified are selected through these morphological features. A multimodal feature vector is constructed using the circularity and convex hull ratio of the false positive regions to be verified and the slope of the corresponding pixels. The specific steps are as follows:
[0030] A preset circularity threshold, a convex hull ratio threshold, and a convex hull ratio upper limit threshold are defined. If the circularity of the positive connected region is less than the circularity threshold and the convex hull ratio is greater than the convex hull ratio threshold, then the positive connected region is determined to be an irregular edge and a non-convex shape feature.
[0031] If the circularity of the positive connected region is greater than the circularity threshold and the convex hull ratio is greater than or equal to the upper limit threshold of the convex hull ratio, then the positive connected region is determined to be a circular regular shape feature and is regarded as a false positive region to be verified.
[0032] Calculate the slope for each pixel in the false positive region to be verified; calculate the area ratio of the total number of pixels in the false positive region to the total number of pixels in the image to be detected; calculate the local binary pattern value for each pixel in the false positive region to be verified, and generate a binary pattern texture feature histogram.
[0033] The slope, area ratio, binary pattern texture feature histogram, and circularity and convex hull ratio of the false positive region to be verified are used together as a multimodal feature vector.
[0034] Preferably, the multimodal feature vector is input into a pre-built and trained classifier, which outputs true positive regions and false positive regions. The specific operation steps are as follows:
[0035] A pre-trained classifier is constructed; the multimodal feature vector of the false positive region to be verified is input into the pre-trained classifier, and the probability value of the false positive region to be verified as a true positive region is output.
[0036] A preset probability threshold is set; if the probability value of the true positive region is greater than or equal to the probability threshold, the false positive region to be verified is determined as the final true positive region; if the probability value of the true positive region is less than the probability threshold, the false positive region to be verified is determined as a false positive region.
[0037] Accordingly, this invention also proposes a rapid detection and false positive identification system based on RGB colorimetric ratio, comprising: a data acquisition module; and a recognition module;
[0038] The acquisition module is used to acquire raw digital images of the target test strip sample, and to preprocess the raw digital images to obtain the image to be detected.
[0039] The recognition module is used to extract pixel grayscale values and calculate texture intensity values from the image to be detected using a sliding window, generating an abnormal connected region mask; analyze the abnormal connected region mask in the HSV color space to extract a first enhanced image; construct a grayscale histogram for the first enhanced image, and identify mountain peaks and determine the interference source region through the constructed grayscale histogram; extract the color values of the G and B channels in the RBG color space from the interference source region to identify false positive regions.
[0040] Compared with the prior art, the embodiments of the present invention have at least the following technical advantages:
[0041] Analysis of the above-mentioned rapid detection and false positive identification method and system based on RGB colorimetric ratio provided by the present invention shows that, in specific applications, this method achieves efficient identification of target areas and accurate elimination of interference in test strip sample images through rapid detection and false positive identification based on RGB colorimetric ratio; this scheme obtains the image to be detected by color correction and color rendering area extraction of the original digital image, providing a reliable basis for subsequent analysis;
[0042] Furthermore, by using a sliding window to calculate local texture intensity, an abnormal connected region mask is generated, which effectively extracts regions with significant grayscale changes, masks the smooth background, and improves the accuracy of preliminary abnormal region detection.
[0043] Furthermore, abnormal areas are converted to the HSV color space for enhancement, making color features more prominent and aiding in the identification of major interference sources using grayscale histograms. This scheme locates interference areas by histogram peak values and extracts the G and B channel color values in the RGB space to determine false positive areas, achieving accurate identification of interference such as bubbles. This method can quickly distinguish between true and false positive areas, and even when grayscale and texture features are similar, it can accurately eliminate interference by relying on multi-channel color features, thereby improving the reliability and stability of test strip detection. At the same time, this method has a fast processing speed, is suitable for automated detection of large batches of samples, has strong robustness and scalability, can significantly reduce the false positive rate, ensure the authenticity and repeatability of test results, and provide efficient and reliable technical support for clinical or rapid testing scenarios. Attached Figure Description
[0044] Figure 1 This is the main flowchart of the rapid detection and false positive identification method based on RGB color ratio in Example 1;
[0045] Figure 2 This is a schematic diagram illustrating a false positive in the rapid detection and false positive identification method based on RGB colorimetric ratio in Example 1.
[0046] Figure 3This is a flowchart illustrating the interference source region of the rapid detection and false positive identification method based on RGB chromaticity ratio in Example 1.
[0047] Figure 4 This is the second grayscale histogram of the rapid detection and false positive identification method based on RGB chromaticity ratio in Example 1;
[0048] Figure 5 This is a flowchart of the positive initial screening area of the rapid detection and false positive identification method based on RGB color ratio in Example 1.
[0049] Figure 6 This is a flowchart of the multimodal feature vector of the fast detection and false positive identification method based on RGB chromaticity ratio in Example 1;
[0050] Figure 7 This is a flowchart of the rapid detection and false positive identification system based on RGB color ratio in Example 2;
[0051] Labels: Acquisition module 10; Recognition module 20. Detailed Implementation
[0052] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0053] The present invention will now be described in further detail with reference to specific embodiments and accompanying drawings.
[0054] Example 1
[0055] like Figure 1 As shown, this invention provides a rapid detection and false positive identification method based on RGB chromaticity ratio, and the specific operation steps include:
[0056] S10: Acquire the original digital image of the target test strip sample, and preprocess the original digital image to obtain the image to be detected;
[0057] It should be noted that the preprocessing includes color correction of the original digital image and extraction of the color-developing area of the test strip to obtain the image to be detected;
[0058] S20: Extract pixel grayscale values from the image to be detected using a sliding window to calculate texture intensity values and generate an abnormal connected region mask; analyze the abnormal connected region mask using the HSV color space to extract a first enhanced image; construct a grayscale histogram for the first enhanced image, and identify mountain peaks and determine the interference source region using the constructed grayscale histogram; extract the color values of the G and B channels in the RBG color space from the interference source region to identify false positive regions;
[0059] It should be noted that the image to be detected is scanned block by block using a sliding window (such as a 3x3 or 5x5 pixel window). Texture intensity values are calculated within each window, typically using grayscale variation, local variance, gradient magnitude, or energy functions. Pixels with texture intensity exceeding a threshold are marked as anomalous. Then, an anomalous connected region mask is generated based on pixel connectivity to extract regions with abnormal grayscale distribution or significant texture, masking smooth background areas and focusing only on areas that may contain targets or interference. This provides the basis for preliminary anomalous color region detection and provides candidate regions for subsequent color analysis and interference source identification. HSV color space analysis is performed on the anomalous connected region mask to extract the first enhanced image. The anomalous color regions are converted from the RGB color space to the HSV color space (hue H, saturation S, brightness V). Enhancement processing is applied to the anomalous color regions based on H, S, and V, such as enhancing contrast, adjusting brightness or saturation, to generate the first enhanced image. This makes the color and brightness characteristics of the anomalous color regions more obvious, and different colored interferences (such as bubbles, etc.) are also identified. Figure 2 The image (shown) performs better in the HSV space; the HSV space is more consistent with human visual perception and color feature expression, providing enhanced identifiable areas for grayscale histogram analysis and improving the accuracy of interference source detection; a grayscale histogram is constructed for the first enhanced image, the frequency of different grayscale values is counted, and the peaks in the histogram are found. These peaks represent the grayscale levels with a large proportion in the abnormal color area. The grayscale range corresponding to the peaks is located as the interference source area, and the most significant area in the grayscale distribution is automatically identified. The area corresponding to the peaks is usually a non-target interference, such as bubbles; the G and B channel color values in the RGB of the interference source area are extracted to identify false positive areas. The G (green) and B (blue) channel values are extracted from the interference source area in the RGB space; the region is determined to be a false positive based on the color value characteristics. For example, the G / B ratio of bubbles usually follows a specific pattern. Interference that is difficult to distinguish by grayscale and shape is excluded by color features, and false positive areas are accurately identified without affecting the real positive areas; multi-channel color features are used to make up for the deficiencies of grayscale and texture features, and improve the robustness of the detection system to false positive interference.
[0060] like Figure 3As shown, specifically, in step S20, a sliding window is used to extract the grayscale values of pixels in the image to be detected to calculate the texture intensity value and generate an abnormal connected region mask; the abnormal connected region mask is analyzed in the HSV color space to extract a first enhanced image; a grayscale histogram is constructed on the first enhanced image, and the peaks are identified and the interference source region is determined by using the constructed grayscale histogram; the color values of the G and B channels in the RBG color space are extracted from the interference source region to identify false positive regions. The specific operation steps are as follows:
[0061] S21: Convert the image to be detected into a grayscale image to be detected. Perform a sliding window operation on the grayscale image according to a pre-set window size (commonly 5×5 or 7×7 pixels (odd sizes facilitate center alignment)). Extract grayscale values from all pixels within the sliding window. Filter the maximum and minimum grayscale values within the sliding window, calculate the difference in grayscale values, and use this difference as the texture intensity value of the pixel (i.e., the larger the difference, the more drastic the texture change in the area; the grayscale difference is used as the texture intensity value at the center of the window; if all pixel grayscale values within the window are similar (the difference is very small or the variance is close to 0), the texture intensity value is low, indicating that the area is flat and uniform; if there are obvious changes in brightness (such as edges or bubbles) within the window, the texture intensity value is high). Generate a texture feature distribution map (i.e., the darker the color, the more drastic the texture change).
[0062] A preset texture intensity threshold is set (i.e., a texture intensity threshold is determined based on experience or statistics from a small number of normal samples (e.g., a texture intensity exceeding twice the average texture intensity of normal samples is considered abnormal)). If the texture intensity value of a pixel in the texture feature distribution map is greater than the texture intensity threshold, all adjacent pixels with a texture intensity value greater than the threshold are merged and binarized to obtain an abnormal connected region mask (i.e., represented as a binary image, where white pixels represent abnormal locations; when the binary mask is directly displayed as an image, the white areas are very conspicuous, making it easy to see which parts are marked as abnormal or targets by the algorithm; if black is used to represent abnormalities, the display will be completely black, with only a few black dots at the abnormal locations, which is not intuitive and not conducive to debugging).
[0063] It should be noted that the color image to be detected is converted into a grayscale image to simplify calculations and focus on analyzing the brightness change characteristics of the image; the next step is to scan the image and extract the pixel value of each window by setting a window (such as 5×5 or 7×7); a sliding window method is used to locally analyze the detailed features of the image; the difference between the maximum and minimum grayscale values in each window is calculated as the texture intensity value; this invention defines the texture intensity value as the difference between the maximum and minimum grayscale values in the sliding window, which reflects the degree of contrast change in a local area; the larger the difference, the more drastic the texture change in the area, which may correspond to abnormal features such as edges and bubbles; the texture intensity values of all sliding windows are summarized to generate a distribution map, where the darker the color, the more drastic the texture change, which can intuitively show possible abnormal color areas in the image; the above-mentioned determination of which areas have texture intensity exceeding the normal range by using a preset texture intensity threshold, and merging these areas to form an abnormal connected region mask, is to further gather abnormal information in the image;
[0064] S22: Based on the abnormal connected region mask, locate the coordinate position of the corresponding pixel in the image to be detected (RGB color image); based on the coordinate position of the pixel, crop out the corresponding pixel from the image to be detected and record it as the abnormal color region (that is, the abnormal color region formed by cropping out the pixel is an RPG color image, while the abnormal connected region mask is a grayscale image, so the color abnormal image at the corresponding position needs to be extracted from the image to be detected).
[0065] The abnormal color region is converted to the HSV color space, and the V channel (that is, the V channel contains brightness information but not color information) is extracted to obtain the brightness channel image.
[0066] The brightness channel image is uniformly divided into grids (i.e., the image is divided into small blocks of 8×8 or 16×16 pixels; if the entire image is adjusted uniformly, it will result in the overall image being too bright or too dark; block adjustment allows each small area to "manage its own brightness information" and adapt to local lighting conditions), and a first grayscale histogram is constructed for the grayscale values of the pixels in each grid.
[0067] A preset cropping threshold is defined (i.e., this threshold represents the maximum number of pixels allowed for each grayscale value; i.e., the pixel frequency refers to the number of pixels with a specific grayscale value in a certain region (or the entire image) of the image). The pixel frequency of each grayscale value is determined sequentially in the first grayscale histogram. If the pixel frequency of each grayscale value in the first grayscale histogram is greater than the cropping threshold, then the grayscale pixels in the first grayscale histogram that are greater than the cropping threshold are cropped, and the grayscale values of the cropped pixels are evenly distributed to all grayscale histograms.
[0068] Equalize all the reassigned first gray-level histograms, and then use bilinear interpolation to stitch all the equalized first gray-level histograms together to convert them into RPG space to obtain the first enhanced image;
[0069] It's important to note that the grayscale value range is from 0 (pure black) to 255 (pure white). The histogram is a statistical bar chart with the horizontal axis representing 0-255 and the vertical axis representing "how many pixels have this brightness value" (grayscale value 80). A preset grayscale value range for a pixel, such as 70, is used. All histograms with grayscale values exceeding 70 are cropped to prevent excessive contrast enhancement in the adjusted area due to a single brightness value appearing too frequently, resulting in noise or artifacts. The cropped grayscale values are then evenly distributed to the remaining grayscale histograms to avoid areas of excessive brightness or darkness in the adjusted image. Without redistribution, the cropped pixels are lost, reducing the overall brightness and darkening the image. Finally, all redistributed grayscale histograms are equalized to redistribute pixels across the entire 0-255 range. Within the range, the number of pixels at each brightness level is made approximately equal; after each histogram is adjusted independently, the brightness between adjacent blocks may be different, and obvious grid lines will appear at the boundaries between histograms, which looks like a collage. Therefore, bilinear interpolation is used to stitch the histograms together.
[0070] Based on the abnormal connected region mask obtained in the previous step, the corresponding region is extracted from the original image (extracted after converting the color image to grayscale). The abnormal color region is converted to the HSV color space, and the luminance channel (V channel) is extracted to remove color interference and retain only luminance information, which facilitates the adjustment of the image's lighting and contrast. The luminance channel image is divided into a uniform grid, and grayscale values are counted within each grid to generate a grayscale histogram. Grid division helps with local adjustments and avoids overall brightness being too bright or too dark. For the grayscale histogram of each grid, the part with grayscale values exceeding the set range is cropped, and the remaining grayscale values are evenly distributed. The equalization operation can make the image brightness distribution uniform and avoid the appearance of local areas that are too bright or too dark. Bilinear interpolation technology is used to stitch all the equalized grid images together to avoid obvious transition bands or stitching marks at the image edges, ensuring the smoothness and natural transition of the overall image.
[0071] S23: Reconstruct a second grayscale histogram from all the first enhanced images (i.e., this grayscale histogram is constructed from the entire first enhanced image, whereas the grayscale histogram in step S22 above was constructed from a grid, and finally stitched together to obtain the first enhanced image, so the two grayscale histograms are different); calculate the grayscale mean of the pixel grayscale values in the second grayscale histogram; and further calculate the grayscale deviation between the grayscale value of each pixel and the grayscale mean, as the skewness of the second grayscale histogram (i.e., the peak skewness in the second grayscale histogram).
[0072] If the skewness is greater than or equal to 0 (i.e., skewness ≈ 0, the histogram is roughly symmetrical; skewness > 0, the histogram has a long tail on the right or a steeper peak on the left (a small number of bright pixels in the overall dark area); skewness < 0, the histogram has a long tail on the left or a steeper peak on the right (a small number of dark pixels in the overall bright area); skewness not equal to 0 indicates severe asymmetry in distribution, which may be caused by interference), then it is determined that the first enhanced image has an interference source.
[0073] The peak value of the mountain is determined for the second gray-level histogram; if the peak value of the mountain is less than a preset kurtosis significance threshold, it is determined that the second gray-level histogram has a source of interference (i.e., kurtosis ≈ 3 is close to a normal distribution (normal uniform regions usually have higher kurtosis because pixels are concentrated); kurtosis > 3 has a very thin distribution (pixels are highly concentrated on a few gray values); kurtosis < 3 has a flat distribution (pixels are scattered over a wide gray range); interference is indicated by if the kurtosis is significantly low (e.g., < 2), it means that the histogram is too flat and the pixels are scattered, usually caused by noise or complex interference).
[0074] For all second grayscale histograms, identify the peaks and calculate the inter-peak distance (i.e., the distance between peaks). If the inter-peak distance is less than the preset inter-peak distance threshold, then the peaks are determined to be separated double peaks and identified as sources of interference (i.e., typical manifestations such as bubbles).
[0075] Determine the pixel positions in the corresponding grayscale histograms of all the interference sources to obtain the interference source region (i.e., if any one of the above three criteria is true, it is determined that there is an interference source in the first enhanced image).
[0076] It should be noted that a new second gray-level histogram is constructed for the enhanced image, and its gray-level mean is calculated. The second gray-level histogram differs from the first gray-level histogram in step S22 because it is a statistical result of the entire enhanced image. The step analyzes the distribution skewness of the histogram by calculating the deviation of each pixel from the gray-level mean. Skewness reflects whether the distribution of gray-level values is symmetrical. If the skewness is not zero, it may mean that there is asymmetrical lighting or interference sources in the image. The uniformity of the image is evaluated by calculating the kurtosis of the histogram. Low kurtosis may mean that there is noise or complex interference (such as bubbles) in the image because the pixel distribution of a normal image should be concentrated rather than scattered. The distance between adjacent peaks in the second gray-level histogram is calculated. If the distance is less than a preset threshold, it indicates that there may be a bimodal structure in the second gray-level histogram (usually due to interference sources). A bimodal structure is used to indicate that there may be interference such as bubbles in the second gray-level histogram. The step analyzes the second gray-level histogram as described above. Figure 4 As shown, possible sources of interference are identified and their corresponding pixel locations are determined. These areas are marked as interference areas to facilitate subsequent repair or further analysis.
[0077] S24: Extract corresponding pixels from the image to be detected based on the interference source region, extract the color values of the G and B channels in the RGB color space of the pixel, and construct a chromaticity response curve; obtain sampling points from the chromaticity response curve, calculate the slope of the sampling points, and select the sampling point with the largest slope as the chromaticity change inflection point; use the slope corresponding to all chromaticity change inflection points as the dynamic interference threshold; divide the pixels in the image to be detected into sub-windows, calculate the chromaticity difference index of each sub-window; use the chromaticity difference index to select sub-windows as non-uniform local chromaticity change regions; determine and select positive initial screening regions based on the slope of each pixel in the image to be detected and the dynamic interference threshold; select positive initial screening regions at corresponding positions from the local chromaticity change regions to select false positive regions;
[0078] It should be noted that when extracting pixels from previously identified interference source areas (such as bubbles), only the G (green) and B (blue) channel values in the RGB space are taken, ignoring the R channel. A chromaticity response curve is constructed, with pixel position as the x-axis and G / B channel values as the y-axis, yielding a color change curve of the interference area in the green and blue directions, which can reflect the color change trend. The G / B channels are sensitive to interference sources (such as bubbles), and extracting their chromaticity features helps distinguish abnormal color changes from normal textures. Several sampling points are selected on the chromaticity response curve (e.g., one every few pixels), and the slope between adjacent sampling points (Δchromaticity / ) is calculated. The sampling point with the largest slope (Δ position) is identified and considered the inflection point of chromaticity change. This inflection point corresponds to the pixel location with the fastest color change, typically an interference edge or abrupt change. Areas with significant color changes are marked to provide a reference for dynamic threshold setting. The threshold adapts to changes in the characteristics of the interference source, rather than being a fixed value, increasing robustness. Dynamic thresholding can distinguish significant chromaticity changes (potentially interference sources) from ordinary color fluctuations, reducing false positives. The image pixels to be detected are divided into sub-windows, and the chromaticity difference index of each sub-window is calculated to measure the degree of local pixel color change. Windows with large chromaticity changes may contain interference or abnormal color regions, transforming the whole-image analysis into a local analysis, thus making local anomalies more apparent. It is not usually masked by overall smoothing; sub-windows with large chromaticity difference indices are marked as non-uniform local chromaticity change regions, identifying areas that may have local interference (such as small bubbles), narrowing the area to be analyzed, reducing computational load, and focusing on potentially abnormal local areas; preliminary screening is performed based on pixel slope and dynamic interference threshold to obtain positive preliminary screening areas, initially screening out pixels that may have interference or abnormalities, and preliminarily identifying potential interference sources through dynamic threshold and slope judgment; positive preliminary screening areas are screened from local chromaticity change regions to eliminate false positives, and the obtained local chromaticity change regions are combined with positive preliminary screening areas to retain the truly possible interference source areas, that is, false positive areas;
[0079] like Figure 5As shown, specifically, in step S24, corresponding pixels are extracted from the image to be detected based on the interference source region. The color values of the G and B channels in the RGB color space are extracted from these pixels to construct a chromaticity response curve. Sampling points are obtained from the chromaticity response curve, and the slope of the sampling points is calculated. The sampling point with the largest slope is selected as the chromaticity change inflection point. The slopes corresponding to all chromaticity change inflection points are used as dynamic interference thresholds. The pixels in the image to be detected are divided into sub-windows, and the chromaticity difference index of each sub-window is calculated. The chromaticity difference index is used to select sub-windows as non-uniform local chromaticity change regions. Positive initial screening regions are selected based on the slope of each pixel in the image to be detected and the dynamic interference threshold. False positive regions are selected from the positive initial screening regions corresponding to the local chromaticity change regions. The specific operation steps are as follows:
[0080] S241: Determine the coordinate positions of all interference source areas in the image to be detected, extract the color values of the G channel (i.e., green channel) and B channel (i.e., blue channel) in the RBG color space, and construct a chromaticity scatter plot (i.e., establish a two-dimensional coordinate plane with the horizontal axis as the G value (0→255) and the vertical axis as the B value (0→255); plot the (G, B) values of each pixel as a pixel on the plane; if an independent region contains a large number of pixels, the pixels will form a cloud-like distribution).
[0081] The color value of the G channel of each pixel in the chromaticity scatter plot is used as the independent variable, and the color value of the B channel is used as the dependent variable; nonlinear fitting is performed on the independent and dependent variables of the pixel to obtain the chromaticity response curve.
[0082] It should be noted that, in the image to be detected, the coordinates of all interference source regions (such as bubbles) are determined, and the G (green) and B (blue) channel values of each pixel in these regions are extracted to construct a chromaticity scatter plot. Each pixel corresponds to a (G, B) coordinate, which is plotted on a two-dimensional plane. A large number of pixels will form a cloud-like distribution, reflecting the color concentration area and change trend. Using G as the independent variable and B as the dependent variable, a nonlinear fitting is performed on the scatter plot to obtain the chromaticity response curve. The obtained curve is a continuous curve of color change, rather than discrete points, which can better capture the color change trend of the interference region. The cloud-like distribution reflects the color concentration and distribution characteristics within the interference region. The color information of discrete pixels is transformed into an analyzable curve, which facilitates the subsequent calculation of slope and chromaticity change points, making the color transition boundaries more obvious. (At the same time, for the interference region (such as the edge of a bubble), the color change is regular. By fitting this curve, it is used to accurately describe how blue changes with the change of green; the steeper the curve (the larger the slope), the more drastic the change of blue relative to green in this region, which is often a typical feature of the edge of a bubble or scratch. Therefore, G...) (B is the independent variable, and B is the dependent variable).
[0083] S242: Sample points are obtained from the chromaticity response curve at preset intervals, and the slope of each sample point is calculated (that is, the slope is obtained by dividing the change in B value by the change in G value, which is the first derivative. Since the curve is non-linear, the slope will change along the G value).
[0084] For each sampling point, obtain the absolute value of the slope (i.e., ignore the positive and negative directions), and filter the sampling point with the maximum slope. The coordinates (G, B) of this sampling point are taken as the inflection point of chromaticity change (i.e., this inflection point represents the position where B changes most drastically relative to G in the interference area, usually corresponding to the chromaticity jump boundary from the background to the interference object).
[0085] It should be noted that sampling points are acquired on the chromaticity response curve at preset intervals, and the slope of each sampling point is calculated. Due to the non-linearity of the curve, the slope varies with the G value. The absolute value of the slope is taken (ignoring the direction), and the sampling point with the maximum slope is selected. The (G, B) coordinates of this sampling point are the inflection point of chromaticity change, corresponding to the position where B changes most drastically relative to G within the interference area. It is usually located at the color transition boundary between the background and the interference object. Finding the position where the color change in the interference area is most significant can clearly distinguish the boundary of the interference object, rather than being covered by the background or other smooth areas. This quantifies the local color mutation and provides a basis for subsequent dynamic threshold setting. The step uses slope judgment rather than a fixed threshold to adapt to different interference types and lighting conditions.
[0086] S243: The absolute value of the slope corresponding to the inflection point of the chromaticity change is used as the base value of the dynamic interference threshold (i.e., the absolute value of the slope comes from the identified interference source area, representing the typical degree of drastic chromaticity change of non-target interference objects (such as bubbles) in this image; different samples and different regions of interference sources will lead to different inflection point positions, thereby automatically adjusting the threshold to avoid missed detections or false detections caused by a fixed threshold; the threshold adjustment is based on the different slopes corresponding to each chromaticity change inflection point, forming a slope sequence of chromaticity change inflection points, which forms a dynamically adjusted interference threshold when used as the interference threshold); a preset relaxation coefficient is obtained (a real number greater than 0, typically 1.0-1.5, used for...). The relaxation factor is controlled to be more lenient. The dynamic interference threshold is calculated by multiplying the relaxation factor by the base value of the dynamic interference threshold. To avoid missing true positive areas (whose color change may be relatively gentle) by directly using the base value, a relaxation factor is introduced. The relaxation factor represents a reduction in the strictness of "detecting interference with interference", allowing the detection of areas with slightly weaker but still significant color changes. A sensitivity threshold slightly lower than the reference value is set based on the color change rate of typical interference in the image. This is used to filter out all pixel areas with similar or stronger color change characteristics to the interference, avoiding the failure of the fixed threshold under different lighting or sample conditions.
[0087] The slope is calculated for each pixel in the image to be detected, and a two-dimensional matrix of the slope is constructed; the two-dimensional matrix of the slope is divided according to the preset side length of the sub-window to obtain multiple sub-windows;
[0088] For each sub-window, calculate the mean slope (which reflects the uniformity within the window) and the standard deviation of the slope (which represents the degree of fluctuation in the ratio within the window).
[0089] The colorimetric heterogeneity index is obtained by weighted summation of the mean slope and the standard deviation of the slope.
[0090] If the chromaticity heterogeneity index is greater than the preset chromaticity anomaly threshold (i.e., the threshold value used to determine whether the "chromaticity heterogeneity index" is too high), then the sub-window is determined to be a non-uniform local chromaticity abrupt change region.
[0091] If the slope of each pixel in the image to be detected is greater than the dynamic interference threshold, then the pixel is determined to be a positive pixel. All adjacent positive pixels are connected to form a positive initial screening area.
[0092] It should be noted that the slope value sequence of chromaticity change inflection points is used as a dynamic interference threshold. The threshold is automatically adjusted for different samples and interference regions, avoiding false negatives or missed detections caused by fixed thresholds. The threshold is adaptive, accurately distinguishing significant color changes under different images or interference types, enhancing robustness, and applicable to interference sources with different samples and color characteristics. The slope is calculated for each pixel of the image, forming a two-dimensional matrix (each pixel has a slope value). The matrix is divided according to preset sub-window side lengths (e.g., 8×8 or 16×16), resulting in multiple local windows. This transforms full-image analysis into local analysis, facilitating the capture of local anomalies and conveniently calculating the uniformity and fluctuation level of each sub-window. Local processing is more sensitive than global processing, capable of detecting small but significant interference regions. The slope mean is calculated for each sub-window to reflect the overall color change level within the window, and the slope standard deviation is calculated to reflect the non-uniformity of change within the window. The weighted sum of the slope mean and standard deviation yields the chromaticity heterogeneity index. Windows with a high index represent large and non-uniform local color changes, potentially containing interference, providing a quantitative indicator. Screening for non-uniform local color abrupt changes; if the color heterogeneity index is greater than a preset threshold, the sub-window is determined to be a non-uniform local color abrupt change region, and the local abnormal color region is marked, filtering out uniform regions, narrowing the area to be analyzed, reducing false judgments, and improving the efficiency of subsequent screening; if the slope is greater than the dynamic interference threshold, it is determined to be a positive pixel, and adjacent positive pixels are connected to form a positive initial screening region, obtaining the preliminary location of potential interference regions, retaining continuous regions instead of single isolated pixels, reducing the impact of noise, and initially screening out possible interference sources, providing a basis for subsequent accurate detection or repair;
[0093] S244: Extract the positive initial screening region from the corresponding position on the local color change region as the positive connected region; calculate the circularity of the positive connected region based on the total number of pixels in the positive connected region; determine the pixel coordinates of the edge of the positive connected region, extract the convex hull vertices of the positive connected region, and further calculate the convex hull ratio; determine the morphological features of the positive connected region based on the circularity and convex hull ratio, and filter out the false positive regions to be verified through the morphological features; construct a multimodal feature vector based on the circularity and convex hull ratio of the false positive regions to be verified and the slope corresponding to the pixels; input the multimodal feature vector into a pre-built and trained classifier, and output the true positive regions and false positive regions;
[0094] It should be noted that, at the locations corresponding to local color abrupt change areas, positive initial screening regions are extracted, and these regions are formed into positive connected regions (regions formed by connecting adjacent positive pixel blocks); the positive points obtained from the initial screening are organized according to local regions to form analyzable connected domains, retaining only truly possible positive regions; the roundness is calculated based on the total number of pixels and the perimeter of the connected regions to obtain a rough shape index. The closer the roundness is to 1, the closer the region is to a circle, distinguishing between regular shapes (such as bubbles) and irregular shapes (such as sediment aggregates or strip-shaped regions), providing a reference for subsequent convex hull analysis and false positive screening; the coordinates of the edge pixels of the positive connected regions are found, and they are judged by sorting and orientation (similar to Graham's method). Scanning identifies the vertices of the convex hull, obtaining the outermost shape contour of the connected region. The convex hull ratio quantifies whether there are obvious depressions in the region, determining the convexity characteristics of the region and assisting in morphological classification. Edge and convex hull information provide shape features for subsequent multimodal features. Circularity and convex hull ratio are used to classify regions. Low circularity and high convex hull ratio form irregular edges and non-convex shapes (potentially true positive regions, such as sediment aggregates). High circularity and a convex hull ratio close to 1 form near-circular regular shapes (potential false positives, such as bubbles). Near-circular regions that may be false positives are marked as false positive regions to be verified. Regularly shaped potential interferences are extracted to form independent analysis units without destroying true positive regions, and these are retained for subsequent analysis. False positives are initially screened to reduce their likelihood. The impact of irrelevant interference on the final detection results is mitigated, focusing the screening task on potential false positive regions and improving the efficiency and accuracy of subsequent classification. Features such as roundness, convex hull ratio, and pixel slope (B / G channel ratio) are extracted for each region to be verified as a false positive. These features are then concatenated into a multimodal feature vector. Single shape or color features may not be sufficient to distinguish between true positives and false positives; the multimodal feature vector comprehensively describes the properties of the region, providing sufficient information for the classifier. The multimodal feature vector is then input into a trained classifier (such as SVM, random forest, or neural network). The classifier outputs the true positive probability for each region to be verified. Based on the probability threshold, the classifier automatically distinguishes between true positive regions and interference, ultimately outputting a high-precision positive detection result.
[0095] like Figure 6As shown, specifically, in step S244, the positive initial screening region is extracted from the corresponding position on the local color change region as a positive connected region; the circularity of the positive connected region is calculated based on the total number of pixels in the positive connected region; the pixel coordinates of the edge of the positive connected region are determined, the convex hull vertices of the positive connected region are extracted, and the convex hull ratio is further calculated; the morphological features of the positive connected region are determined based on the circularity and convex hull ratio, and the false positive regions to be verified are screened out through the morphological features; a multimodal feature vector is constructed based on the circularity and convex hull ratio of the false positive regions to be verified and the slope corresponding to the pixels; the multimodal feature vector is input into a pre-built and trained classifier to output the true positive regions and false positive regions. The specific operation steps are as follows:
[0096] S2441: Determine the pixels inside the local color change region and the positive initial screening region, retain the positive initial screening region that overlaps with the local color change region (that is, the positive initial screening region is located on the local color change region, retain this positive initial screening region, and discard the rest), binarize the overlapping positive initial screening region to obtain the positive binary region (that is, the pixel value of the foreground (positive pixel, that is, the pixel determined as the candidate target) is set to 255 (corresponding to white), and the pixel value of the background (non-positive pixel) is set to 0 (corresponding to black)).
[0097] Connect adjacent pixels between all positive binary regions to obtain multiple positive connected regions (i.e., find all interconnected white pixel blocks, each block is called a connected component).
[0098] Calculate the number of pixels for each positive connected region, and use that number as the area of the positive connected region.
[0099] Calculate the sum of the pixels at the edge of each positive connected region, which is taken as the perimeter of the positive connected region (i.e., the pixels at the edge can be identified using edge detection algorithms, which is common knowledge and will not be elaborated further).
[0100] The circularity of the positive connected region is calculated using the area and perimeter of the positive connected region. ;in, Represented as the perimeter of the positive connected region; Represented as the area of positive connected regions, this index is a classic definition in image shape analysis, with a value range of (0,1]. When the region shape is a perfect circle, the roundness = 1; the more elongated the region shape and the rougher the edges, the closer the roundness value is to 0; this index is not sensitive to scale (area size) and can stably describe the roundness characteristics of the shape.
[0101] It should be noted that the positive initial screening regions that overlap with the local color change regions are retained. The overlapping parts of the positive regions and the color change regions are kept, and the rest are discarded. The positive binary regions are obtained by binarization (positive pixels are white and the background is black). Positive connected regions are generated. Adjacent white pixels are connected to form connected components. Basic geometric features are calculated, including area (i.e., number of pixels), perimeter (i.e., number of edge pixels (which can be obtained through edge detection algorithms)), and roundness (i.e., area / perimeter (the closer to 1, the more round the region)). Possible interference regions are screened out, and the basic geometric features of the regions are obtained, providing data for subsequent convex hull analysis. The positive initial screening regions are standardized into analyzable binary connected regions, providing simple shape quantification indicators (area, perimeter, roundness) for preliminary identification of region types.
[0102] S2442: Determine the pixel coordinates of the edges of the positive connected region, and select the pixel with the smallest y-axis coordinate as the starting point (i.e., find the bottom left corner point (smallest y-coordinate, or smallest x-coordinate if they are the same). This point must be a vertex of the convex hull. If there are multiple points, select the point with the smallest x-coordinate (leftmost)); calculate the direction angle (the angle of counterclockwise rotation from positive right) based on the starting point and all edge pixels.
[0103] Sort all orientation angles in ascending order, extract the pixels of edges with the same orientation angle as the starting point, and filter the convex hull vertices based on the pixels of the edges (i.e., the specific operation in the scheme is to first create an empty stack, and then sort the first two points in ascending order). and (i.e., the pixels of the first and second edges in ascending order of orientation angle) are pushed onto the stack; for the third point after ascending sorting... Initially, the loop operations are executed sequentially, with the top two points of the stack set to 1 and 2. (The next one on the stack) and (Top of stack), calculate vector and cross product .x); if cross (Indicating clockwise rotation or collinearity), then the stack vertex is indicated. If it is not a vertex of the convex hull, pop it from the stack; if it crosses... (Indicating counter-clockwise rotation) then means It is a vertex of the convex hull, and the current point Push the points onto the stack and repeat the above process until all points have been processed. The remaining points on the stack constitute the set of convex hull vertices of the positive connected region.
[0104] Connect the vertices of the convex hull according to their coordinates to form a polygon, and calculate the area of the polygon (i.e., the convex hull is a polygon composed of vertices arranged in order). Composition; Method for calculating the area of a polygon (logical description), for each edge ,calculate Sum the results of all edges, take the absolute value, and divide by 2 to get the convex hull area; that is, the vertex order must be consecutive in either clockwise or counterclockwise order).
[0105] The convex hull ratio is calculated using the area of the positive connected region and the area of the polygon (i.e., the area of the connected region divided by the area of the polygon; the convex hull ratio measures the degree of convexity of a shape; a convex hull ratio close to 1 indicates that the shape has no depressions (close to convex), and a convex hull ratio much less than 1 indicates that there are significant depressions).
[0106] It should be noted that, after scanning all boundary points, the bottom left corner point (with the smallest y-coordinate, or the smallest x-coordinate if they are the same) is definitely a vertex of the convex hull. Using the starting point as the origin, calculate the direction angle of all other points relative to the starting point (the angle of counter-clockwise rotation from directly right), sort them in ascending order of angle. For points with the same angle, only the one furthest from the starting point is retained (the others are inside and not convex hull vertices). Maintain a stack, initially placing the starting point and the first sorted point. Add each new point sequentially, checking the direction formed by the top two points of the stack and the new point each time. A left turn (counter-clockwise) indicates the new point might be a convex hull vertex, so it is retained; a right turn (clockwise) indicates the top point is not a convex hull vertex, so it is popped, and the process continues with a new top point. Finally, all points remaining in the stack are convex hull vertices. The method for determining left / right turns is to take the top two points A and B of the stack and the new point C, and calculate the cross product of vectors AB and BC. If the cross product > 0, then a left turn (keeping B as a convex hull vertex); if the cross product < 0, then a right turn (B is not a convex hull vertex, so it is popped); if the cross product = ... 0 indicates that the three points are collinear (retain the endpoints and discard the midpoints);
[0107] S2443: Preset roundness threshold, convex hull ratio threshold, and upper limit threshold for convex hull ratio (i.e., the roundness threshold is usually set to 0.3 to 0.5, below which the shape is far from round; the convex hull ratio threshold is usually set to 0.85 to 0.95, above which the shape is basically convex (without obvious indentation); the upper limit threshold for convex hull ratio is a tolerance range, for example, a convex hull ratio ≥ 0.98 or convex hull ratio ≥ 0.99 is considered a threshold where the convex hull ratio is close to 1).
[0108] If the circularity of the positive connected region is less than the circularity threshold and the convex hull ratio is greater than the convex hull ratio threshold, then the positive connected region is determined to have irregular edges and non-convex morphological characteristics (i.e., the region is long and narrow, with rough edges or a star shape, but the overall outline is still close to the convex hull (not deeply concave), which is common in real positive regions (such as the aggregation of reaction precipitates)).
[0109] If the circularity of the positive connected region is greater than the circularity threshold and the convex hull ratio is greater than or equal to the upper limit threshold of the convex hull ratio (that is, the convex hull ratio is close to 1), then the positive connected region is determined to be a near-circular regular shape feature (that is, the shape of the connected region is close to a circle and the outline is convex and smooth without any depressions. This shape is common in non-target interference objects such as bubbles), and the positive connected region is regarded as a false positive region to be verified.
[0110] S2444: Calculate the slope for each pixel in the false positive region to be verified (i.e., the slope is the ratio calculated by the components of the B channel and the G channel, which will not be elaborated further).
[0111] Calculate the area ratio of the total number of pixels in the false positive region to the total number of pixels in the image to be detected (i.e., the area is calculated by using the number of pixels as the area; that is, it represents the proportion of the positive region to the whole image).
[0112] For each pixel in the region of false positives to be verified, calculate the local binary pattern value (i.e., the binary pattern (LBP) value is calculated by comparing the grayscale of the 8 surrounding neighboring pixels with the center pixel as the threshold. If the grayscale is greater than or equal to the center pixel, it is recorded as 1, and if it is less than, it is recorded as 0, resulting in an 8-bit binary number. Convert it into an integer from 0 to 255, and statistically analyze the distribution of LBP values of all positive initial screening pixels to generate a histogram), and generate a binary pattern texture feature histogram.
[0113] The slope, area ratio, binary pattern texture feature histogram, and circularity and convex hull ratio of the false positive region to be verified are used together as a multimodal feature vector.
[0114] It should be noted that the slope (B / G) is calculated to reflect color changes; the calculated area ratio reflects the number of pixels in the region / the total number of pixels in the image; the binary pattern of the 8-neighborhood of each pixel is calculated to generate an LBP value histogram, reflecting the texture of the region, and a multimodal feature vector is concatenated; color, area, shape and texture information are fused into a unified feature vector, which can describe the multidimensional features of false positive regions and provide sufficient information for the classifier; multimodal features improve discriminative power and avoid the inability of a single feature to distinguish between true positives and false positives;
[0115] S2445: Pre-build a trained classifier; input the multimodal feature vector of the false positive region to be verified into the trained classifier, and output the probability value of the false positive region to be verified as a real positive region;
[0116] A preset probability threshold is set; if the probability value of the true positive region is greater than or equal to the probability threshold, then the false positive region to be verified is determined as the final true positive region.
[0117] If the probability value of the true positive region is less than the probability threshold, then the false positive region to be verified is determined to be a false positive region.
[0118] It should be noted that genuine positive samples are divided into two categories. The first category is standard positive control samples, which use target analyte standards of known concentrations and prepare test strips according to standard testing procedures. Three concentration gradients (low, medium, and high) are set up, and no fewer than 30 samples are prepared for each concentration gradient. The second category is actual positive samples, which include no fewer than 200 actual clinical or field samples confirmed as positive by the gold standard method. Images of all samples are collected under different environmental conditions, with temperatures ranging from 15℃ to 35℃ and humidity ranging from 30% to 80%, to cover the impact of environmental changes on the images. False positive samples are simulated using various interfering substances through experimental methods. Simulation of bubble interference: A microbubble generator, i.e., a bubbler, is used. After the test liquid is added to the reaction area of the test strip, a small amount of air is sprayed onto the liquid surface to generate bubbles with a diameter of approximately 0.1 mm to 2 mm. By adjusting the airflow rate and spraying time, the density and size distribution of the bubbles can be controlled. Samples with sparse, medium, and dense bubble densities are prepared, with no fewer than 50 samples of each.
[0119] sparse 0.5 0.5 50 sparse 0.5 1.0 50 medium 1.0 1.0 50 medium 1.0 2.0 50 dense 2.0 2.0 50 dense 2.0 3.0 50 Bubble Interference Subtotal 300
[0120] When the above steps are executed, the true reaction color development area (target) and the false positive interference area (such as bubbles, which need to be excluded) are distinguished from all abnormal areas. This provides a technical basis for retaining the true positive and identifying and excluding false positives (interference).
[0121] Image acquisition utilizes industrial cameras or document scanners with a fixed resolution of at least 5 megapixels; equipped with standard LED ring light sources with a color temperature range of 5000K to 6500K to ensure uniform illumination; shooting distance, angle, and focal length are all fixed; 3 to 5 images of each sample are acquired under the same conditions for subsequent data enhancement; two professionals independently label the target areas in each image; real positive samples are labeled with the true reaction area, and false positive samples are labeled with various interference areas; if the labeling results of the two personnel are inconsistent, a third party will make the judgment to ensure the accuracy of the labeling;
[0122] For each labeled sample region, a multimodal feature vector is extracted. This feature vector consists of the following five types of features: Color features, which calculate the chromaticity slope of all pixels within the region, i.e., the ratio of the B channel to the G channel, and then calculate the mean and standard deviation of these slopes; the mean reflects the overall color tendency of the region, and the standard deviation reflects the degree of color fluctuation within the region; Morphological features, which calculate the roundness and convex hull ratio of the sample region; the roundness is calculated as four times pi multiplied by the area divided by the square of the perimeter, and the closer the value is to 1, the closer the region is to a circle; the convex hull ratio is calculated as the region area divided by the area of the convex hull polygon, and the closer the value is to 1, the closer the region is to a circle. A value close to 1 indicates a fuller, less concave region. The scale feature calculates the area ratio of the sample region (the number of pixels in the region divided by the total number of pixels in the image), reflecting the relative size of the target region. The texture feature calculates the local binary mode value of each pixel within the sample region. This is achieved by using the center pixel as a threshold, comparing the grayscale values of the eight surrounding pixels, generating an 8-bit binary number, converting it to an integer between 0 and 255, and then statistically analyzing the distribution of the local binary mode values of all pixels to generate a 256-dimensional normalized histogram. These features are then concatenated sequentially to obtain a 261-dimensional multimodal feature vector.
[0123] The dataset is composed of the feature vectors of all samples and their corresponding labels. The dataset is then divided into three subsets: a training set (70%) for training the classifier; a validation set (15%) for tuning hyperparameters; and a test set (15%) for final classifier performance evaluation. If the number of positive and negative samples is unbalanced, sample balancing is required. This can be achieved by undersampling to randomly remove majority class samples, oversampling to duplicate minority class samples, or assigning different weights to positive and negative samples during training. Random forest, support vector machine, or XGBoost can be chosen as the classifier; random forest is used as an example. First, the number of decision trees is set to 100. Then, for each decision tree, the same number of samples are randomly sampled with replacement from the training set, and approximately 16 features are randomly selected from the 261-dimensional features. A decision tree is constructed based on the selected samples and features. Each node of the decision tree is split according to the Gini impurity or information gain, selecting the optimal feature for splitting, until the preset maximum depth is reached or the number of samples in the node is less than the minimum number of split samples. Finally, all decision trees are combined into a random forest.
[0124] During training, a combination of five-fold cross-validation and grid search is used for hyperparameter tuning. For example, a search is conducted for the number of decision trees between 50 and 200 and the maximum depth between 5 and 20, selecting the parameter combination that performs best on the validation set. If a support vector machine is chosen, a radial basis function kernel is used, and the penalty coefficient C and the kernel function parameter gamma are tuned. If XGBoost is chosen, the learning rate, maximum depth, and number of trees are tuned.
[0125] The trained classifier is evaluated using a test set. Evaluation metrics include accuracy, precision, recall, F1 score, and area under the ROC curve. Accuracy represents the proportion of correctly classified samples. Precision represents the proportion of true positives among samples classified as positive. Recall represents the proportion of true positives correctly detected. The F1 score is the harmonic mean of precision and recall. The closer the area under the ROC curve is to 1, the better the classifier's performance. A classifier is considered to meet the requirements when the area under the ROC curve is above 0.95. The classifier outputs the probability value of each sample to be verified belonging to a true positive region, ranging from 0 to 1. A preset probability threshold is set, usually 0.5 by default. If the probability value is greater than or equal to the threshold, it is determined to be a true positive region; if the probability value is less than the threshold, it is determined to be a false positive region. This threshold can be adjusted according to actual application needs: to reduce false positives and improve precision, the threshold can be increased to 0.7 or 0.8; to reduce false negatives and improve recall, the threshold can be decreased to 0.3 or 0.4. The optimal threshold can be determined by the equilibrium point on the ROC curve; classifier training is common knowledge and is not the main focus of this solution, so it will not be elaborated further.
[0126] The multimodal feature vector is input into a trained classifier (such as random forest, SVM, or neural network), and the classifier outputs the true positive probability value. If the probability value is greater than or equal to the threshold, it is determined to be a true positive region. If the true positive probability value is less than the threshold, it is determined to be a false positive region. The region to be verified is accurately classified as a true positive or a false positive, eliminating non-target interference such as noise and bubbles, and improving detection accuracy. Machine learning is used to make automatic decisions, reducing reliance on human experience. Color, texture, area, and morphological features are combined to perform high-precision positive determination.
[0127] Example 2
[0128] like Figure 7 As shown, the present invention also provides a rapid detection and false positive identification system based on RGB color ratio, including: a data acquisition module 10; and an identification module 20.
[0129] The acquisition module 10 is used to acquire raw digital images of the target test strip sample, and to preprocess the raw digital images to obtain the image to be detected.
[0130] The recognition module 20 is used to extract pixel grayscale values and calculate texture intensity values from the image to be detected using a sliding window, and generate an abnormal connected region mask; analyze the abnormal connected region mask in the HSV color space to extract a first enhanced image; construct a grayscale histogram for the first enhanced image, and identify mountain peaks and determine the interference source region through the constructed grayscale histogram; extract the color values of the G and B channels in the RBG color space from the interference source region to identify false positive regions.
[0131] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; those skilled in the art can modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A rapid detection and false positive identification method based on RGB chromaticity ratio, characterized in that, The specific operating steps include: The target test strip sample is collected to obtain a raw digital image, and the raw digital image is preprocessed to obtain the image to be detected; The image to be detected is subjected to a sliding window to extract the gray values of pixels and calculate the texture intensity value to generate an abnormal connected region mask; the abnormal connected region mask is analyzed in the HSV color space to extract a first enhanced image; a gray-level histogram is constructed on the first enhanced image, and the mountain peaks are identified to determine the interference source region through the constructed gray-level histogram; the color values of the G and B channels in the RBG color space are extracted from the interference source region to identify the false positive region.
2. The rapid detection and false positive identification method based on RGB chromaticity ratio according to claim 1, characterized in that, The image to be detected is subjected to a sliding window to extract pixel grayscale values and calculate texture intensity values to generate an abnormal connected region mask; the abnormal connected region mask is then analyzed in the HSV color space to extract the first enhanced image. The specific operation steps are as follows: The image to be detected is converted into a grayscale image to be detected. A sliding window is formed on the grayscale image to be detected according to a preset window size. Grayscale values are extracted from all pixels in the sliding window. The maximum and minimum grayscale values in the sliding window are selected. The difference between the grayscale values is calculated as the texture intensity value of the pixel and a texture feature distribution map is generated. A preset texture intensity threshold is set; if the texture intensity value of a pixel in the texture feature distribution map is greater than the texture intensity threshold, then all adjacent pixels with a texture intensity value greater than the texture intensity threshold are merged and binarized to obtain an abnormal connected region mask. Based on the abnormal connected region mask, locate the coordinate position of the corresponding pixel in the image to be detected; based on the coordinate position of the pixel, crop out the corresponding pixel from the image to be detected and record it as the abnormal color region; The abnormal color region is converted to the HSV color space, the V channel is extracted, and a luminance channel image is obtained; the luminance channel image is uniformly divided into a grid, and a first grayscale histogram is constructed for the grayscale values of the pixels in each grid. Preset cropping threshold; The pixel frequency of each gray value is determined sequentially from the first gray-level histogram. If the pixel frequency of each gray value in the first gray-level histogram is greater than the cropping threshold, then the gray-level pixels in the first gray-level histogram that are greater than the cropping threshold are cropped, and the gray-level values of the cropped pixels are evenly distributed to all gray-level histograms; all the redistributed first gray-level histograms are equalized, and bilinear interpolation is used to stitch all the equalized first gray-level histograms together to convert them into RPG space to obtain the first enhanced image.
3. The rapid detection and false positive identification method based on RGB chromaticity ratio according to claim 2, characterized in that, A grayscale histogram is constructed on the first enhanced image. The constructed grayscale histogram is used to identify mountain peaks and determine the interference source region. The color values of the G and B channels in the RGB color space are extracted from the interference source region to identify false positive regions. The specific operation steps are as follows: Reconstruct a second grayscale histogram from all the first enhanced images; calculate the mean grayscale value of each pixel in the second grayscale histogram; and further calculate the grayscale deviation between each pixel's grayscale value and the mean grayscale value, which is used as the skewness of the second grayscale histogram. If the skewness is greater than or equal to 0, it is determined that the first enhanced image has a source of interference; the peak value of the mountain is determined for the second gray-level histogram; if the peak value of the mountain is less than a preset kurtosis significance threshold, it is determined that the second gray-level histogram has a source of interference. For all second grayscale histograms, identify mountain peaks and calculate the inter-peak distance between all mountain peaks; if the inter-peak distance is less than a preset inter-peak distance threshold, determine that the mountain peaks are separate double peaks and identify them as sources of interference; determine the pixel positions in the corresponding grayscale histograms of all sources of interference to obtain the interference source region; Based on the interference source region, the corresponding pixel is extracted from the image to be detected, and the color values of the G and B channels in the RBG color space are extracted from the pixel to construct a color response curve. Sampling points are obtained from the chromaticity response curve, the slope of the sampling points is calculated, and the sampling point with the largest slope is selected as the inflection point of chromaticity change. The slope corresponding to all inflection points of chromaticity change is used as the dynamic interference threshold; the pixels in the image to be detected are divided into sub-windows, and the chromaticity difference index of each pixel in the sub-window is calculated; the sub-windows are selected as non-uniform local chromaticity change regions using the chromaticity difference index; positive initial screening regions are selected based on the slope of each pixel in the image to be detected and the dynamic interference threshold; and false positive regions are selected from the positive initial screening regions corresponding to the local chromaticity change regions.
4. The rapid detection and false positive identification method based on RGB chromaticity ratio according to claim 3, characterized in that, Based on the interference source region, corresponding pixels are extracted from the image to be detected. The color values of the G and B channels in the RGB color space are extracted from these pixels to construct a chromaticity response curve. Sampling points are obtained from the chromaticity response curve, and the slope of these sampling points is calculated. The sampling point with the largest slope is selected as the inflection point of chromaticity change. The specific operation steps are as follows: In the image to be detected, determine the coordinate positions of all interference source regions, extract the color values of the G and B channels in the RBG color space, and construct a chromaticity scatter plot. The color value of the G channel of each pixel in the chromaticity scatter plot is used as the independent variable, and the color value of the B channel is used as the dependent variable. The independent and dependent variables of the pixels are fitted using nonlinear fitting to obtain the chromaticity response curve; The chromaticity response curve is sampled at preset intervals, and the slope of each sampling point is calculated. For each sampling point, obtain the absolute value of the slope, filter the sampling point with the maximum slope, and use the coordinates corresponding to the sampling point as the inflection point of chromaticity change.
5. The rapid detection and false positive identification method based on RGB chromaticity ratio according to claim 4, characterized in that, The slope corresponding to all chromaticity change inflection points is used as the dynamic interference threshold; the pixels in the image to be detected are divided into sub-windows, and the chromaticity difference index of each pixel in the sub-window is calculated; the sub-windows are selected as non-uniform local chromaticity change regions using the chromaticity difference index; positive initial screening regions are determined based on the slope of each pixel in the image to be detected and the dynamic interference threshold. The specific operation steps are as follows: The absolute value of the slope corresponding to the inflection point of the chromaticity change is used as the base value of the dynamic interference threshold; a preset relaxation coefficient is obtained; the dynamic interference threshold is calculated by multiplying the relaxation coefficient and the base value. The slope is calculated for each pixel in the image to be detected, and a two-dimensional matrix of slopes is constructed. The two-dimensional matrix of slopes is divided according to the preset side length of the sub-window to obtain multiple sub-windows. The mean slope and standard deviation of the slope are calculated for the pixels in each sub-window. The mean slope and standard deviation of the slope are weighted and summed to obtain the chromaticity heterogeneity index. If the chromaticity heterogeneity index is greater than the preset chromaticity anomaly threshold, then the sub-window is determined to be a non-uniform local chromaticity abrupt change region. If the slope of each pixel in the image to be detected is greater than the dynamic interference threshold, then the pixel is determined to be a positive pixel. All adjacent positive pixels are then connected to form a positive initial screening area.
6. The rapid detection and false positive identification method based on RGB chromaticity ratio according to claim 5, characterized in that, The process of screening for false positives from the local color change regions involves selecting positive initial screening regions at corresponding locations. The specific steps are as follows: The positive initial screening region is extracted from the corresponding position on the local color change region as the positive connected region; the circularity of the positive connected region is calculated based on the total number of pixels in the positive connected region; the pixel coordinates of the edge of the positive connected region are determined, the convex hull vertices of the positive connected region are extracted, and the convex hull ratio is further calculated; the morphological features of the positive connected region are determined based on the circularity and convex hull ratio, and the false positive regions to be verified are screened out through the morphological features. A multimodal feature vector is constructed by using the circularity and convex hull ratio of the false positive region to be verified and the slope of the corresponding pixel. The multimodal feature vector is then input into a pre-built and trained classifier to output the true positive region and the false positive region.
7. The rapid detection and false positive identification method based on RGB chromaticity ratio according to claim 6, characterized in that, The positive initial screening region is extracted from the corresponding position on the local color change region as the positive connected region; the circularity of the positive connected region is calculated based on the total number of pixels in the positive connected region; the pixel coordinates of the edge of the positive connected region are determined, the convex hull vertices of the positive connected region are extracted, and the convex hull ratio is further calculated. The specific operation steps are as follows: For the local color change region and the positive initial screening region, determine the internal pixels, retain the positive initial screening regions that overlap with the local color change region, binarize the overlapping positive initial screening regions to obtain positive binary regions; connect the adjacent pixels between all positive binary regions to obtain multiple positive connected regions. Calculate the number of pixels for each positive connected region, and use that number as the area of the positive connected region. Calculate the sum of the pixels at the edge of each positive connected region, which is taken as the perimeter of the positive connected region; calculate the circularity of the positive connected region using the area and perimeter of the positive connected region. Determine the pixel coordinates of the edge of the positive connected region, and select the pixel of the edge with the smallest y-axis coordinate as the starting point; Calculate the orientation angle based on the pixels of the starting point and all edges; sort all orientation angles in ascending order, extract the pixels of the edges with the same orientation angle as the starting point, and filter the convex hull vertices based on the pixels of the edges; Connect the vertices of each convex hull to form a polygon, and calculate the area of the polygon; The convex hull ratio is calculated using the area of the positive connected region and the area of the polygon.
8. The rapid detection and false positive identification method based on RGB chromaticity ratio according to claim 7, characterized in that, The morphological features of the positive connected regions are determined based on their circularity and convex hull ratio, and false positive regions to be verified are selected through these morphological features. A multimodal feature vector is constructed using the circularity and convex hull ratio of the false positive regions to be verified, as well as the slope of the corresponding pixels. The specific operation steps are as follows: A preset circularity threshold, a convex hull ratio threshold, and a convex hull ratio upper limit threshold are defined. If the circularity of the positive connected region is less than the circularity threshold and the convex hull ratio is greater than the convex hull ratio threshold, then the positive connected region is determined to be an irregular edge and a non-convex shape feature. If the circularity of the positive connected region is greater than the circularity threshold and the convex hull ratio is greater than or equal to the upper limit threshold of the convex hull ratio, then the positive connected region is determined to be a circular regular shape feature and is regarded as a false positive region to be verified. Calculate the slope for each pixel in the false positive region to be verified; calculate the area ratio of the total number of pixels in the false positive region to the total number of pixels in the image to be detected. For each pixel in the false positive region to be verified, calculate the local binary pattern value and generate a binary pattern texture feature histogram; The slope, area ratio, binary pattern texture feature histogram, and circularity and convex hull ratio of the false positive region to be verified are used together as a multimodal feature vector.
9. The rapid detection and false positive identification method based on RGB chromaticity ratio according to claim 8, characterized in that, The multimodal feature vectors are input into a pre-built and trained classifier, which outputs true positive regions and false positive regions. The specific operation steps are as follows: A pre-trained classifier is constructed; the multimodal feature vector of the false positive region to be verified is input into the pre-trained classifier, and the probability value of the false positive region to be verified as a true positive region is output. Preset probability threshold; If the probability value of the true positive region is greater than or equal to the probability threshold, then the false positive region to be verified is determined as the final true positive region. If the probability value of the true positive region is less than the probability threshold, then the false positive region to be verified is determined to be a false positive region.
10. A rapid detection and false positive identification system based on RGB chromaticity ratio, characterized in that, include: Data acquisition module; Recognition module; The acquisition module is used to acquire raw digital images of the target test strip sample, and to preprocess the raw digital images to obtain the image to be detected. The recognition module is used to extract pixel gray values from the image to be detected using a sliding window, calculate texture intensity values, and generate an abnormal connected region mask. The abnormal connected region mask is analyzed in HSV color space to extract the first enhanced image; a grayscale histogram is constructed on the first enhanced image, and the mountain peaks are identified to determine the interference source region through the constructed grayscale histogram; the color values of the G and B channels in the RBG color space are extracted from the interference source region to identify the false positive region.