Image occlusion detection method and apparatus
By combining multiple image occlusion detection algorithms and a dynamic threshold adjustment method, the problem of high false positive rates in existing technologies under varying lighting conditions and complex scenes is solved, achieving fast and accurate image occlusion detection under different conditions.
Patent Information
- Application Number
- CN202511198333.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-26
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2045-08-26
AI Technical Summary
Existing image occlusion detection methods based on the proportion of grayscale pixels in a single frame have a high false positive rate under varying lighting conditions and complex scenes, especially failing in nighttime environments. They also lack the ability to flexibly adjust the detection algorithm and cannot detect image occlusion quickly and accurately.
By combining the Laplacian variance algorithm, TOP-K grayscale ratio algorithm, information entropy algorithm and region analysis algorithm, and by adjusting the detection order and cross-validation, the preset threshold is dynamically adjusted to adapt to different lighting conditions and scenes. Combined with CLAHE contrast enhancement technology, the detection accuracy is improved.
It reduces the false positive rate and can quickly and accurately detect image occlusion in complex and dynamic occlusion scenarios. It avoids dependence on a single feature and improves the flexibility and adaptability of detection.
Smart Images

Figure CN120783057B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image detection, in particular to an image occlusion detection method and device. BACKGROUND
[0002] Camera occlusion detection is a key technology to ensure the reliable operation of vision systems, aiming to identify whether the lens is covered by foreign matter leading to imaging failure in real time. The current mainstream method relies on the pixel gray scale proportion statistics of a single gray scale image to make a judgment: the proportion of dark (or bright) pixels below (or above) a fixed threshold in the image is calculated, and if it exceeds the preset value, it is determined to be occluded.
[0003] However, this method has significant limitations:
[0004] (1) Single feature, high false positive rate: it is difficult to distinguish between real occlusion (such as stains) and large-area dark areas in normal scenes (such as shadows, dark objects) by relying solely on global gray scale proportion, which can easily lead to false positives; at the same time, it is not sensitive to local or complex texture occlusions, which can easily lead to false negatives.
[0005] (2) Nighttime failure: normal images are generally dark at night, and the proportion of dark pixels is bound to be high. This method will generally misjudge it as occlusion, and cannot adapt to low-light environments.
[0006] (3) Poor robustness: relies on a fixed threshold, making it difficult to adapt to changes in lighting and scene switching; lacks the use of temporal information, and is sensitive to transient disturbances.
[0007] In summary, the existing method based on single-frame gray scale pixel proportion has a single principle, is sensitive to light, and is particularly ineffective in nighttime environments, with insufficient accuracy and adaptability. Therefore, there is a lack of an image occlusion detection method and device that can flexibly adjust the detection order of the detection algorithm to fuse multiple image occlusion detection algorithms and quickly and accurately detect whether the image to be detected is occluded. SUMMARY
[0008] Therefore, it is necessary to provide an image occlusion detection method and device that can flexibly adjust the detection order of the detection algorithm to fuse multiple image occlusion detection algorithms and quickly and accurately detect whether the image to be detected is occluded.
[0009] In a first aspect, the present application provides an image occlusion detection method, which comprises:
[0010] obtaining image occlusion detection algorithm calling parameters;
[0011] According to the image occlusion detection algorithm calling parameter, a detection order of multiple image occlusion detection algorithms is determined, wherein the image occlusion detection algorithms include a Laplacian variance algorithm, a TOP-K gray scale proportion algorithm, an information entropy algorithm, and a region analysis algorithm;
[0012] An image to be detected is acquired, and based on the detection order, the multiple image occlusion detection algorithms are sequentially used to judge whether the image to be detected is occluded;
[0013] When the adjacent previous image occlusion detection algorithm judges that the image to be detected is occluded, the judgment of the image to be detected by the next image occlusion detection algorithm is continued;
[0014] When the adjacent previous image occlusion detection algorithm judges that the image to be detected is not occluded, the judgment of the image to be detected by the remaining image occlusion detection algorithms is terminated, and it is directly determined that the image to be detected is not occluded.
[0015] Optionally, the TOP-K gray scale proportion algorithm includes:
[0016] The image to be detected is converted into a first gray scale image, and the first gray scale image is converted into a corresponding first gray scale histogram;
[0017] The gray scale values corresponding to the first gray scale histogram are sorted according to the occurrence frequencies, and the K gray scale values with the highest occurrence frequencies are extracted as first target gray scale values;
[0018] The total number of pixels of the image to be detected is calculated, and the ratio of the sum of the occurrence frequencies of the first target gray scale values to the total number of pixels is taken as an occlusion proportion;
[0019] The occlusion proportion is compared with a preset gray scale proportion threshold value to determine whether the image to be detected is occluded.
[0020] Optionally, after the total number of pixels of the image to be detected is calculated, and the ratio of the sum of the occurrence frequencies of the first target gray scale values to the total number of pixels is taken as the occlusion proportion, the method further includes:
[0021] A brightness factor of the first gray scale image is calculated;
[0022] According to the brightness factor, a low brightness factor threshold value, and a high brightness factor threshold value, the preset gray scale proportion threshold value is adjusted.
[0023] Optionally, according to the brightness factor, the low brightness factor threshold value, and the high brightness factor threshold value, the preset gray scale proportion threshold value is adjusted, including:
[0024] When the brightness factor is less than the low brightness factor threshold value, the preset gray scale proportion threshold value is adjusted to a first preset gray scale proportion threshold value;
[0025] The preset gray scale proportion threshold is adjusted to a second preset gray scale proportion threshold when the brightness factor is greater than the high brightness factor threshold.
[0026] The first preset gray scale proportion threshold is less than the second preset gray scale proportion threshold.
[0027] Optionally, the information entropy algorithm comprises:
[0028] The to-be-detected image is converted into a second gray scale image, and the second gray scale image is converted into a corresponding second gray scale histogram;
[0029] The gray scale values corresponding to the second gray scale histogram are sorted according to the occurrence frequencies, and the K gray scale values with the highest occurrence frequencies are extracted as second target gray scale values;
[0030] According to the occurrence frequencies of the second target gray scale values and the sum of the occurrence frequencies of the second target gray scale values, the probabilities of the second target gray scale values are calculated;
[0031] According to the frequencies of the second target gray scale values, the information entropy of the K second target gray scale values is calculated, and the calculation formula of the information entropy of the K second target gray scale values is:
[0032]
[0033] wherein, is the second target gray scale value, is the probability of the second target gray scale value
[0034] According to the preset information entropy threshold and the information entropy of the K second target gray scale values, it is determined whether the to-be-detected image is blocked.
[0035] Optionally, the region analysis algorithm comprises:
[0036] The to-be-detected image is converted into a third gray scale image, the centroid O of the third gray scale image is calculated by a gray scale weighted centroid method, and the O is taken as the center to divide into concentric ring regions in an equal gradient increasing manner , wherein, is a core ring, is an edge ring;
[0037] For each concentric ring region , the following is performed: the gradient amplitudes of the pixel points in the concentric ring region are calculated by using a Sobel operator ; a third gray scale histogram with gradient weighting is constructed according to the gradient amplitudes of the pixel points in the concentric ring region ; the probability distribution is obtained by normalizing the third gray scale histogram, and the concentric ring region The information entropy of the third gray image, wherein the calculation formula is: , ;
[0038] If , and , it is determined that the image to be detected is not blocked;
[0039] If and , it is determined that the image to be detected is locally blocked;
[0040] If and , the slope of the entropy change curve is calculated ; when , it is determined that the image to be detected is centrally concentrated overall blocked; when , it is determined that the image to be detected is uniformly dispersed overall blocked;
[0041] Wherein, is a normal texture entropy threshold; is a non-blocking tolerance; is a decay threshold; is an overall blocking tolerance; is a slope threshold; is the information entropy of the core ring; is the information entropy of the edge ring; is the radius of the core ring, the value of which is 1 / 10 to 1 / 6 of the short side of the third gray image; is the radius of the edge ring.
[0042] Optionally, the concentric ring radius , wherein, , , respectively, the width and height of the third gray image, is the total number of ring domains, and .
[0043] Optionally, according to the gradient amplitude of each pixel point in the concentric ring region , a gradient-weighted third gray histogram is constructed, comprising:
[0044] Grouping the pixels in the concentric ring region by gray level;
[0045] According to the gradient amplitude of each pixel point in the concentric ring region , the weight value of the gray level is calculated using the calculation formula: , wherein, is the pixel a gray value of the image.
[0046] Optionally, after obtaining the image to be detected, the method further comprises:
[0047] calculating a brightness factor of the image to be detected;
[0048] when the brightness factor is less than a low brightness factor threshold, performing CLAHE contrast enhancement on the image to be detected to enhance details.
[0049] In a second aspect, the present application provides an image occlusion detection device, comprising: a parameter configuration module, an algorithm sorting module and an image detection module; wherein,
[0050] the parameter configuration module is configured to obtain image occlusion detection algorithm calling parameters;
[0051] the algorithm sorting module is connected to the parameter configuration module and is configured to determine the detection order of multiple image occlusion detection algorithms according to the image occlusion detection algorithm calling parameters, wherein the image occlusion detection algorithms include Laplacian variance algorithm, TOP-K gray scale proportion algorithm, information entropy algorithm and region analysis algorithm;
[0052] the image detection module is connected to the algorithm sorting module and is configured to obtain an image to be detected and sequentially use multiple image occlusion detection algorithms to judge whether the image to be detected is occluded based on the detection order, wherein when the adjacent previous image occlusion detection algorithm judges that the image to be detected is occluded, the next image occlusion detection algorithm is executed to judge the image to be detected; when the adjacent previous image occlusion detection algorithm judges that the image to be detected is not occluded, the execution of the remaining image occlusion detection algorithms to judge the image to be detected is terminated, and it is directly determined that the image to be detected is not occluded.
[0053] The image occlusion detection method and device provided by the present application first obtain image occlusion detection algorithm calling parameters and determine the detection order of multiple image occlusion detection algorithms according to the parameters, wherein the image occlusion detection algorithms include Laplacian variance algorithm, TOP-K gray scale proportion algorithm, information entropy algorithm and region analysis algorithm; then obtain an image to be detected and sequentially use multiple image occlusion detection algorithms to judge whether the image to be detected is occluded based on the detection order, wherein when the adjacent previous detection algorithm judges that the image to be detected is occluded, the next detection algorithm is executed to judge the image to be detected; when the adjacent previous detection algorithm judges that the image to be detected is not occluded, the execution of the remaining detection algorithm to judge the image to be detected is terminated, and it is directly determined that the image to be detected is not occluded. The method and device of the present application can flexibly adjust the detection order of the detection algorithm to fuse multiple image occlusion detection algorithms, and quickly and accurately detect whether the image to be detected is occluded. BRIEF DESCRIPTION OF DRAWINGS
[0054] Figure 1 A flowchart of a first image occlusion detection method provided by the present application is shown in the figure;
[0055] Figure 2 A flowchart of a TOP-K gray scale proportion algorithm in the image occlusion detection method provided by the present application is shown in the figure;
[0056] Figure 3 A flowchart of an information entropy algorithm in the image occlusion detection method provided by the present application is shown in the figure;
[0057] Figure 4 A circuit module structure diagram of the image occlusion detection device provided by the present application is shown in the figure;
[0058] Figure 5 An internal structure diagram of the computer device in an embodiment of the present application is shown in the figure. DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solutions and advantages of the present application clearer and more apparent, the present application will be further described in detail below in combination with the figures and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.
[0060] As shown in the figure, Figure 1 The present application provides an image occlusion detection method, which comprises:
[0061] Step S11: Obtain image occlusion detection algorithm calling parameters;
[0062] The image occlusion detection algorithm calling parameters are pre-set by those skilled in the art, which can include parameters corresponding to various image occlusion detection algorithms, such as interpretability parameters and stability parameters. The interpretability parameters and stability parameters can be pre-set by those skilled in the art or obtained by a large model, which is not limited here. It should be understood that the interpretability refers to the ability of the image occlusion detection algorithm to understand and analyze the image, and the stability refers to the stability of the image occlusion detection algorithm to output correct results when judging whether the image is occluded.
[0063] Step S12: Determine the detection order of multiple image occlusion detection algorithms according to the image occlusion detection algorithm calling parameters, wherein the image occlusion detection algorithms include Laplacian variance algorithm, TOP-K gray scale proportion algorithm, information entropy algorithm and region analysis algorithm;
[0064] In the present application, the Laplacian variance algorithm is the existing Laplacian variance algorithm, which will not be described here.
[0065] Optionally, as shown in the figure, Figure 2 The TOP-K gray scale proportion algorithm in the present application comprises:
[0066] Step S21: converting the image to be detected into a first gray image, and converting the first gray image into a corresponding first gray histogram;
[0067] Optionally, the image to be detected is converted into a first gray image using cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) in OpenCV (a cross-platform computer vision and machine learning software library based on Apache2.0 license (open source)). cv2.cvtColor is a function in OpenCV, and the cv2.cvtColor function is used for color space conversion. The first parameter is the input image to be detected, and the second parameter is the color conversion code. cv2.COLOR_BGR2GRAY means conversion from BGR color space to gray color space.
[0068] Optionally, the first gray image is converted into a corresponding first gray histogram, which can use cv2.calcHist([gray_image], [0], None,
[256] , [0,256]) in OpenCV. Wherein, gray_image is the first gray image; [0] represents the 0th gray channel; None is usually missing, indicating that the default window size and position are used to calculate the histogram;
[256] represents that a histogram with a length of 256 is created, and the gray value range is 0 to 255; [0, 256]) represents the value range of the gray value.
[0069] Of course, those skilled in the art can also use other methods to convert the image to be detected into a first gray image, and convert the first gray image into a corresponding first gray histogram, which is not limited here.
[0070] Step S22: sorting the gray values corresponding to the first gray histogram according to the frequency of occurrence, and extracting the K gray values with the highest frequency of occurrence as the first target gray values;
[0071] In step S22, the value of K can be flexibly set according to actual needs, for example: K=30, which is not limited here.
[0072] Step S23: calculating the total number of pixels of the image to be detected, and taking the ratio of the sum of the frequencies of occurrence of each first target gray value to the total number of pixels as the occlusion ratio;
[0073] Step S24: comparing the occlusion ratio with a preset gray ratio threshold to determine whether the image to be detected is occluded.
[0074] Specifically, the occlusion ratio can be calculated as follows:
[0075]
[0076] wherein, is a first target gray value, is a first target gray value probability; is a width of the first gray image, is a height of the first gray image.
[0077] In the case of an occluded image, the gray distribution will be more concentrated, and the K gray values with the highest frequency will occupy more pixel regions. This method not only effectively determines whether the image is occluded, but also reduces the analysis and calculation amount and improves the analysis and calculation efficiency.
[0078] In a low brightness image, the gray distribution will shift significantly to the left (towards the dark area), and the gray value of the occluded area will also tend to be darker. Therefore, if the traditional fixed threshold value is used for judgment, it may cause misjudgment of the low contrast area as occluded. The dynamic brightness factor adjusts the preset gray proportion threshold to solve this problem. Specifically, a lower brightness factor (when the image as a whole is darker) will relax the occlusion judgment standard, because in a low brightness image, the gray value change of the occluded area may not be obvious. A higher brightness factor (when the image as a whole is brighter) maintains a strict occlusion judgment standard, because in a high brightness image, the gray change of the occluded area is more likely to be detected. Therefore, after step S23, the method can further include:
[0079] Step S25: calculating a brightness factor of the first gray image;
[0080] wherein, the brightness factor of the first gray image can be calculated by the existing technology mean_gray / 255.0, and the range of the brightness factor is [0, 1], which represents the brightness of the first gray image.
[0081] Step S26: adjusting the preset gray proportion threshold according to the brightness factor, the low brightness factor threshold and the high brightness factor threshold.
[0082] Optionally, step S26 specifically includes:
[0083] Step S261: when the brightness factor is less than the low brightness factor threshold, adjusting the preset gray proportion threshold to a first preset gray proportion threshold;
[0084] Step S262: when the brightness factor is greater than the high brightness factor threshold, adjusting the preset gray proportion threshold to a second preset gray proportion threshold;
[0085] wherein, the first preset gray proportion threshold is less than the second preset gray proportion threshold.
[0086] Optionally, the low brightness factor threshold is 0.3, the high brightness factor threshold is 0.8, the first preset grayscale ratio threshold is 0.6, and the second preset grayscale ratio threshold is 0.85. It should be noted that when the brightness factor is greater than the low brightness factor threshold and less than the high brightness factor threshold, it indicates that the first grayscale image is at normal brightness. In this case, the preset grayscale ratio threshold does not need to be adjusted and can be set to 0.75. Of course, those skilled in the art can flexibly set each threshold according to actual needs; this is not limited here.
[0087] Optionally, such as Figure 3 As shown, the information entropy algorithm in this invention includes:
[0088] Step S31: Convert the image to be detected into a second grayscale image, and convert the second grayscale image into a corresponding second grayscale histogram;
[0089] The description of step S31 can be referred to the description of step S21, and will not be repeated here.
[0090] Step S32: Sort the gray values corresponding to the second gray histogram according to their frequency of occurrence, and extract the K gray values with the highest frequency of occurrence as the second target gray values;
[0091] Step S33: Calculate the probability of each gray value of the second target based on the frequency of occurrence of each gray value of the second target and the sum of the frequencies of occurrence of each gray value of the second target;
[0092] Step S34: Calculate the information entropy of K second target grayscale values based on their frequencies. The formula for calculating the information entropy of the K second target grayscale values is as follows:
[0093]
[0094] in, The second target grayscale value, The second target grayscale value The probability of;
[0095] Step S35: Determine whether the image to be detected is occluded based on the preset information entropy threshold and the information entropy of the K second target gray values.
[0096] Optionally, the region analysis algorithm in this invention specifically includes:
[0097] Step S41: Convert the image to be detected into a third grayscale image, calculate the centroid O of the third grayscale image using the grayscale weighted centroid method, and then, with O as the center, calculate the centroid of the concentric rings with radius... Equal gradient increasing method partitioning A concentric ring region ,in, As the core ring, is the edge ring;
[0098] The method for converting the image to be detected into the third gray-scale image in step S41 can refer to the method for converting the image to be detected into the first gray-scale image in step S21, which will not be described herein. The gray-scale weighted barycenter method can use the gray-scale weighted barycenter method in the prior art, which will not be described herein.
[0099] Step S42: calculating the gradient amplitude of each pixel point in the concentric ring region using the Sobel operator , constructing a gradient-weighted third gray-scale histogram according to the gradient amplitude of each pixel point in the concentric ring region , and normalizing the third gray-scale histogram to obtain a probability distribution , and calculating the information entropy of the concentric ring region , wherein the calculation formula is: , ;
[0100] Step S43: if , and , determining that the image to be detected is not blocked;
[0101] Step S44: if and , determining that the image to be detected is locally blocked;
[0102] Step S45: if and , calculating the slope of the entropy change curve ; when , determining that the image to be detected is centrally concentrated overall blocked; when , determining that the image to be detected is uniformly dispersed overall blocked;
[0103] wherein is a normal texture entropy threshold; is a non-blocking tolerance; is a decay threshold; is an overall blocking tolerance; is a slope threshold; is the information entropy of the core ring; is the information entropy of the edge ring; is the radius of the core ring, , the value of which is 1 / 10 to 1 / 6 of the short side of the third gray-scale image; is the radius of the edge ring.
[0104] wherein , to adjust the coefficient, , to adjust the bit depth; , , ; , The skilled in the art can set flexibly according to actual needs, which are not limited here.
[0105] Optionally, the radius of the concentric ring wherein, , , respectively the width and height of the third gray image, the total number of ring domains, and .
[0106] Optionally, in step S42, according to the gradient amplitude of each pixel point in the concentric ring region , a third gray histogram weighted by gradient is constructed, including:
[0107] grouping the pixels in the concentric ring region by gray level;
[0108] According to the gradient amplitude of each pixel point in the concentric ring region , the weight value of the gray level is calculated by the calculation formula: , wherein, is the gray value of the pixel .
[0109] For example, if there are 3 pixels with gray value = 100 in the concentric ring region , and the gradient values are 1.2, 0.8, and 1.0 respectively, then the weight value W(100) of the gray level = 100 is 3.0.
[0110] It should be noted that steps S25, S26, S261, S262 and S41 to S45 are not shown in the figure.
[0111] Step S13: obtaining a to-be-detected image, and sequentially using multiple image occlusion detection algorithms to judge whether the to-be-detected image is occluded based on a detection sequence;
[0112] In addition, after obtaining the to-be-detected image, the method of the present application further comprises:
[0113] calculating a brightness factor of the to-be-detected image;
[0114] When the brightness factor is less than the low brightness factor threshold, the CLAHE contrast enhancement is performed on the to-be-detected image to enhance details.
[0115] CLAHE is a technique for image enhancement in computer vision and image processing, which avoids the noise enhancement problem that may be caused by traditional histogram equalization through local processing and contrast limitation. It divides the image into small blocks for histogram equalization, and smoothes the discontinuity between blocks through the cloning filling technique, while limiting the local contrast to preserve image details.
[0116] Step S14: When the adjacent previous image occlusion detection algorithm determines that the to-be-detected image is occluded, the judgment of the to-be-detected image by the next image occlusion detection algorithm is continued.
[0117] Step S15: When the adjacent previous image occlusion detection algorithm determines that the to-be-detected image is not occluded, the judgment of the to-be-detected image by the remaining image occlusion detection algorithm is terminated, and it is directly determined that the to-be-detected image is not occluded.
[0118] The image occlusion detection method provided by the application sorts multiple image occlusion detection algorithms, and cross- verifies the output results, thereby reducing the misjudgment rate and being able to cope with complex, dynamic and diverse occlusion scenes (such as night, motion blur and single color), and avoiding complete dependence on a certain feature to cause misjudgment.
[0119] The image occlusion detection method provided by the application sorts multiple image occlusion detection algorithms, and cross- verifies the output results, thereby reducing the misjudgment rate and being able to cope with complex, dynamic and diverse occlusion scenes (such as night, motion blur and single color), and avoiding complete dependence on a certain feature to cause misjudgment.
[0120] Based on the same inventive concept, the embodiments of the application also provide an image occlusion detection device for implementing the above-mentioned image occlusion detection method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more image occlusion detection device embodiments provided below can refer to the limitations of the image occlusion detection method in the foregoing, which will not be repeated here.
[0121] AsFigure 4 As shown, the present application provides an image occlusion detection device, which comprises a parameter configuration module 41, an algorithm sorting module 42 and an image detection module 43; wherein,
[0122] The parameter configuration module 41 is configured to obtain image occlusion detection algorithm calling parameters;
[0123] The algorithm sorting module 42 is connected with the parameter configuration module 41 and is configured to determine the detection order of multiple image occlusion detection algorithms according to the image occlusion detection algorithm calling parameters, wherein the image occlusion detection algorithms include Laplacian variance algorithm, TOP-K gray scale proportion algorithm, information entropy algorithm and region analysis algorithm;
[0124] The image detection module 43 is connected with the algorithm sorting module 42 and is configured to obtain a to-be-detected image, and sequentially uses multiple image occlusion detection algorithms to judge whether the to-be-detected image is occluded based on the detection order, wherein when the adjacent previous image occlusion detection algorithm judges that the to-be-detected image is occluded, the next image occlusion detection algorithm is executed to judge the to-be-detected image; when the adjacent previous image occlusion detection algorithm judges that the to-be-detected image is not occluded, the execution of the remaining image occlusion detection algorithms to judge the to-be-detected image is terminated, and it is directly determined that the to-be-detected image is not occluded.
[0125] Optionally, the TOP-K gray scale proportion algorithm comprises:
[0126] The to-be-detected image is converted into a first gray scale image, and the first gray scale image is converted into a corresponding first gray scale histogram;
[0127] The gray scale values corresponding to the first gray scale histogram are sorted according to the occurrence frequency, and the K gray scale values with the highest occurrence frequency are extracted as first target gray scale values;
[0128] The total number of pixels of the to-be-detected image is calculated, and the ratio of the sum of the occurrence frequencies of the first target gray scale values to the total number of pixels is taken as an occlusion proportion;
[0129] The occlusion proportion is compared with a preset gray scale proportion threshold value to determine whether the to-be-detected image is occluded.
[0130] Optionally, after the total number of pixels of the to-be-detected image is calculated, and the ratio of the sum of the occurrence frequencies of the first target gray scale values to the total number of pixels is taken as an occlusion proportion, the method further comprises:
[0131] The brightness factor of the first gray scale image is calculated;
[0132] The preset gray scale proportion threshold value is adjusted according to the brightness factor, a low brightness factor threshold value and a high brightness factor threshold value.
[0133] Optionally, the preset grayscale ratio threshold is adjusted based on the brightness factor, the low brightness factor threshold, and the high brightness factor threshold, including:
[0134] When the brightness factor is less than the low brightness factor threshold, the preset grayscale ratio threshold is adjusted to the first preset grayscale ratio threshold.
[0135] When the brightness factor is greater than the high brightness factor threshold, the preset grayscale ratio threshold is adjusted to the second preset grayscale ratio threshold.
[0136] Among them, the first preset grayscale ratio threshold is less than the second preset grayscale ratio threshold.
[0137] Optionally, the information entropy algorithm includes:
[0138] The image to be detected is converted into a second grayscale image, and the second grayscale image is converted into a corresponding second grayscale histogram;
[0139] Sort the gray values corresponding to the second gray histogram according to their frequency of occurrence, and extract the K gray values with the highest frequency of occurrence as the second target gray values.
[0140] Calculate the probability of each gray value of the second target based on the frequency of occurrence of each gray value of the second target and the sum of the frequencies of occurrence of each gray value of the second target;
[0141] Based on the frequency of the grayscale values of the second target, calculate the information entropy of K grayscale values of the second target. The formula for calculating the information entropy of the K grayscale values of the second target is as follows:
[0142]
[0143] in, The second target grayscale value, The second target grayscale value The probability of;
[0144] Based on the preset information entropy threshold and the information entropy of K second target gray values, it is determined whether the image to be detected is occluded.
[0145] Optionally, the region analysis algorithm includes:
[0146] The image to be detected is converted into a third grayscale image. The centroid O of the third grayscale image is calculated using the grayscale weighted centroid method. Then, with O as the center, concentric rings are drawn with radius... Equal gradient increasing method partitioning A concentric ring region ,in, As the core ring, For edge ring;
[0147] For each concentric ring region Perform: the Sobel operator is used to calculate the gradient amplitude of each pixel point in the concentric ring region ; according to the gradient amplitude of each pixel point in the concentric ring region , a third gradient weighted gray histogram is constructed; the third gray histogram is normalized to obtain a probability distribution , the information entropy of the concentric ring region is calculated, wherein the calculation formula is: , ;
[0148] If , and , it is determined that the image to be detected is not blocked;
[0149] If and , it is determined that the image to be detected is locally blocked;
[0150] If and , the slope of the entropy change curve is calculated ; when , it is determined that the image to be detected is centrally concentrated overall blocked; when , it is determined that the image to be detected is uniformly dispersed overall blocked;
[0151] wherein is a normal texture entropy threshold; is a non-blocking tolerance; is a decay threshold; is an overall blocking tolerance; is a slope threshold; is the information entropy of the core ring; is the information entropy of the edge ring; is the radius of the core ring, the value of which is 1 / 10 to 1 / 6 of the short side of the third gray image; is the radius of the edge ring.
[0152] Optionally, the concentric ring radius wherein , , respectively, the width and height of the third gray image, is the total number of ring domains, and .
[0153] Optionally, according to the gradient amplitude of each pixel point in the concentric ring region , a third gradient weighted gray histogram is constructed, including:
[0154] the concentric ring region Pixels within the inner region are grouped by gray scale level;
[0155] According to the gradient amplitude of each pixel point in the concentric ring region , the gray scale weight value is calculated by the calculation formula: , wherein, is the gray value of the pixel .
[0156] Optionally, the image detection module 43 is further configured to: calculate a brightness factor of the to-be-detected image; and perform CLAHE contrast enhancement to improve details on the to-be-detected image when the brightness factor is less than a low brightness factor threshold.
[0157] The image occlusion detection device of the present application, the parameter configuration module obtains the image occlusion detection algorithm calling parameter; the algorithm sorting module determines the detection order of a plurality of image occlusion detection algorithms according to the image occlusion detection algorithm calling parameter, wherein the image occlusion detection algorithm includes Laplacian variance algorithm, TOP-K gray scale proportion algorithm, information entropy algorithm and region analysis algorithm; the image detection module obtains the to-be-detected image, and based on the detection order, a plurality of image occlusion detection algorithms are used in turn to judge whether the to-be-detected image is occluded, wherein when the adjacent previous image occlusion detection algorithm judges that the to-be-detected image is occluded, the next image occlusion detection algorithm is continued to execute to judge the to-be-detected image; when the adjacent previous image occlusion detection algorithm judges that the to-be-detected image is not occluded, the judgment of the remaining image occlusion detection algorithm to the to-be-detected image is terminated, and it is directly determined that the to-be-detected image is not occluded. The device of the present application can flexibly adjust the detection order of the detection algorithm to quickly and accurately detect whether the to-be-detected image is occluded.
[0158] It should be noted that the plurality of in the present application includes two and more.
[0159] It should be understood that, although each step in the flowchart involved in each embodiment as described above is displayed in sequence according to the arrow indication, these steps are not necessarily executed in sequence according to the arrow indication. Unless explicitly stated herein, the execution of these steps has no strict order limitation, and these steps can be executed in other orders. Moreover, at least part of the steps in the flowchart involved in each embodiment as described above can include multiple steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or steps or stages in other steps.
[0160] Each of the modules in each of the devices in the present application can be realized by software, hardware and combination thereof in whole or in part. The modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory in the computer device in software form, so as to be called and executed by the processor to perform the operations corresponding to each of the modules.
[0161] In one embodiment, a computer device is provided, which can be a server, and an internal structure diagram thereof can be as shown in Figure 5 The computer device includes a processor, a memory and a network interface connected through a system bus. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The database of the computer device is configured to store data required for or generated by executing the image occlusion detection method. The network interface of the computer device is configured to communicate with an external terminal through a network connection. The computer program is executed by the processor to implement an image occlusion detection method.
[0162] In one embodiment, a computer device is provided, which can be a terminal, and an internal structure diagram thereof can be as shown in Figure 5 The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is configured to communicate with an external terminal in a wired or wireless manner. The wireless manner can be achieved by WIFI, mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by the processor to implement an image occlusion detection method. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the computer device, or an external keyboard, touchpad or mouse, etc.
[0163] Those skilled in the art can understand that Figure 5 The structures shown in the above embodiments are only block diagrams of part of the structures related to the present application, and do not constitute a limitation on the computer device to which the present application is applied. The specific computer device can include more or fewer components than those shown in the figures, or combine certain components, or have a different arrangement of components.
[0164] In an embodiment, a computer device is provided, comprising a memory and a processor, the memory has stored therein a computer program, the processor implements the steps in the above method embodiments when executing the computer program.
[0165] In an embodiment, a computer readable storage medium is provided, having stored thereon a computer program, the computer program is executed by a processor to implement the steps in the above method embodiments.
[0166] In an embodiment, a computer program product is provided, comprising a computer program, the computer program is executed by a processor to implement the steps in the above method embodiments.
[0167] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties.
[0168] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, database or other medium used in the embodiments provided by the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided by the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided by the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.
[0169] Any combination of the technical features of the above embodiments can be made. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist, it should be considered as the scope of the present application.
[0170] The above embodiments only express several embodiments of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are within the scope of protection of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. An image occlusion detection method, characterized in that, The method includes: Obtain the parameters for the image occlusion detection algorithm; Based on the parameters called by the image occlusion detection algorithm, the detection order of various image occlusion detection algorithms is determined. Among them, the image occlusion detection algorithms include Laplacian variance algorithm, TOP-K gray-scale ratio algorithm, information entropy algorithm and region analysis algorithm. The image to be detected is acquired, and based on the detection order, multiple image occlusion detection algorithms are used sequentially to determine whether the image to be detected is occluded. When the preceding image occlusion detection algorithm determines that the image to be detected is occluded, the next image occlusion detection algorithm is executed to determine the image to be detected. When the preceding image occlusion detection algorithm determines that the image to be detected is not occluded, the remaining image occlusion detection algorithms are terminated from judging the image to be detected, and it is directly determined that the image to be detected is not occluded. The region analysis algorithm includes: The image to be detected is converted into a third grayscale image. The centroid O of the third grayscale image is calculated using the grayscale weighted centroid method. Then, with O as the center, concentric rings are drawn with radius... Equal gradient increasing method partitioning A concentric ring region ,in, As the core ring, For edge ring; For each concentric ring region Execution: The Sobel operator is used to calculate the gradient magnitude of each pixel within the concentric ring region. Based on the gradient magnitude of each pixel within the concentric ring region Construct a gradient-weighted third gray-level histogram; normalize the third gray-level histogram to obtain the probability distribution. Calculate the concentric ring region The information entropy, where the calculation formula is: , ; like , and This confirms that the image to be detected is not occluded. like and This determines that the image to be detected is partially occluded; like and Calculate the slope of the entropy change curve ;when When, it is determined that the image to be detected is centrally and uniformly occluded; when At that time, it was determined that the image to be detected was uniformly diffusely occluded. in, The normal texture entropy threshold; Tolerance for no obstruction; The attenuation threshold; To allow for overall occlusion tolerance; Slope threshold; The information entropy of the core ring; The information entropy of the edge ring; The radius of the core ring, The value of is 1 / 10 to 1 / 6 of the shorter side of the third grayscale image; Let be the radius of the edge ring.
2. The method according to claim 1, characterized in that, The TOP-K grayscale ratio algorithm includes: The image to be detected is converted into a first grayscale image, and the first grayscale image is converted into a corresponding first grayscale histogram; Sort the gray values corresponding to the first gray histogram according to their frequency of occurrence, and extract the K gray values with the highest frequency of occurrence as the first target gray values. Calculate the total number of pixels in the image to be detected, and use the ratio of the sum of the frequencies of each first target gray value to the total number of pixels as the occlusion ratio; The occlusion percentage is compared with a preset grayscale percentage threshold to determine whether the image to be detected is occluded.
3. The method according to claim 2, characterized in that, After calculating the total number of pixels in the image to be detected and using the ratio of the sum of the frequencies of occurrence of each first target grayscale value to the total number of pixels as the occlusion ratio, the method further includes: Calculate the brightness factor of the first grayscale image; Adjust the preset grayscale ratio threshold based on the brightness factor, low brightness factor threshold, and high brightness factor threshold.
4. The method according to claim 3, characterized in that, The step of adjusting the preset grayscale ratio threshold based on the brightness factor, low brightness factor threshold, and high brightness factor threshold includes: When the brightness factor is less than the low brightness factor threshold, the preset grayscale ratio threshold is adjusted to the first preset grayscale ratio threshold. When the brightness factor is greater than the high brightness factor threshold, the preset grayscale ratio threshold is adjusted to the second preset grayscale ratio threshold. The first preset grayscale percentage threshold is less than the second preset grayscale percentage threshold.
5. The method according to claim 1, characterized in that, The information entropy algorithm includes: The image to be detected is converted into a second grayscale image, and the second grayscale image is converted into a corresponding second grayscale histogram; Sort the gray values corresponding to the second gray histogram according to their frequency of occurrence, and extract the K gray values with the highest frequency of occurrence as the second target gray values. Calculate the probability of each gray value of the second target based on the frequency of occurrence of each gray value of the second target and the sum of the frequencies of occurrence of each gray value of the second target; Based on the frequency of the grayscale values of the second target, calculate the information entropy of K grayscale values of the second target. The formula for calculating the information entropy of the K grayscale values of the second target is as follows: ,in, The second target grayscale value, The second target grayscale value The probability of; Based on the preset information entropy threshold and the information entropy of K second target gray values, it is determined whether the image to be detected is occluded.
6. The method according to claim 1, characterized in that, radius of concentric rings ,in, , , These are the width and height of the third grayscale image, respectively. The total number of ring domains, and .
7. The method according to claim 1, characterized in that, The gradient magnitude of each pixel within the concentric ring region is used as a basis. Construct a gradient-weighted third gray-level histogram, including: Concentric ring region Pixels within the range are grouped by gray level; Based on the gradient magnitude of each pixel within the concentric ring region The calculation formula is as follows: The gray levels are calculated. The weight values, where, For pixels The grayscale value.
8. The method according to claim 1, characterized in that, After acquiring the image to be detected, the method further includes: Calculate the brightness factor of the image to be detected; When the brightness factor is less than the low brightness factor threshold, CLAHE contrast enhancement is performed on the image to be detected to improve details.
9. An image occlusion detection device, characterized in that, The device includes: a parameter configuration module, an algorithm sorting module, and an image detection module; wherein... The parameter configuration module is used to obtain the calling parameters of the image occlusion detection algorithm; The algorithm sorting module is connected to the parameter configuration module. It is used to call parameters according to the image occlusion detection algorithm to determine the detection order of various image occlusion detection algorithms. Among them, the image occlusion detection algorithms include Laplacian variance algorithm, TOP-K gray-scale ratio algorithm, information entropy algorithm and region analysis algorithm. The image detection module is connected to the algorithm sorting module. It is used to acquire the image to be detected and, based on the detection order, sequentially uses multiple image occlusion detection algorithms to determine whether the image to be detected is occluded. Specifically, if the preceding image occlusion detection algorithm determines that the image to be detected is occluded, the next image occlusion detection algorithm is executed to judge the image to be detected; if the preceding image occlusion detection algorithm determines that the image to be detected is not occluded, the execution of the remaining image occlusion detection algorithms is terminated, and the image to be detected is directly determined to be not occluded. The region analysis algorithm includes: The image to be detected is converted into a third grayscale image. The centroid O of the third grayscale image is calculated using the grayscale weighted centroid method. Then, with O as the center, concentric rings are drawn with radius... Equal gradient increasing method partitioning A concentric ring region ,in, As the core ring, For edge ring; For each concentric ring region Execution: The Sobel operator is used to calculate the gradient magnitude of each pixel within the concentric ring region. Based on the gradient magnitude of each pixel within the concentric ring region Construct a gradient-weighted third gray-level histogram; normalize the third gray-level histogram to obtain the probability distribution. Calculate the concentric ring region The information entropy, where the calculation formula is: , ; like , and This confirms that the image to be detected is not occluded. like and This determines that the image to be detected is partially occluded; like and Calculate the slope of the entropy change curve ;when When, it is determined that the image to be detected is centrally and uniformly occluded; when At that time, it was determined that the image to be detected was uniformly diffusely occluded. in, The normal texture entropy threshold; Tolerance for no obstruction; The attenuation threshold; To allow for overall occlusion tolerance; Slope threshold; The information entropy of the core ring; The information entropy of the edge ring; The radius of the core ring, The value of is 1 / 10 to 1 / 6 of the shorter side of the third grayscale image; Let be the radius of the edge ring.
Citation Information
Patent Citations
Cheek occlusion detection method and device and electronic equipment
CN112651322A
Defect detection method and device with AOI and AI
CN112763506A