Image detection method and device, and computer storage medium
Through the training process, the detection threshold is determined and the image blur is judged using gradient information. Adaptive binarization and gradient calculation are used to solve the problems of high computational complexity and high-frequency features in the prior art, and fast and accurate image blur detection is achieved.
Patent Information
- Application Number
- CN202410041538.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-10
- Publication Date
- 2025-07-11
AI Technical Summary
The existing image blur detection algorithms are difficult to balance between computational complexity and accuracy. The frequency domain method has high computational complexity and is not suitable for real-time detection, while the air domain method ignores high-frequency features, resulting in low accuracy of blur detection.
The detection threshold is determined through the training process, the image blur is judged using gradient information, and the image processing is simplified by adaptive binarization and gradient calculation. The fuzzy detection score is calculated by combining the weight matrix and the Gaussian kernel to process local overexposure or overdark problems.
Fast and accurate image blur detection is achieved, reducing the impact of overexposure or overdark points on detection results, and improving the accuracy and efficiency of detection.
Smart Images

Figure CN120298288A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image analysis technology, and in particular to an image detection method and an image detection device for detecting whether an image is blurred, as well as a computer storage medium. Background Art
[0002] Existing image blur detection algorithms are generally divided into two categories: spatial domain and frequency domain.
[0003] In the frequency domain method, based on the characteristics that the high-frequency information of a blurred image is less and the low-frequency information is more in the frequency domain, the Fourier transform, discrete cosine transform, or discrete wavelet transform of the image is mostly used, with high computational complexity and long computational time, which is not suitable for real-time detection.
[0004] In the spatial domain method, a neural network-based method is usually adopted. In order to balance accuracy and computational complexity, a convolutional neural network usually adopts downsampling for image classification or blur degree value regression, which reduces the computational complexity while causing loss of detail information. This is beneficial for extracting low-frequency features (such as the coarse-grained contour of an object, semantic information, etc.) but ignores high-frequency features (such as sharpness changes, edge gradients, etc.). The blur detection task needs to use high-frequency feature information to distinguish clear from blurred. Directly inputting the image to be detected into a convolutional neural network for feature extraction results in low accuracy of blur judgment.
[0005] Therefore, a detection method for detecting whether an image is blurred is needed to at least partially solve the above problems. Summary of the Invention
[0006] A series of simplified concepts are introduced in the Summary of the Invention section, which will be further described in detail in the Detailed Implementation section. The Summary of the Invention section of the present application does not mean to attempt to define the key features and essential technical features of the claimed technical solution, nor does it mean to attempt to determine the protection scope of the claimed technical solution.
[0007] To at least partially solve the above problems, a first aspect of the present application provides an image detection method for detecting whether an image is blurred, including:
[0008] A training session for determining a detection threshold, and the training session includes:
[0009] Step S100: Set an initial detection threshold, and then execute step S200.
[0010] Step S200: Randomly select m images, calculate the blur detection score of each image, and manually determine whether each image is a blurred image or a clear image, where m is a positive integer, and then execute step S300.
[0011] Step S300: Determine the maximum value smax and the minimum value smin of all the fuzzy detection scores. Determine the corrected detection threshold within the range [smin, smax]. Mark the images with fuzzy detection scores less than or equal to the corrected detection threshold as fuzzy images, and mark the images with fuzzy detection scores greater than the corrected detection threshold as clear images, where the corrected detection threshold makes the marking results of all images have the highest consistency with the manual judgment results. Then perform Step S400.
[0012] Step S400: When the absolute value of the difference between the corrected detection threshold and the initial detection threshold is less than or equal to the preset error, set the value of the detection threshold to the corrected detection threshold, and then end the training session; when the absolute value of the difference between the corrected detection threshold and the initial detection threshold is greater than the preset error, set the value of the initial detection threshold to the corrected detection threshold, and then perform Step S500.
[0013] Step S500: Randomly select a new image, calculate the fuzzy detection score of the new image, and manually judge whether the new image is a fuzzy image or a clear image. Then perform Step S300.
[0014] Detection session, used to detect whether an image is fuzzy. The detection session includes:
[0015] Calculate the fuzzy detection score of the image to be detected. When the fuzzy detection score of the image to be detected is greater than the detection threshold, judge that the image to be detected is a clear image; when the fuzzy detection score of the image to be detected is less than or equal to the detection threshold, judge that the image to be detected is a fuzzy image.
[0016] Since this application determines whether an image is fuzzy or clear based on the fuzzy detection score of the image, the detection threshold is also trained through the fuzzy detection score. The detection threshold th is obtained by training with a random image library, making the detection result more accurate.
[0017] Optionally, the calculation of the fuzzy detection score for each image includes:
[0018] Step S210: Convert the image into a grayscale image.
[0019] Step S220: Perform at least binarization processing on the grayscale image to obtain an adjusted grayscale image, where the binarization processing includes: when the grayscale value of a pixel in the grayscale image is greater than or equal to the grayscale threshold, make the grayscale value of the pixel the maximum grayscale value, and when the grayscale value of the pixel is less than the grayscale threshold, make the grayscale value of the pixel the minimum grayscale value.
[0020] Step S230: Calculate a gradient image based on the adjusted grayscale image;
[0021] Step S240: Calculate the blur detection score based on the gradient image.
[0022] According to the present application, judging whether an image is blurred based on gradient information is simple and fast to calculate. At the same time, the influence of overexposed or underexposed points on the gradient information of the image is reduced through grayscale binarization processing, making the detection result more accurate.
[0023] Optionally, the detection method further includes: when performing the binarization processing, determining the grayscale threshold of a certain pixel according to the grayscale value of the certain pixel and the grayscale values of its surrounding pixels.
[0024] According to the present application, instead of using a unified grayscale threshold for binarization processing, adaptive binarization processing is adopted, so that better results can still be obtained in the case of local overexposure or underexposure.
[0025] Optionally, determining the grayscale threshold of a certain pixel according to the grayscale value of the certain pixel and the grayscale values of its surrounding pixels includes:
[0026] Cropping out an image matrix A of size p×p with the certain pixel as the central pixel from the grayscale image, where p is an odd number,
[0027] Setting a weight matrix W of size p×p, and the value of the element in the x-th row and y-th column of the matrix W is denoted as w(x, y), where x and y are positive integers, 1≤x≤p, 1≤y≤p,
[0028] The grayscale threshold of the certain pixel is the difference between the result of the convolution of the matrix A and the matrix W and a preset threshold constant.
[0029] Furthermore, the value of the central element at the position ((p + 1) / 2, (p + 1) / 2) in the weight matrix W is greater than the values of other elements.
[0030] Furthermore,
[0031] In the weight matrix W, the closer an element is to the central element, the greater its value; and / or
[0032] In the weight matrix W, the values of the elements at equal distances from the central element are equal.
[0033] According to the present application, the value of the central element in the weight matrix W is the largest among other elements, the values of the elements farther away from the central element are smaller, and the values of the elements at the same distance from the central element are the same. Therefore, the gray threshold of the pixels in the grayscale image is greatly affected by the original gray value of the pixels, and the influence of local overexposure or underexposure on the detection result can be reduced.
[0034] Optionally, setting the weight matrix W of size p×p includes:
[0035] Setting a matrix C of size p×p, and the value of the element in the x-th row and y-th column of the matrix C is denoted as c(x, y), where x and y are positive integers, 1≤x≤p, 1≤y≤p, where σ is a constant,
[0036] The value w(x, y) of the element in the x-th row and y-th column of the weight matrix W is calculated according to the following formula:
[0037]
[0038] According to the present application, the weight matrix W is calculated based on the two-dimensional discrete Gaussian function.
[0039] Optionally, the detection method further includes calculating the constant σ according to the value of p.
[0040] The constant σ is the standard deviation of the Gaussian kernel. The larger σ is, the more dispersed the weight distribution of the Gaussian kernel is, and the values of the elements of the generated weight matrix are close, which is more similar to the mean template. According to the present application, determining the value of σ according to the size of the kernel can ensure that the Gaussian kernel can take into account all pixels that may significantly affect the result value.
[0041] Optionally, obtaining the gradient image from the adjusted grayscale image includes:
[0042] Convolving the horizontal operator matrix with the adjusted grayscale image to obtain a horizontal gradient image matrix, and convolving the vertical operator matrix with the adjusted grayscale image to obtain a vertical gradient image matrix,
[0043] Taking the absolute value of each pixel value in the horizontal gradient image matrix to obtain a first gradient image matrix Hx; taking the absolute value of each pixel value in the vertical gradient image matrix to obtain a second gradient image matrix Hy,
[0044] Calculating the gradient image H according to the following formula:
[0045] H = (Hx + Hy) / 2.
[0046] According to the present application, it is detected whether the image is blurred based on the edge gradient information. Based on the premise that the sensitivity of the clear region to the gradient is greater than that of the blurred region, it can effectively determine whether the image is blurred.
[0047] Optionally, the horizontal operator matrix and / or the vertical operator matrix is configured as a Sobel operator.
[0048] According to the present application, the Sobel operator not only produces a good detection effect, but also has a smoothing and suppressing effect on noise.
[0049] Optionally, calculating the blur detection score based on the gradient image includes:
[0050] The blur detection score is the standard deviation of the values of all pixels in the gradient image.
[0051] According to the present application, the method for calculating the blur detection score is simple.
[0052] Optionally, converting the image into a grayscale image includes:
[0053] When the image is a color image, the value of each pixel point of the image is the grayscale value gray, where the grayscale value gray is calculated according to the following formula:
[0054] gray = c1 × R + c2 × G + c3 × B,
[0055] where c1, c2, and c3 are constants, c1 + c2 + c3 = 1, R is the luminance value of the red channel of the pixel point, G is the luminance value of the green channel of the pixel point, and B is the luminance value of the blue channel of the pixel point.
[0056] According to the present application, the method for converting a color image into a grayscale image is simple.
[0057] Optionally,
[0058] Step S220 further includes: performing binarization processing on the grayscale image to obtain a first grayscale image, adjusting the grayscale of the binarized first grayscale image to obtain a second grayscale image, and using the second grayscale image as the adjusted grayscale image.
[0059] Furthermore, adjusting the grayscale of the binarized first grayscale image to obtain a second grayscale image includes:
[0060] Cropping an image matrix D with a size of q × q containing a certain pixel from the first grayscale image, where q is an odd number,
[0061] Statistical the grayscale distribution of the image matrix D to obtain a first grayscale distribution statistical result,
[0062] Adjust the first grayscale distribution statistical result to obtain a second grayscale distribution statistical result,
[0063] Calculate the ratio of the statistical value of each gray value in the second gray-level distribution statistical result to q 2 where the statistical value of gray value i in the second gray-level distribution statistical result is denoted as s(i), and the ratio of s(i) to q 2 is denoted as r(i).
[0064] Set the function where v is the minimum gray value, and the value range of gray value i is from the minimum gray value to the maximum gray value.
[0065] Calculate the gray mapping value of a certain pixel for the image matrix D according to the following formula:
[0066] map = u × [cdf(g1) - cdfmin] ÷ (1 - cdfmin),
[0067] where map is the gray mapping value of a certain pixel for the image matrix D, u is the maximum gray value, g1 is the gray value of the certain pixel in the first gray-scale image, and cdfmin is the minimum value of the function cdf(i).
[0068] According to the present application, performing local histogram equalization adjustment on the gray-scale image, redistributing the brightness to change the image contrast, can further eliminate the influence of overexposed or underexposed points on the gradient information detection.
[0069] Optionally, adjusting the first gray-level distribution statistical result to obtain the second gray-level distribution statistical result includes:
[0070] Determine the gray values in the first gray-level distribution statistical result whose statistical values are greater than the preset quantity threshold cl, denoted as the gray values to be limited.
[0071] Calculate the difference in the quantity to be limited obtained by subtracting the preset quantity threshold cl from the statistical value of each gray value to be limited.
[0072] Calculate the sum te of all the differences in the quantity to be limited.
[0073] Calculate the integer part in of the quotient obtained by dividing te by the total number of gray levels.
[0074] Calculate the difference up between cl and in.
[0075] Adjust the statistical values of the gray values in the first gray-level distribution statistical result that are greater than or equal to up to the preset quantity threshold cl, and add in to the statistical values of the gray values in the first gray-level distribution statistical result that are less than up, so as to obtain the second gray-level distribution statistical result.
[0076] According to the present application, a method of restricting contrast adaptive local histogram equalization adjustment is adopted. On the basis of ensuring that the total number of gray values (which can also be understood as the area of the gray histogram) is constant, the locally overly concentrated gray values are reduced (restricted), and the gray values with a small occurrence probability are increased, so as to reduce the influence of local overexposure or underexposure on the detection of gradient information.
[0077] Optionally,
[0078] At least one of the image matrices D satisfies the first condition, and the first condition is: the position of the element in the first row and first column of the image matrix D in the first gray image is (1 + k·q, 1 + l·q), where k and l are natural numbers; and
[0079] The gray value of a certain pixel in the second gray image in the image matrix D that satisfies the first condition is the gray mapping value of the certain pixel for the image matrix D.
[0080] Furthermore,
[0081] All the image matrices D satisfy the first condition: and
[0082] The gray value of a certain pixel in each of the image matrices D in the second gray image is the gray mapping value of the certain pixel for the image matrix D.
[0083] According to the present application, the gray mapping value of a pixel in the first gray image for the image matrix D can be directly used as the gray value of the pixel in the second gray image.
[0084] Optionally,
[0085] The pixels of the first gray image include edge region pixels and middle region pixels. Among them, the edge region pixels are the pixels in the leftmost q columns, the rightmost q columns, the uppermost q rows, and the lowermost q rows of the first gray image, and the middle region pixels are the pixels of the first gray image except the edge region pixels.
[0086] Among them, the image matrix D intercepted from the edge region pixels satisfies the first condition; and
[0087] The gray value of a certain edge region pixel PI11 in the image matrix D intercepted from the edge region pixels in the second gray image is the gray mapping value of the edge region pixel PI11 for the image matrix D.
[0088] Furthermore, the gray value of a certain pixel PI12 in the middle region pixels in the second gray image is determined according to the following method:
[0089] Four image matrices D with a size of q×q containing the intermediate region pixel PI12 are cropped from the first grayscale image, and the grayscale mapping values of the intermediate region pixel PI12 for the four image matrices D are calculated respectively. The result of bilinear interpolation of the four grayscale mapping values is used as the grayscale of the intermediate region pixel PI12 in the second grayscale image.
[0090] According to the present application, the information contained in the middle part of the image is relatively large, and there are other pixels around each pixel. Eliminating the blocking effect on the middle part can make the detection result more accurate.
[0091] Optionally, the positions of the intermediate region pixel PI12 in the four image matrices D differ from each other by one row and / or one column.
[0092] Furthermore,
[0093] The position of the intermediate region pixel PI12 in the first image matrix D is ((q + 1) / 2, (q + 1) / 2),
[0094] The position of the intermediate region pixel PI12 in the second image matrix D is ((q + 1) / 2, (q + 1) / 2 - 1),
[0095] The position of the intermediate region pixel PI12 in the third image matrix D is ((q + 1) / 2 - 1, (q + 1) / 2),
[0096] The position of the intermediate region pixel PI12 in the fourth image matrix D is ((q + 1) / 2 - 1, (q + 1) / 2 - 1).
[0097] According to the present application, when eliminating the blocking effect, the selection method of the image block is simple.
[0098] The second aspect of the present application provides an image detection device for detecting whether an image is blurred, including a memory, a processor, and a computer program stored on the memory and running on the processor. When the processor executes the computer program, it performs the steps of the image detection method according to any one of the first aspect.
[0099] The third aspect of the present application is a computer storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the image detection method according to any one of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0100] The following drawings of the present application are hereby incorporated as part of the present application for understanding the present application. The drawings herein show representative embodiments of the present application for explaining the principles of the present application, rather than limiting the present application.
[0101] In the accompanying drawings:
[0102] Figure 1 is a schematic flowchart of a detection method for detecting whether an image is blurred according to a specific embodiment of the present application;
[0103] Figure 2 is Figure 1 a schematic flowchart of the step of calculating the blur detection score in the detection method shown in;
[0104] Figure 3 is Figure 2 a specific step flow example of step S220 shown in;
[0105] Figure 4 is a schematic diagram of the partitioning of the first grayscale image. Specific Embodiments
[0106] In the following description, numerous specific details are given to provide a more thorough understanding of the present application. However, it is obvious to those skilled in the art that the present application can be implemented without one or more of these details. In other instances, in order to avoid confusion with the present application, some well-known technical features are not described.
[0107] For a thorough understanding of the present application, a detailed description will be presented in the following. It should be understood that these embodiments are provided to make the disclosure of the present application thorough and complete, and to fully convey the concept of these exemplary embodiments to those of ordinary skill in the art. Obviously, the implementation of the embodiments of the present application is not limited to the specific details familiar to those skilled in the art. The preferred embodiments of the present application are described in detail below. However, in addition to these detailed descriptions, the present application may have other embodiments.
[0108] The ordinal numbers such as "first" and "second" cited in the present application are merely identifiers and do not have any other meanings, such as a specific order, etc. Moreover, for example, the term "first component" does not imply the existence of a "second component" by itself, and the term "second component" does not imply the existence of a "first component" by itself. The use of the words "first", "second", and "third" does not represent any order, and these words can be interpreted as names.
[0109] It should be noted that the terms "upper", "lower", "front", "rear", "left", "right", "inner", "outer", and similar expressions used in the present application are only for the purpose of illustration and are not restrictive.
[0110] In this text, terms such as "equal" and "identical" are not strict mathematical and / or geometric limitations, and also include errors that can be understood by those skilled in the art and are allowed in manufacturing or use, etc.
[0111] Unless otherwise specified, the numerical ranges in this text not only include the entire range within its two endpoints, but also include several sub-ranges contained therein.
[0112] This application provides an image detection method and an image detection device for detecting whether an image is blurred, as well as a computer storage medium storing a program of the image detection method. In this application, an image refers to a single-frame two-dimensional picture.
[0113] Now, exemplary embodiments according to this application will be described in more detail with reference to the accompanying drawings.
[0114] As Figure 1 shown, in a specific embodiment, the detection method for detecting whether an image is blurred according to this application includes a training step S10 and a detection step S20. In the training step S10, a detection threshold th is determined through a randomly formed training library (that is, several randomly selected images). The detection step S20 is the process of real-time detection. For each image to be detected, its blur detection score s is calculated, and then the blur detection score s is compared with the detection threshold th to determine whether the image is clear or blurred. For example, when the blur detection score s of the image to be detected is greater than the detection threshold th, it is determined that the image to be detected is a clear image; when the blur detection score s of the image to be detected is less than or equal to the detection threshold th, it is determined that the image to be detected is a blurred image.
[0115] Specifically, the training step S10 may include the following steps S100, S200, S300, S400, and S500.
[0116] Step S100: Set an initial detection threshold th0, and then execute step S200.
[0117] The initial detection threshold th0 can be understood as the initial value of the detection threshold th. This initial value can be randomly generated or set artificially, and it is a rough estimate of the detection threshold th.
[0118] Step S200: Randomly select m images, calculate the blur detection score s of each image, and manually determine whether each image is a blurred image or a clear image, where m is a positive integer, and then execute step S300.
[0119] In this step, the m randomly selected images are the training library images, or the training images.
[0120] Step S300: Determine the maximum value smax and the minimum value smin of the blur detection scores s of all training images. Determine the corrected detection threshold th1 within the range [smin, smax]. Mark the images with blur detection scores s less than or equal to the corrected detection threshold th1 as blurred images, and mark the images with blur detection scores s greater than the corrected detection threshold th1 as clear images, where the corrected detection threshold makes the marking results of all images have the highest degree of coincidence with the manual judgment results. Then, execute Step S400.
[0121] Since this application determines whether an image is blurred or clear based on the blur detection score of the image, the detection threshold is also trained through the blur detection score. In this step, taking the manual judgment result as the standard, make the machine marking result as close to the standard as possible, so that the corrected detection threshold th1 can be closer to the detection threshold th. For example, the initial value of the correction variable th2 can be set to smin, and then the variable th2 is gradually increased until it reaches smax. Use the variable th2 as the detection threshold. At each variable th2 from smin to smax, the machine marks the blur detection results of each training image, and calculates the accuracy rate of the machine marking results at each variable th2. That is, mark the images with blur detection scores st less than or equal to the variable th2 as blurred images, and mark the images with blur detection scores st greater than the variable th2 as clear images, where if the machine marking result is the same as the manual judgment result, it is a correct machine marking, and if the machine marking result is different from the manual judgment result, it is an incorrect machine marking. Thus, the accuracy rate of the machine marking results at each variable th2 can be obtained, and the variable th2 with the highest accuracy rate is used as the corrected detection threshold th1.
[0122] Step S400: When the absolute value of the difference between the corrected detection threshold th1 and the initial detection threshold th0 is less than or equal to the preset error e, set the value of the detection threshold th to the corrected detection threshold th1, and then end the training session; when the absolute value of the difference between the corrected detection threshold th1 and the initial detection threshold th0 is greater than the preset error e, set the value of the initial detection threshold th0 to the corrected detection threshold th1, and then execute Step S500.
[0123] In this step, since the corrected detection threshold th1 is obtained based on the training library images and is more reliable than the estimated initial detection threshold th0, before the training converges, the initial detection threshold th0 is replaced with the corrected detection threshold th1. When the training converges, that is, when the value of the corrected detection threshold th1 fluctuates no more than the preset error e and tends to be stable, the stable corrected detection threshold th1 is used as the detection threshold th.
[0124] Step S500: Randomly select a new image, calculate the blur detection score st of the new image, and manually determine whether the new image is a blurred image or a clear image, and then execute step S300.
[0125] In this step, before the training converges, continuously increase the number of training images and continuously update and correct the detection threshold th1 until convergence is achieved.
[0126] After determining the detection threshold th in the training session S10, real-time detection can be implemented, that is, the machine detects whether the image is blurred. The detection session S20 includes:
[0127] Step S600: Calculate the blur detection score s of the image to be detected, and then execute step S700;
[0128] Step S700: When the blur detection score s of the image to be detected is greater than the detection threshold th, determine that the image to be detected is a clear image; when the blur detection score s of the image to be detected is less than or equal to the detection threshold th, determine that the image to be detected is a blurred image.
[0129] According to the present application, the detection threshold th is obtained by training with a random image library, making the detection result more accurate.
[0130] As Figure 2 shown, the blur detection score s of the image can be calculated through the following steps:
[0131] Step S210: Convert the image into a grayscale image GI0;
[0132] Step S220: At least binarize the grayscale image GI0 to obtain an adjusted grayscale image GIA;
[0133] Step S230: Calculate the gradient image GRI according to the adjusted grayscale image GIA;
[0134] Step S240: Calculate the blur detection score s according to the gradient image GRI.
[0135] The present application determines whether the image is blurred based on gradient information, with simple and fast calculation. At the same time, through grayscale binarization processing, the influence of overexposed or underexposed points on the gradient information of the image is reduced, making the detection result more accurate.
[0136] In step S210, if the original image is a grayscale image (such as an infrared image), it can be directly applied as the grayscale image GI0; if the original image is a color image, then for example, according to the following formula (1), change the value of each pixel point in the color image to a grayscale value gray to obtain the grayscale image GI0,
[0137] gray = c1×R + c2×G + c3×B (1)
[0138] In formula (1), c1, c2, and c3 are constants, c1 + c2 + c3 = 1, R is the luminance value of the red channel of the pixel, G is the luminance value of the green channel of the pixel, and B is the luminance value of the blue channel of the pixel. Preferably, c1 is 0.299, c2 is 0.587, and c3 is 0.114.
[0139] In step S210, the region of interest of the original image can also be intercepted, and the region of interest is scaled to a fixed size (such as a square matrix of a fixed size, such as 121×121 pixel size), and a grayscale image GI0 is obtained based on the image of the fixed size to reduce the amount of computation and unify the detection method. This process is a conventional method in this technical field and will not be elaborated here.
[0140] In step S220, the grayscale image GI0 obtained in step S210 needs to be processed. For example, at least the binaryzation step S221 is performed, and the processed image is used as the adjusted grayscale image GIA for the gradient calculation in step S230. For example, only binaryzation can be performed, and the binaryzed image GI1 is directly used as the adjusted grayscale image GIA. Among them, the binaryzation process includes: when the grayscale value gray of the pixel of the grayscale image is greater than or equal to the grayscale threshold, the grayscale value gray of the pixel is set to the maximum grayscale value u, and when the grayscale value of the pixel is less than the grayscale threshold, the grayscale value gray of the pixel is set to the minimum grayscale value v. For example, the total grayscale level of the image is 256 levels, the minimum grayscale value v is 0, and the maximum grayscale value u is 255. Then the grayscale value gray of the pixel of the original grayscale image may be any natural number greater than or equal to 0 and less than or equal to 255. After binaryzation, the first grayscale image GI1 is obtained, and the grayscale value of each pixel in the first grayscale image GI1 is either the maximum grayscale value (such as 255) or the minimum grayscale value (such as 0).
[0141] When performing the binaryzation process, preferably, the grayscale threshold thg of a certain pixel PI0 is determined according to the grayscale value gray of the certain pixel PI0 and the grayscale values gray of its surrounding pixels. That is, instead of using a unified grayscale threshold for binaryzation, adaptive binaryzation is used, so that better results can still be obtained in the case of local overexposure or underexposure.
[0142] For example, the grayscale threshold thg of a certain pixel PI0 can be determined according to the following method:
[0143] First step, an image matrix A with a size of p×p centered on a certain pixel PI0 is intercepted from the grayscale image GI0, where p is an odd number, such as p is 9, 11, 13, etc., and preferably p = 11;
[0144] In the second step, a weight matrix W of size p×p is set. The value of the element in the x-th row and y-th column of matrix W is denoted as w(x,y), where x and y are positive integers, 1≤x≤p, 1≤y≤p, and the values of all w(x,y) satisfy That is, the sum of all w(x,y) is 1. Preferably, each w(x,y) is greater than or equal to 0;
[0145] In the third step, the value of thg is calculated. Among them, the gray threshold thg of a certain pixel PI0 is the difference between the result of the convolution of the image matrix A and the weight matrix W and a preset threshold constant con (such as 1).
[0146] The image matrix A and the weight matrix W are two-dimensional matrices of the same size. The convolution result of the two is the sum of the products of the pixels at the corresponding positions of the two, that is:
[0147]
[0148] In formula (2), a(x,y) represents the element in the x-th row and y-th column of the image matrix A.
[0149] When a certain pixel PI0 is close to the edge in the grayscale image GI0 and a p×p-sized image matrix A centered on a certain pixel PI0 cannot be cropped from the grayscale image GI0, 0 can be padded outside the four sides of the grayscale image GI0, and a p×p-sized image matrix A centered on a certain pixel PI0 can be cropped from the padded grayscale image.
[0150] Preferably, the value of the central element at the position ((p + 1) / 2, (p + 1) / 2) in the weight matrix W is greater than the values of other elements. Thus, the gray threshold thg of the pixel PI0 is more affected by the original gray value of the pixel PI0, and the influence of local overexposure or underexposure on the detection result can be reduced. Preferably, in the weight matrix W, the closer the element is to the central element, the greater its value. Preferably, in the weight matrix W, the values of the elements at the same distance dis from the central element are equal. Among them, the distance dis between the element w(x,y) in the weight matrix W and the central element is calculated according to the following formula (3):
[0151]
[0152] For example, the weight matrix W can be set like this. First, a matrix C of size p×p is set. The value of the element in the x-th row and y-th column of matrix C is denoted as c(x,y), where x and y are positive integers, 1≤x≤p, 1≤y≤p, and the value of c(x,y) is calculated according to the following formula (4):
[0153]
[0154] In formula (4), σ is a constant. The value w(x, y) of the element in the x-th row and y-th column of the weight matrix W is calculated according to the following formula (5):
[0155]
[0156] Preferably, in this application, the constant σ is calculated according to the value of p. For example:
[0157] σ = 0.3×[(p - 1)×0.5 - 1] + 0.8 (6)
[0158] After obtaining the first grayscale image GI1, the first grayscale image GI1 can be used as the adjusted grayscale image GIA, and then step S230 is executed. Alternatively, the first grayscale image GI1 can also be further adjusted, and the further adjusted image is used as the adjusted grayscale image GIA.
[0159] As Figure 3 shown, for example, step S222 or S223 can be executed after the binarization step S221 to perform at least histogram equalization processing on the first grayscale image GI1, that is, adjust the grayscale of the binarized first grayscale image GI1 to obtain the second grayscale image GI2, and use the second grayscale image GI2 as the adjusted grayscale image GIA.
[0160] For example, the second grayscale image GI2 can be obtained according to the following method:
[0161] First step, an image matrix D with a size of q×q including a certain pixel PI1 is intercepted from the first grayscale image GI1, where q is an odd number, such as q = 9, 11, 13, etc., and preferably q = 11 (q = p);
[0162] Second step, the grayscale distribution of the image matrix D is counted to obtain the first grayscale distribution statistical result. It can be understood that the first grayscale distribution statistical result is also the number of occurrences of each grayscale i in the image matrix D. The value range of the grayscale value i is from the minimum grayscale value v to the maximum grayscale value u, that is, there are a total of u - v + 1 values, which are v, v + 1, v + 2,..., u;
[0163] Third step, the first grayscale distribution statistical result is adjusted to obtain the second grayscale distribution statistical result;
[0164] Fourth step, calculate the ratio of the statistical value of each grayscale value i in the second grayscale distribution statistical result to q 2 where the statistical value of the grayscale value i in the second grayscale distribution statistical result is denoted as s(i), and the ratio of s(i) to q 2The ratio is denoted as r(i). As described above, the gray value i is u - v + 1 natural numbers from the minimum gray value v to the maximum gray value u, and r(i) is the proportion of the gray value i among all the pixels in the image matrix D (which can also be understood as the probability of the gray value i in the image matrix D);
[0165] Step 5, set the function where v is the minimum gray value (for example, 0), and the value range of the gray value i is from the minimum gray value v to the maximum gray value u (for example, 255). Thus, the function cdf(i) is equivalent to the integral or sum of the probabilities of the gray values less than or equal to i;
[0166] Step 6, calculate the gray mapping value of a certain pixel PI1 for the image matrix D according to the following formula (7):
[0167] map = u × [cdf(g1) - cdfmin] ÷ (1 - cdfmin) (7)
[0168] In formula (7), map is the gray mapping value of a certain pixel PI1 for the image matrix D, u is the maximum gray value (for example, 255), g1 is the gray value of a certain pixel PI1 in the first gray image GI1, and cdfmin is the minimum value of the function cdf(i). In this application, cdfmin = cdf(v);
[0169] Step 7, determine the gray value g2 of a certain pixel PI1 in the second gray image GI2 according to the gray mapping value of a certain pixel PI1 for the image matrix D.
[0170] Compared with the first gray image GI1, the second gray image GI2 improves the local contrast of the image, that is, the local contrast of the local area where all are the maximum gray value or all are the minimum gray value, and can further eliminate the influence of overexposed or underexposed points on the detection of gradient information.
[0171] For the operation in the above Step 3, to adjust the first gray distribution statistical result to obtain the second gray distribution statistical result, it can be implemented according to the following method:
[0172] The first sub-step, determine the gray values in the first gray distribution statistical result whose statistical values are greater than the preset quantity threshold cl, and denote them as the gray values to be limited;
[0173] The second sub-step, calculate the difference in the quantity to be limited obtained by subtracting the preset quantity threshold cl (for example, 95) from the statistical value of each gray value to be limited;
[0174] The third sub-step, calculate the sum te of all the differences in the quantity to be limited;
[0175] The fourth sub-step, calculate the integer part in of the quotient obtained by dividing te by the total number of gray levels (that is, u - v + 1);
[0176] The fifth sub-step is to calculate the difference up of cl minus in;
[0177] The sixth sub-step is to adjust the statistical value of the grayscale value greater than or equal to up in the first grayscale distribution statistical result to a preset quantity threshold cl, so that the statistical value in the first grayscale distribution statistical result is less than the statistical value of the grayscale value of up plus in, thereby obtaining a second grayscale distribution statistical result.
[0178] It can be seen that the present application adopts a method of limiting contrast and adaptive grayscale equalization. On the basis of ensuring that the total number of grayscale values (which can also be understood as the grayscale histogram area) is constant, it reduces (limits) the local overly concentrated grayscale values and increases the grayscale values with a small probability of occurrence, so as to reduce the impact of local overexposure or excessive darkness on gradient information detection.
[0179] In the first step, it is necessary to extract a q×q image matrix D including a certain pixel PI1 from the first grayscale image GI1. Here, there is no special limitation on the position of the pixel PI1 in the image matrix D, that is, the pixel PI1 can be located at any position in the image matrix D.
[0180] Preferably, at least one image matrix D is intercepted to meet the first condition, which is: the position of the element of the first row and the first column of the image matrix D in the first grayscale image GI1 is (1+k·q, 1+l·q), where k and l are natural numbers. That is, the first grayscale image GI1 is divided into a plurality of adjacent, non-overlapping image blocks of equal size (all of size q×q), and each image block can be an image matrix D (the number of rows and columns of pixels of which are both integer multiples of q).
[0181] Preferably, for any image matrix D that satisfies the first condition, the grayscale g2 of a certain pixel PI1 in the second grayscale image GI2 is the grayscale mapping value of the pixel PI1 for the image matrix D to which it belongs. For example, the image matrix D is an image block from the first row to the qth row and the first column to the qth column of the first grayscale image GI1, that is, the image block in the upper left corner of the first grayscale image GI1, then all pixels from the first row to the qth row and the first column to the qth column of the first grayscale image GI1 share the same image matrix D (that is, share the same first grayscale distribution statistical result and the same second grayscale distribution statistical result), and the grayscale value of any one of the pixels from the first row to the qth row and the first column to the qth column of the second grayscale image GI2 is the grayscale mapping value of the pixel of the first grayscale image GI1 corresponding to the position for the image matrix D to which it belongs.
[0182] When step S222 is executed, all image matrices D satisfy the first condition (i.e., all image matrices D are intercepted according to the first condition), and for each of all image matrices D, the gray level of a certain pixel PI1 in the second gray image is the gray level mapping value of the pixel PI1 for the image matrix D to which it belongs.
[0183] When step S223 is executed, only a part of the image matrices D of PI1 are intercepted according to the first condition.
[0184] Specifically, as Figure 4 shown, the pixels of the first gray image GI1 include the pixels in the edge region GI11 (edge region pixels) and the pixels in the middle region GI12 (middle region pixels). Among them, the edge region pixels are the pixels in the leftmost q columns, the rightmost q columns, the uppermost q rows, and the lowermost q rows of the first gray image GI1, that is, the pixels in the region of a rectangular ring with a peripheral dimension (span) of q pixels. The middle region pixels are the pixels of the first gray image GI1 except for the edge region pixels GI11, that is, the pixels in the middle rectangular region GI12 surrounded by this rectangular ring. On the basis of this partition, for example, the following method can be used:
[0185] (1) For the edge region pixels, intercept the image matrix D from the first gray image GI1 according to the first condition, and for the image matrix D that satisfies the first condition (i.e., the image matrix D intercepted from the edge region pixels), the gray level g2 of a certain edge region pixel PI11 in the second gray image GI2 is the gray level mapping value of the edge region pixel PI11 for the image matrix D to which it belongs;
[0186] (2) For the middle region pixels, for example, the middle region pixel PI12, intercept four image matrices D of size q×q containing the middle region pixel PI12 from the first gray image GI1, calculate the gray level mapping values of the middle region pixel PI12 for the four image matrices D to which it belongs respectively, and use the result of the bilinear interpolation of the four gray level mapping values as the gray level of the middle region pixel PI12 in the second gray image GI2.
[0187] Therefore, in step S223, by further interpolating with adjacent image blocks, the sudden change difference between image blocks is reduced, and the influence of texture information and local brightness change on the image gradient is further reduced.
[0188] The intermediate region pixel PI12 is simultaneously included in four image matrices D. Preferably, the positions of the intermediate region pixel PI12 in the four image matrices D differ from each other by one row and / or one column. For example, the position of the intermediate region pixel PI12 in the first image matrix D is ((q + 1) / 2, (q + 1) / 2), which is the central element, the position in the second image matrix D is ((q + 1) / 2, (q + 1) / 2 - 1), which is the element adjacent to the left of the central element, the position in the third image matrix D is ((q + 1) / 2 - 1, (q + 1) / 2), which is the element adjacent to the above of the central element, and the position in the fourth image matrix D is ((q + 1) / 2 - 1, (q + 1) / 2 - 1), which is the element adjacent to the upper left of the central element.
[0189] In this application, both the first grayscale image GI1 and the second grayscale image GI2 are images of the same size as the grayscale image GI0, for example, images of size r×o.
[0190] After obtaining the adjusted grayscale image GIA, in step S230, the gradient image H can be obtained by the following method:
[0191] In the first step, the horizontal operator matrix Gx is convolved with the adjusted grayscale image GIA to obtain the horizontal gradient image matrix Kx, and the vertical operator matrix Gy is convolved with the adjusted grayscale image GIA to obtain the vertical gradient image matrix Ky;
[0192] In the second step, the absolute value of each pixel value in the horizontal gradient image matrix Kx is taken to obtain the first gradient image matrix Hx, and the absolute value of each pixel value in the vertical gradient image matrix Ky is taken to obtain the second gradient image matrix Hy;
[0193] In the third step, the gradient image H is calculated according to the following formula (8):
[0194] H = (Hx + Hy) / 2 (8)
[0195] Preferably, both the horizontal operator matrix Gx and the vertical operator matrix Gy are matrices of size t×t (t < r, t < o), where t is an odd number, such as 3, 5. The horizontal operator matrix Gx and / or the vertical operator matrix Gy are, for example, constructed as Sobel operators. For example,
[0196]
[0197] Since the sizes of the horizontal operator matrix Gx and the vertical operator matrix Gy are different from the size of the adjusted grayscale image GIA, the horizontal gradient image matrix Kx and the vertical gradient image matrix Ky are still r×o matrices with the same size as the adjusted grayscale image GIA, and the gradient image H is also an r×o matrix with the same size as the adjusted grayscale image GIA. The gradient image H contains the horizontal gradient information and the vertical gradient information of the image, and can comprehensively reflect the gradient of the image. Based on the premise that the sensitivity of the gradient to the clear area is greater than that to the blurred area in this application, it is possible to effectively determine whether the image is blurred.
[0198] In the first step, when convolving the operator matrices Gx and Gy with the adjusted grayscale image GIA, when a certain element PIA of the adjusted grayscale image GIA is close to the edge, such that a t×t matrix centered on a certain element PIA cannot be intercepted from the image GIA, the four sides of the image GIA are supplemented with elements according to the principle of mirror symmetry, that is, the supplemented elements are mirror-symmetric with the elements in the image GIA with respect to a certain element PIA, and then a t×t matrix centered on a certain element PIA is intercepted from the enlarged adjusted grayscale image GIA.
[0199] In step S240, preferably, the blur detection score s is set to the standard deviation of the values of all pixels in the gradient image H, that is:
[0200]
[0201] In formula (9), h(i,j) is the value of the element in the i-th row and j-th column of the gradient image H, n is the number of elements in the gradient image H (n = r×o), and hmean is the average value of the values of all elements in the gradient image H.
[0202] The calculation process of the detection method according to this application is simple and the parameter selection is reasonable, which can solve the problem of inaccurate blur judgment caused by uneven illumination in grayscale images (such as infrared images), and effectively improve the accuracy of blur detection.
[0203] This application also provides an image detection device for detecting whether an image is blurred. In a specific implementation, the image detection device includes, for example, a memory, a processor, and a computer program stored on the memory and running on the processor. Among them, when the processor executes the computer program, the steps of the above-mentioned image detection method for detecting whether an image is blurred can be implemented. The image detection device according to this application can be a desktop PC, a laptop computer, a tablet computer, a smart phone, etc. with data processing functions, or a dedicated device for image detection.
[0204] The present application also provides a computer storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-described image detection method for detecting whether an image is blurred can be implemented. The storage medium may include, for example, a memory card of a smart phone, a storage component of a tablet computer, a hard disk of a PC, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a portable compact disc read-only memory (CD-ROM), a USB memory, or any combination of the above storage media. The computer-readable storage medium may be any combination of one or more computer-readable storage media.
[0205] In all of the above preferred embodiments, the processes and steps described are merely examples. Unless adverse effects occur, various processing operations may be performed in an order different from the order of the above processes. The order of the steps of the above processes may also be increased, combined, or deleted according to actual needs.
[0206] When understanding the scope of the present application, as used herein, the term "comprising" and its derivatives are intended to be open-ended terms that specify the presence of the recited features, elements, components, groups, wholes, and / or steps, but do not exclude the presence of other unrecited features, elements, components, groups, wholes, and / or steps. This concept also applies to words with similar meanings, such as the terms "including", "having", and their derivatives.
[0207] As used herein, the term "attached" or "attachment" includes: a configuration in which an element is directly fixed to another element by directly fixing the element to the other element; a configuration in which an element is indirectly fixed to another element by fixing the element to an intermediate member, and the intermediate member is in turn fixed to the other element; and a configuration in which one element is integral with another element, i.e., one element is substantially a part of the other element. This definition also applies to words with similar meanings, such as "connected", "coupled", "joined", "mounted", "adhered", "fixed", and their derivatives. Finally, degree terms such as "substantially", "about", and "approximately" as used herein represent the amount of deviation that modifies the term such that the final result will not be significantly changed.
[0208] Unless otherwise defined, the technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the technical field of the present application. The terms used herein are only for the purpose of describing specific embodiments and are not intended to limit the present application. The features described in one embodiment herein may be applied alone or in combination with other features in another embodiment, unless the feature is not applicable or otherwise stated in that other embodiment.
[0209] The present application has been described by the above embodiments. However, it should be understood that the above embodiments are only for illustrative and explanatory purposes, and are not intended to limit the present application to the scope of the described embodiments. In addition, those skilled in the art can understand that the present application is not limited to the above embodiments, and more variations and modifications can be made according to the teachings of the present application, and these variations and modifications all fall within the scope claimed by the present application.
Claims
1. An image detection method for detecting whether an image is blurred, characterized in that, Including: A training session for determining a detection threshold, where the training session includes: Step S100: Set an initial detection threshold, and then execute Step S200. Step S200: Randomly select m images, calculate the blur detection score for each image, and manually determine whether each image is a blurred image or a clear image, where m is a positive integer, and then execute Step S300. Step S300: Determine the maximum value smax and the minimum value smin of all the blur detection scores, determine a corrected detection threshold within the range [smin, smax], mark the images with blur detection scores less than or equal to the corrected detection threshold as blurred images, and mark the images with blur detection scores greater than the corrected detection threshold as clear images. Among them, the corrected detection threshold makes the marking results of all images have the highest degree of coincidence with the manual judgment results, and then execute Step S400. Step S400: When the absolute value of the difference between the corrected detection threshold and the initial detection threshold is less than or equal to a preset error, set the value of the detection threshold to the corrected detection threshold, and then end the training session; when the absolute value of the difference between the corrected detection threshold and the initial detection threshold is greater than the preset error, set the value of the initial detection threshold to the corrected detection threshold, and then execute Step S500, and Step S500: Randomly select a new image, calculate the blur detection score of the new image, and manually determine whether the new image is a blurred image or a clear image, and then execute Step S300; and A detection session for detecting whether an image is blurred, where the detection session includes: Calculate the blur detection score of the image to be detected. When the blur detection score of the image to be detected is greater than the detection threshold, determine that the image to be detected is a clear image; when the blur detection score of the image to be detected is less than or equal to the detection threshold, determine that the image to be detected is a blurred image.
2. The image detection method according to claim 1, wherein The calculation of the blur detection score for each image includes: Step S210: Convert the image into a grayscale image. Step S220: Perform at least binarization processing on the grayscale image to obtain an adjusted grayscale image. Among them, the binarization processing includes: when the grayscale value of a pixel in the grayscale image is greater than or equal to a grayscale threshold, make the grayscale value of the pixel the maximum grayscale value; when the grayscale value of the pixel is less than the grayscale threshold, make the grayscale value of the pixel the minimum grayscale value. Step S230: Calculate a gradient image based on the adjusted grayscale image. Step S240: Calculate the blur detection score based on the gradient image.
3. The image detection method according to claim 2, wherein The image detection method further includes: when performing the binarization processing, determining the grayscale threshold of a certain pixel PI0 according to the grayscale value of the certain pixel PI0 and the grayscale values of its surrounding pixels.
4. The image detection method according to claim 3, wherein The determination of the grayscale threshold of a certain pixel PI0 according to the grayscale value of the certain pixel PI0 and the grayscale values of its surrounding pixels includes: Extract an image matrix A of size p×p centered on a certain pixel PI0 from the grayscale image, where p is an odd number. Set a weight matrix \(W\) of size \(p\times p\), and the value of the element in the \(x\)-th row and \(y\)-th column of the matrix \(W\) is denoted as \(w(x,y)\). Where \(x\) and \(y\) are positive integers, \(1\leq x\leq p\), \(1\leq y\leq p\), The grayscale threshold of the certain pixel PI0 is the difference between the result of the convolution of the matrix A and the matrix W minus a preset threshold constant.
5. The image detection method according to claim 4, wherein The value of the central element at position ((p + 1) / 2, (p + 1) / 2) in the weight matrix W is greater than the values of other elements.
6. The image detection method according to claim 5, wherein in the weight matrix W, the closer an element is to the central element, the greater its value; and / or in the weight matrix W, the values of elements at equal distances from the central element are equal.
7. The detection method according to claim 6, characterized in that, The setting of the weight matrix W of size p×p includes: Set up a matrix \(C\) of size \(p\times p\), and the value of the element in the \(x\)-th row and \(y\)-th column of the matrix \(C\) is denoted as \(c(x,y)\), where \(x\) and \(y\) are positive integers, \(1\leq x\leq p\), \(1\leq y\leq p\). where \(\sigma\) is a constant. The value w(x, y) of the element in the x-th row and y-th column of the weight matrix W is calculated according to the following formula:
8. The image detection method according to claim 7, wherein The image detection method further includes calculating the constant σ according to the value of p.
9. The image detection method according to claim 2, wherein The obtaining of the gradient image from the adjusted grayscale image includes: Convolving the horizontal operator matrix with the adjusted grayscale image to obtain a horizontal gradient image matrix, and convolving the vertical operator matrix with the adjusted grayscale image to obtain a vertical gradient image matrix. Take the absolute value of each pixel value in the horizontal gradient image matrix to obtain the first gradient image matrix Hx; take the absolute value of each pixel value in the vertical gradient image matrix to obtain the second gradient image matrix Hy. Calculate the gradient image H according to the following formula: H = (Hx + Hy) / 2.
10. The image detection method according to claim 9, wherein The horizontal operator matrix and / or the vertical operator matrix is constructed as a Sobel operator.
11. The image detection method according to claim 2, wherein The calculating of the blur detection score according to the gradient image includes: The blur detection score is the standard deviation of all pixel values in the gradient image.
12. The image detection method according to claim 2, wherein The converting of the image into a grayscale image includes: When the image is a color image, make the value of each pixel point of the image be the grayscale value gray, where the grayscale value gray is calculated according to the following formula: gray = c1×R + c2×G + c3×B, where c1, c2, and c3 are constants, c1 + c2 + c3 = 1, R is the luminance value of the red channel of the pixel point, G is the luminance value of the green channel of the pixel point, and B is the luminance value of the blue channel of the pixel point.
13. The image detection method according to any one of claims 2 to 12, wherein Step S220 further includes: performing binarization processing on the grayscale image to obtain a first grayscale image, adjusting the grayscale of the binarized first grayscale image to obtain a second grayscale image, and using the second grayscale image as the adjusted grayscale image.
14. The image detection method according to claim 13, wherein The adjusting of the grayscale of the binarized first grayscale image to obtain a second grayscale image includes: Extract an image matrix D of size q×q containing a certain pixel from the first grayscale image, where q is an odd number. Statistical the grayscale distribution of the image matrix D to obtain a first grayscale distribution statistical result. Adjust the first grayscale distribution statistical result to obtain a second grayscale distribution statistical result. Calculate the ratio of the statistical value of each gray value in the second gray-scale distribution statistical result to q 2 , where the statistical value of gray value i in the second gray-scale distribution statistical result is denoted as s(i), and the ratio of s(i) to q 2 is denoted as r(i). Set function where v is the minimum gray value, and the gray value i ranges from the minimum gray value to the maximum gray value Calculate the gray-scale mapping value of a certain pixel for the image matrix D according to the following formula: map = u × [cdf(g1) - cdfmin] ÷ (1 - cdfmin)), where map is the gray-scale mapping value of a certain pixel for the image matrix D, u is the maximum gray value, g1 is the gray value of the certain pixel in the first gray-scale image, and cdfmin is the minimum value of the function cdf(i). Determine the gray scale of the certain pixel in the second gray-scale image according to the gray-scale mapping value.
15. The image detection method according to claim 14, wherein Adjusting the first gray-scale distribution statistical result to obtain a second gray-scale distribution statistical result includes: Determine the gray values in the first gray-scale distribution statistical result whose statistical values are greater than the preset quantity threshold cl, and record them as the gray values to be limited. Calculate the difference in the quantity to be limited obtained by subtracting the preset quantity threshold cl from the statistical value of each gray value to be limited. Calculate the sum te of all the differences in the quantity to be limited. Calculate the integer part in of the quotient obtained by dividing te by the total number of gray levels. Calculate the difference up between cl and in. Adjust the statistical values of the gray values in the first gray-scale distribution statistical result that are greater than or equal to up to the preset quantity threshold cl, and add in to the statistical values of the gray values in the first gray-scale distribution statistical result that are less than up, so as to obtain the second gray-scale distribution statistical result.
16. The image detection method according to claim 14, wherein At least one of the image matrices D satisfies the first condition, and the first condition is: the element in the first row and first column of the image matrix D is at the position (1 + k·q, 1 + l·q) in the first gray-scale image, where k and l are natural numbers; and The gray scale of a certain pixel in the image matrix D that satisfies the first condition in the second gray-scale image is the gray-scale mapping value of the certain pixel for the image matrix D.
17. The image detection method according to claim 16, wherein All the image matrices D satisfy the first condition: and The gray scale of a certain pixel in each image matrix D in the second gray-scale image is the gray-scale mapping value of the certain pixel for the image matrix D.
18. The image detection method according to claim 16, wherein The pixels of the first gray-scale image include edge region pixels and middle region pixels. Among them, the edge region pixels are the pixels in the leftmost q columns, the rightmost q columns, the uppermost q rows, and the lowermost q rows of the first gray-scale image, and the middle region pixels are the pixels in the first gray-scale image except the edge region pixels. Among them, the image matrix D intercepted from the edge region pixels satisfies the first condition; and The gray scale of a certain edge region pixel PI11 in the image matrix D intercepted from the edge region pixels in the second gray-scale image is the gray-scale mapping value of the edge region pixel PI11 for the image matrix D.
19. The image detection method according to claim 18, characterized in that, The gray level of a certain pixel PI12 among the pixels in the middle region in the second gray-scale image is determined according to the following method: Four image matrices D with a size of q×q containing the middle-region pixel PI12 are cropped from the first gray-scale image. The gray-level mapping values of the middle-region pixel PI12 for the four image matrices D are calculated respectively, and the result of the bilinear interpolation of the four gray-level mapping values is used as the gray level of the middle-region pixel PI12 in the second gray-scale image.
20. The image detection method according to claim 19, wherein The positions of the middle-region pixel PI12 in the four image matrices D differ from each other by one row and / or one column.
21. The image detection method according to claim 20, wherein: The position of the middle-region pixel PI12 in the first image matrix D is ((q + 1) / 2, (q + 1) / 2). The position of the middle-region pixel PI12 in the second image matrix D is ((q + 1) / 2, (q + 1) / 2 - 1). The position of the middle-region pixel PI12 in the third image matrix D is ((q + 1) / 2 - 1, (q + 1) / 2). The position of the middle-region pixel PI12 in the fourth image matrix D is ((q + 1) / 2 - 1, (q + 1) / 2 - 1).
22. An image detection device for detecting whether an image is blurred, comprising a memory, a processor, and a computer program stored on the memory and running on the processor, characterized in that, When the processor executes the computer program, the steps of the image detection method according to any one of claims 1 to 21 are implemented.
23. A computer storage medium, on which a computer program is stored, characterized in that, When the computer program is executed by the processor, the steps of the image detection method according to any one of claims 1 to 21 are implemented.