Image clarity data processing method, device, and electronic device

Through gradient algorithm and position matrix calculation, combined with weighting coefficients, the problem that image sharpness algorithms in the prior art cannot effectively evaluate overall sharpness, and a comprehensive evaluation and distributed characterization of image sharpness are achieved.

CN118918109BActive Publication Date: 2024-12-27HANGZHOU XINO INTELLIGENT MEDICINE CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202411411521.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-10
Publication Date
2024-12-27
Estimated Expiration
2044-10-10

AI Technical Summary

Technical Problem

The existing image definition algorithm is based on the total image gradient, and it is easy to filter out images with high local sharpness but poor overall sharpness, and cannot effectively filter out images with good overall sharpness.

Method used

The gradient algorithm calculates the pixel gradient value and total gradient of the target image, filters pixel points based on the preset gradient threshold, calculates the degree of dispersion of the position matrix and gradient position, and calculates the sharpness of the image with weighting coefficients, reflects the overall sharpness and clarity of the image distributed.

Benefits of technology

Effective evaluation of the overall sharpness of the image and the characterization of the definition distribution are achieved, and the problem of high local sharpness but poor overall sharpness is solved, and images with high overall sharpness and uniform sharpness of each part can be screened out.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118918109B_ABST
    Figure CN118918109B_ABST
Patent Text Reader

Abstract

The invention relates to a data processing method, device and electronic device for image clarity. The method first calculates the pixel gradient value of each pixel point of the target image through a gradient algorithm, then selects the pixel points whose pixel gradient value reaches a preset gradient threshold as the target pixel points, and calculates the position matrix based on the pixel coordinates of the target pixel points. The gradient position discreteness of the target image is calculated according to the position matrix to characterize the overall distribution of clarity, which can be used as a reference to select images with better overall clarity. This solves the problem that the image clarity algorithm in the related art can easily select images with high local clarity gradient values ​​based on the total amount of gradient, but the clarity of other parts of the image is poor, resulting in the inability to select images with better overall clarity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of image processing, and in particular to a method, device and electronic equipment for processing image clarity data. Background Art

[0002] Image clarity is an important indicator for measuring image quality. For cameras, they generally work in a mode without a reference image, so focus control is required when taking pictures. If the focus is not accurate, the image will become blurry and unclear. When the camera focuses, it controls the distance between the lens and the CCD (Charge coupled Device) through some clarity evaluation indicators to make the image clear. Generally, there is an adjustment process when focusing, and the image goes from blurry to clear, then to blurry again, determine the clarity peak, and finally reach the clearest position.

[0003] There is a focusing process when taking pictures. In order to find the focus point, take pictures at certain distances within the range set above and below the focal length. In this way, you will get a group of photos. Find the clearest photo among them, and the corresponding position is the focus point.

[0004] In related technologies, to find the clearest photo in a group of photos, a clarity algorithm is usually used to calculate the clarity of each photo, and then find the photo with the highest clarity. Current clarity algorithms are all based on image gradients, and there are many ways to calculate image gradients. The difference generally lies in the calculation of pixel position and calculation formula, but the basic concept is the same, that is, by calculating the pixel gradients within a local range, the total gradient of the entire image is summed up, that is, the clarity of the image.

[0005] However, the existing clarity algorithms may find that the photo images with high gradient values, that is, the photo images with high clarity, may only have a small local area that is clear, while the rest of the majority of the area is more blurred. For example, the image gradient value of a cluster of cells is very high, but most of the other areas are unclear. This situation is not the clearest image we want to find, which means that the existing clarity algorithms have great limitations and cannot guarantee the uniform distribution of the overall clarity of the image.

[0006] Regarding the image clarity algorithm in the related technology, based on the total amount of gradient, it is easy to screen out images with high gradient values ​​of local clarity, but poor clarity of other parts of the image, resulting in the problem of being unable to screen out images with good overall clarity. No effective solution has been proposed yet. Summary of the invention

[0007] The present invention provides a method, device and electronic device for processing image clarity data, which at least solve the problem that the image clarity algorithm in the related art can easily screen out images with high local clarity gradient values ​​based on the total gradient, but poor clarity of other parts of the image, resulting in an inability to screen out images with good overall clarity.

[0008] The invention provides a method for processing image clarity data, comprising: calculating the pixel gradient value of each pixel point of a target image by a gradient algorithm; screening the pixel points of the target image according to a preset gradient threshold, and determining that the pixel points whose pixel gradient values ​​reach the preset gradient threshold are target pixel points; calculating a position matrix according to the coordinates of the target pixel points; and calculating the degree of gradient position discreteness of the target image according to the position matrix.

[0009] As an optional embodiment, after calculating the degree of gradient position discreteness of the target image according to the position matrix, the method further includes: calculating a weighting coefficient of the clarity of the target image according to the degree of gradient position discreteness, wherein the target image is a single image in a group of images in which the target object is photographed at different heights; calculating the clarity of the target image according to the weighting coefficient and the total gradient calculated by the gradient algorithm; and determining the image with the highest clarity according to the clarity of each image in the group of images.

[0010] As an optional embodiment, the weighting coefficient of the clarity of the target image is calculated according to the degree of gradient position discreteness, including: calculating the degree of gradient position discreteness of each image in the group of images; calculating the weighting coefficient according to the degree of gradient position discreteness of the target image and the minimum value of the degree of gradient position discreteness in the group of images.

[0011] As an optional embodiment, the clarity of the target image is calculated based on the weighting coefficient and the total gradient calculated by the gradient algorithm, including: when the number of target pixel points reaches a preset threshold number, using the product of the weighting coefficient and the total gradient as the clarity of the target image; when the number of target pixel points does not reach the preset threshold number, using the total gradient as the clarity of the target image.

[0012] As an optional embodiment, the pixel gradient values ​​and the total gradient of each pixel point of the target image are calculated by a gradient algorithm, including: calculating the pixel gradient values ​​of the available pixels according to a preset method using the pixel values ​​of the pixel points adjacent to the available pixels, wherein the available pixels are pixel points that meet the preset method for calculating the required adjacent pixel points; and calculating the total gradient according to the pixel gradient values ​​of the available pixels of the target image using the calculation formula of the gradient algorithm.

[0013] As an optional embodiment, the position matrix is ​​calculated according to the coordinates of the target pixel points, including: counting the number of target pixel points of the target image; when the number reaches a preset threshold, generating the position matrix according to the position coordinates of the target pixel points, wherein the number of rows of the position matrix is ​​the number of the target pixel points, and the number of columns is 2.

[0014] As an optional embodiment, the degree of gradient position discreteness of the target image is calculated according to the position matrix, including: calculating the corresponding covariance matrix according to the position matrix; calculating the variance features of the projection values ​​of each position in the direction of the eigenvector according to the covariance matrix, wherein the number of the variance features is the same as the order of the covariance matrix; and obtaining the degree of gradient position discreteness by summing the variance features.

[0015] As an optional embodiment, the corresponding covariance matrix is ​​calculated according to the position matrix, including: calculating the coordinate mean according to the position coordinates of the target pixel point in the position matrix; de-centering the position matrix according to the coordinate mean to obtain a normalized matrix; and calculating the covariance matrix according to the normalized matrix.

[0016] The invention provides a data processing device for image clarity, comprising: a gradient calculation module, used to calculate the pixel gradient value of each pixel point of a target image by a gradient algorithm; a threshold screening module, used to screen the pixel points of the target image according to a preset gradient threshold value, and determine that the pixel points whose pixel gradient values ​​reach the preset gradient threshold value are the target pixel points; a position matrix module, used to calculate the position matrix according to the coordinates of the target pixel points; and a gradient position discrete degree module, used to calculate the gradient position discrete degree of the target image according to the position matrix.

[0017] An electronic device provided by an embodiment of the present invention includes: a processor, and a memory storing a program, wherein the program includes instructions, and when the instructions are executed by the processor, the processor executes any one of the methods described above.

[0018] An embodiment of the present invention provides a non-transitory machine-readable medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute any one of the methods described above.

[0019] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, and when the computer program / instruction is executed by a processor, any of the above methods is implemented.

[0020] The data processing method for image clarity provided by the embodiment of the present invention calculates the pixel gradient value and the total gradient of each pixel point of the target image through a gradient algorithm, calculates the position matrix according to the coordinates of the target pixel points whose pixel gradient values ​​reach the preset gradient threshold, and calculates the degree of gradient position discreteness of the target image, so that the image clarity and the distribution of clarity can be characterized in combination with the overall clarity, thereby reflecting the overall clarity of the image. The problem that the image clarity algorithm in the related art is easy to screen out images with high local clarity gradient values ​​based on the total gradient amount, but the clarity of other parts of the image is poor, resulting in the inability to screen out images with good overall clarity, is achieved. The technical effect of being able to express both the overall clarity and the overall distribution of clarity is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other embodiments can be obtained based on these drawings without creative work.

[0022] Figure 1 It is a schematic diagram of a photo focused on dust in a group of photos of an embodiment created by the present invention.

[0023] Figure 2 It is a schematic diagram of a photograph focusing on agglomerated cells in a group of figures of an embodiment of the invention.

[0024] Figure 3 The present invention is a flowchart of a method for processing image clarity data according to an embodiment of the present invention.

[0025] Figure 4 It is the clearest image selected according to the basic gradient algorithm of the implementation mode created by the present invention.

[0026] Figure 5 It is the clearest image selected according to the GGD algorithm of the implementation mode created by the present invention.

[0027] Figure 6 This is the clearest image screened out according to the basic gradient algorithm when there is dust on the surface of the object in the implementation mode created by the present invention.

[0028] Figure 7 This is the clearest image selected according to the GGD algorithm when there is dust on the surface of the object in the implementation mode created by the present invention.

[0029] Figure 8It is a schematic diagram of an image clarity data processing device according to an embodiment of the present invention.

[0030] Fig. 9 It is a structural schematic diagram of the electronic device created by the present invention. DETAILED DESCRIPTION

[0031] The embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided to provide a more thorough and complete understanding of the present invention. It should be understood that the drawings and embodiments of the present invention are only for exemplary purposes and are not intended to limit the scope of protection of the present invention.

[0032] In the related art, pathological slice scanning is to take microscopic photos of each field of view. There is a focusing process in taking photos. In order to find the focus point, photos are taken at certain distances within the range set above and below the focal length. In this way, a group of photos are obtained, and the clearest photo is found. The corresponding position is the focus point.

[0033] However, the surface of cells and tissues on the slices is undulating, and there may be dust on them. The objects in focus are layered. The focus may be on the dust on top, and the image gradient value is very high, such as Figure 1 As shown in . It is also possible that some parts are clear, such as clustered cells, with high image gradient values, but most other areas are unclear, such as Figure 2 shown.

[0034] In the above situations, we do not want to find the clearest image. The purpose is to find the real clearest image, for which we need to design a clarity algorithm.

[0035] Current clarity algorithms are all based on image gradients. There are many ways to calculate image gradients. The following description is a basic image gradient algorithm.

[0036] Image gradient refers to the rate of change of a pixel in the image in the x and y directions (compared with adjacent pixels). It is a two-dimensional vector consisting of two components: the change in the x-axis and the change in the y-axis.

[0037] The change in the X axis refers to the grayscale value to the right of the current pixel (X plus 1) minus the grayscale value of the current pixel.

[0038] The change on the Y axis is the gray value below the current pixel (Y plus 1) minus the gray value of the current pixel.

[0039] Calculating these two components to form a two-dimensional vector gives us the image gradient of the pixel.

[0040] The following formulas g(x) and g(y) are the gradients in the x and y directions respectively:

[0041]

[0042] Combining the gradients in the x and y directions, the gradient value of the pixel is:

[0043]

[0044] Considering the need to save computation time, the gradient value of a pixel can be:

[0045]

[0046] Currently, there are many methods for calculating gradients, such as the first-order Sobel operator, Roberts operator, Prewitt operator, Scharr operator, and the second-order Laplacian operator. Compared with the basic gradient method, the pixel positions and calculation formulas are different, but the basic concepts are the same. By calculating the gradients of pixels in a local range, the gradient value of the entire image, that is, the clarity of the image, is calculated.

[0047] The sobel operator calculates the gradient:

[0048] For each pixel of the image, the sobel operator uses the Gx convolution kernel to convolve the grayscale value of the x-direction gradient and the Gy convolution kernel to convolve the grayscale value of the y-direction gradient. After obtaining the x- and y-direction gradients, the calculation process of the pixel gradient value is the same as the basic gradient algorithm.

[0049] The clarity calculation methods in related technologies all calculate the gradient value of the entire image by summing up the gradients of pixel points in a local range. This reflects the total amount of gradients in the entire image, but does not reflect the location distribution of the gradients. Although the total gradient value of the entire image is high, the pixels with high gradient values ​​may be concentrated in certain local areas of the image, while the gradient values ​​in most areas of the image are not high. The entire image is not clear as a whole, and the problem of overall clarity of the entire image cannot be solved.

[0050] Regarding the image clarity algorithm in the related technology, based on the total amount of gradient, it is easy to screen out images with high gradient values ​​of local clarity, but poor clarity of other parts of the image, resulting in the problem of being unable to screen out images with good overall clarity. No effective solution has been proposed yet.

[0051] In order to solve the above technical problems, an embodiment of the present invention provides a method for processing image clarity data, wherein the method comprises the following steps:

[0052] Step S301, calculating the pixel gradient value of each pixel point of the target image by using a gradient algorithm;

[0053] Step S302, screening the pixels of the target image according to a preset gradient threshold, and determining the pixels whose pixel gradient values ​​reach the preset gradient threshold as the target pixels;

[0054] Step S303, calculating the position matrix according to the coordinates of the target pixel point;

[0055] Step S304, calculating the degree of gradient position discreteness of the target image according to the position matrix.

[0056] The above-mentioned image clarity data processing method provided by the embodiment created by the present invention calculates the pixel gradient value and the total gradient of each pixel point of the target image through a gradient algorithm, calculates the position matrix according to the coordinates of the target pixel points whose pixel gradient values ​​reach the preset gradient threshold, and calculates the degree of gradient position discreteness of the target image, so that the image clarity and the distribution of clarity can be characterized by combining the overall degree, thereby reflecting the overall clarity of the image, achieving the technical effect of being able to express both the overall clarity and the overall distribution of clarity.

[0057] The above-mentioned gradient algorithm can be a gradient algorithm already available in the relevant technology, for example, a first-order Sobel operator, a Roberts operator, a Prewitt operator, a Scharr operator, a second-order Laplacian operator, etc., which can also be referred to as a basic gradient algorithm in this embodiment. This embodiment addresses the problem that the basic gradient algorithm cannot reflect the overall gradient distribution of the image. The pixel gradient value of each pixel point is used to calculate the coordinates of the target pixel point that reaches a preset gradient threshold, and determine the position matrix and the degree of gradient position discreteness.

[0058] When the gradient algorithm is used to calculate the pixel gradient values ​​of each pixel of the target image, different gradient algorithms calculate the pixel gradient values ​​of a certain pixel in different ways and use different positions and numbers of adjacent pixels. Therefore, the pixel points of the target image whose pixel gradient values ​​are calculated are not all the pixel points in the target image. Usually, the pixel points in a row at the edge often cannot calculate the pixel gradient values ​​due to the lack of adjacent pixel points. Therefore, in this embodiment, the above-mentioned pixel points may be some available pixel points in the target image.

[0059] The pixel gradient value of each pixel can be used to characterize whether the difference between the pixel value of the pixel and the adjacent pixel values ​​is obvious, and thus the clarity of the pixel. There are many methods for calculating image gradients in related technologies, all of which have the same principle, referring to the rate of change of a certain pixel in the image with respect to the adjacent pixels in the X and Y directions. It is a two-dimensional vector consisting of two components: the change in the X axis and the change in the Y axis.

[0060] Considering that there are sometimes non-edge contour areas in the image, the pixel gradient values ​​of its pixels are not high and it is difficult to reflect the clarity. Therefore, the pixels of the target image are screened according to the preset gradient threshold, and the pixels whose pixel gradient values ​​reach the preset gradient threshold are determined as the target pixels. The target pixels can effectively reflect the image clarity, and the pixel gradient values ​​reaching the preset gradient threshold also indicate that the pixels of the target pixels are clear.

[0061] Then, the coordinates of the target pixel points are used to calculate the position matrix, and the gradient position discreteness of the target image is calculated based on the position matrix. It should be noted that the position matrix contains the coordinates of the target pixel points, that is, it contains the distribution information of the target pixel points. By deforming the position matrix by mathematical methods and calculating the characteristic parameters, a value of the gradient position discreteness can be obtained to characterize the distribution of the target pixel points that meet the clarity standard.

[0062] The specific calculation method of the position matrix in this embodiment will be described later. In addition, after obtaining the above-mentioned gradient position discreteness, it can be further combined with the overall degree calculated by the gradient algorithm to perform weighted calculation to obtain the overall degree including the gradient position discreteness, that is, the clarity value of the target image.

[0063] As an optional embodiment, after calculating the degree of gradient position discreteness of the target image according to the position matrix, the method further includes: calculating a weighting coefficient of the clarity of the target image according to the degree of gradient position discreteness, wherein the target image is a single image in a group of images in which the target object is photographed at different height positions; calculating the clarity of the target image according to the weighting coefficient and the total gradient calculated by the gradient algorithm; and determining the image with the highest clarity according to the clarity of each image in the group of images.

[0064] In the scenario of this embodiment, the image with the highest definition can be found in the group of images, which are multiple images of the same object taken at different focal lengths. In order to consider the comparison with other images in the group of images when calculating the definition of the image, the weighting coefficient of the image can be calculated according to the degree of discreteness, and the definition of the image can be calculated using the weighting coefficient.

[0065] Then, the clarity of the target image is calculated based on the weighted coefficient and the total gradient calculated by the gradient algorithm, and the image with the highest clarity is determined based on the clarity of each image in the group of images. This image with the highest clarity not only has high overall clarity, but also has small differences in clarity between its parts.

[0066] As an optional embodiment, the weighting coefficient of the clarity of the target image is calculated according to the degree of gradient position discreteness, including: calculating the degree of gradient position discreteness of each image in the group of images; calculating the weighting coefficient according to the degree of gradient position discreteness of the target image and the minimum value of the degree of gradient position discreteness of the group of images.

[0067] Calculate the weighting coefficients of the target image , using the minimum value of the discrete degree of the gradient position in the group image and the discrete degree of the gradient position of the target image, combined with the following formula for settlement: , where Di is the discrete degree of the gradient position of the target image i, min ( D ) is the minimum value of the discrete degree of gradient position in the group graph.

[0068] As an optional embodiment, the clarity of the target image is calculated based on the weighting coefficient and the total gradient, including: when the number of target pixel points reaches a preset threshold number, the product of the weighting coefficient and the total gradient is used as the clarity of the target image; when the number of target pixel points does not reach the preset threshold number, the product of the weighting coefficient and the total gradient is used as the clarity of the target image.

[0069] Considering that the overall clarity of some images is low, that is, the number of target pixels that meet the clarity requirements is low, such as Figure 6 In the dust image, only the pixels in the dust part may meet the definition requirement, and the pixels in most other areas do not meet the definition requirement. In the case where the number of target pixels is low, there is no need to calculate the discrete degree of its distribution.

[0070] Therefore, in this embodiment, when the number of target pixels reaches the preset number threshold, the product of the weighting coefficient and the total gradient is used as the clarity of the target image. When the number of target pixels does not reach the preset number threshold, the total gradient is used as the clarity of the target image. That is, the following formula:

[0071]

[0072] Where n is the number of target pixels that meet the gradient threshold, and n_threhold is the threshold of n, which is related to the image size and content and is a configurable parameter. is the heaviest clarity value, and G is the total gradient obtained using the basic gradient algorithm. is the weighting coefficient.

[0073] As an optional embodiment, the pixel gradient values ​​and the total gradient of each pixel point of the target image are calculated by a gradient algorithm, including: calculating the pixel gradient values ​​of the available pixels according to a preset method using the pixel values ​​of the pixel points adjacent to the available pixels, wherein the available pixels are the pixel points that meet the preset method for calculating the required adjacent pixel points; calculating the total gradient according to the pixel gradient values ​​of the available pixels of the target image using the calculation formula of the gradient algorithm.

[0074] The above-mentioned gradient algorithm can be a gradient algorithm already available in the relevant technology, for example, a first-order Sobel operator, a Roberts operator, a Prewitt operator, a Scharr operator, a second-order Laplacian operator, etc., all of which use the pixel values ​​of the pixel points adjacent to the pixel point to calculate the pixel gradient value of the available pixel point, and then calculate the total gradient according to the pixel gradient value of the available pixel points of the image using the calculation formula of the gradient algorithm.

[0075] The above-mentioned available pixel points are pixel points that meet the preset method to calculate the required adjacent pixel points. The above-mentioned gradient algorithm can effectively reflect the total level of the overall clarity of the image, and can also reflect the clarity of the image to a certain extent.

[0076] As an optional embodiment, a position matrix is ​​calculated based on the coordinates of the target pixel points, including: counting the number of target pixel points in the target image; when the number reaches a preset threshold, a position matrix is ​​generated based on the position coordinates of the target pixel points, wherein the number of rows of the position matrix is ​​the number of target pixel points, and the number of columns is 2.

[0077] The number of rows in the above position matrix is ​​n, the number of pixels that meet the gradient threshold, and the number of columns is 2. The number of pixels that meet the threshold also sets a threshold, and only the pixel set above the number threshold will calculate the position distribution. The position matrix P is as follows:

[0078]

[0079] In the formula, are the positions of the pixels in the image, that is, the index values ​​of the rows and columns where the pixels are located in the image matrix.

[0080] As an optional embodiment, the degree of gradient position discreteness of the target image is calculated according to the position matrix, including: calculating the corresponding covariance matrix according to the position matrix; calculating the variance features of the projection values ​​of each position in the direction of the eigenvector according to the covariance matrix, wherein the number of variance features is the same as the order of the covariance matrix; and obtaining the degree of gradient position discreteness by summing the variance features.

[0081] In this embodiment, the covariance matrix C calculated according to the position matrix P is specifically as follows.

[0082]

[0083] in, , , , n is the number of rows in the matrix P, They are The average value of .

[0084] Then calculate the eigenvalues ​​of the covariance matrix C ,have:

[0085]

[0086] Calculating the above determinant, the covariance matrix is ​​of order 2, and solving the equation yields two eigenvalues .

[0087] Calculate the degree of discreteness of the gradient position. Because the matrix elements are the positions of the gradient, the eigenvalue is the variance of the projection value of the position in the direction of the eigenvector. The larger the variance, the more discrete the position distribution. The sum of the eigenvectors can reflect the degree of discreteness of the gradient position distribution.

[0088] Assume the discrete degree of gradient position is D, then D: .

[0089] As an optional embodiment, the corresponding covariance matrix is ​​calculated according to the position matrix, including: calculating the coordinate mean according to the position coordinates of the target pixel points in the position matrix; de-centering the position matrix according to the coordinate mean to obtain a normalized matrix; and calculating the covariance matrix according to the normalized matrix.

[0090] The position matrix P is decentralized to obtain the normalized matrix X, as follows:

[0091]

[0092] In the formula, They are all the The average value of .

[0093] Then the covariance matrix of the normalized matrix X is calculated to obtain the covariance matrix C. The normalized matrix after decentralization can have higher accuracy.

[0094] It should be noted that this embodiment also provides an optional implementation, which is described in detail below.

[0095] This implementation provides a global clarity calculation method, which considers the total amount of gradients and the position distribution of gradients to solve the problem of evaluating the overall clarity of the image. This implementation is called the GGD (Global Gradient Distribution) algorithm, which comprehensively considers the distribution of gradient values ​​and gradient positions. The details are as follows:

[0096] 1. Calculate the total gradient of the image. The basic gradient algorithm is used to calculate the total gradient of the image. The pixel gradient value is the sum of the absolute values ​​of the gradients in the x and y directions. Generally speaking, the x direction is the horizontal direction of the image, and the y direction is the vertical direction of the image. Suppose the total gradient of an image is G, which is the sum of the gradients of each pixel in the image.

[0097] Considering that the gradient is the difference between the grayscale values ​​of adjacent pixels, for each image, the gradient is not calculated for an edge with a width of one pixel on the top, bottom, left and right sides of the image, and it does not affect the gradient contrast of a group of images.

[0098]

[0099] Reasons for choosing the basic gradient algorithm:

[0100] Fast speed. Compared with the sober operator to calculate the gradient, in the C++ environment, the calculation time for a single image is reduced from 500ms to 4ms, which is about 100 times faster. The focusing process of selecting the clearest image from hundreds of images is completed within 1 second.

[0101] The basic gradient algorithm is helpful for screening dusty images, and the basic gradient algorithm can also exclude some dusty images.

[0102] 2. Calculate the gradient position distribution of the image, and calculate the clarity based on the total gradient and gradient position distribution of the image. Use the PCA (Principal components analysis) algorithm to calculate the position distribution.

[0103] 1) Set the pixel gradient threshold. Only the gradients above the threshold will be calculated for the gradient position distribution. The gradient threshold is a parameter that can be set. The parameter value varies depending on the type of image. For pathological sections, the threshold can be set to 10.

[0104] 2) Calculate the position of the pixels that meet the gradient threshold in the image and obtain the position matrix P. The number of rows in the matrix is ​​the number of pixels that meet the gradient threshold, n, and the number of columns is 2. The number of pixels that meet the threshold also sets a threshold, and only the pixel sets that are higher than the number threshold will calculate the position distribution.

[0105]

[0106] in, are the positions of the pixels in the image, that is, the index values ​​of the rows and columns where the pixels are located in the image matrix.

[0107] 3) Decentralize the position matrix P to obtain the normalized matrix X.

[0108]

[0109] in, They are all the The average value of .

[0110] 4) Calculate the covariance matrix of the normalized matrix X and obtain the covariance matrix C.

[0111]

[0112]

[0113]

[0114]

[0115] Where n is the number of rows in the normalized matrix X, They are The average value of .

[0116] 5) Calculate the eigenvalues ​​of the covariance matrix C.

[0117] Let the eigenvalues ​​of matrix C be ,have:

[0118]

[0119] Calculating the above determinant, the covariance matrix is ​​of order 2, and solving the equation yields two eigenvalues .

[0120] 6) Calculate the degree of gradient position discreteness.

[0121] Because the matrix elements are the positions of the gradients, the eigenvalues ​​are the variances of the projection values ​​of the positions in the direction of the eigenvectors. The larger the variance, the more discrete the position distribution. The sum of the eigenvectors can reflect the degree of discreteness of the gradient position distribution.

[0122] Assume the discrete degree of gradient position is D, then D:

[0123]

[0124] 7) Calculate the position distribution weighting coefficient and image clarity.

[0125] For a set of images with calculated position distribution, calculate the minimum value and weighting coefficient of D, the weighting coefficient for:

[0126]

[0127] Image clarity:

[0128]

[0129] Among them, n is the number of pixels that meet the gradient threshold, and n_threhold is the threshold of n, which is related to the image size and content and is a configurable parameter.

[0130] This implementation verifies the above-mentioned GGD algorithm. Specifically, in the example, 30 groups of images taken during the focusing process of different cell tissues were found, and 6 groups had the problem of very clear parts but unclear overall. For these 6 groups of images, the current gradient-based clarity algorithm cannot correctly find the clearest image, but the GGD algorithm can find the clearest image.

[0131] Figure 4 It is the clearest image of the basic gradient algorithm. The algorithm value is 10549441, which is the highest algorithm value of clarity in the basic gradient algorithm. The corresponding GGD algorithm value is 14304371. The above basic gradient algorithm can be an algorithm for calculating the gradient of the sobel operator. Figure 5 This is the clearest image of the GGD algorithm. The value of the basic gradient algorithm is 10547250. It is not the algorithm with the highest clarity among the basic gradient algorithms. The value of the GGD algorithm is 16059069. It is obvious Figure 4 The gradient value of the cell cluster in the lower right part of the image is higher and clearer, while the cell boundaries in other parts are fuzzy. Figure 5 The boundaries of most cells in the image are relatively clear, so the GGD algorithm finds the correct clearest image.

[0132] There is also an example of dust, which is on the surface of the object being photographed, and is compared with other gradient algorithms. Figure 6 It is the clearest image of other gradient algorithms. It is a dust image, but its algorithm value of clarity is 2109767747, which is the highest. This is obviously not the image we need. Its GGD algorithm value is 4159869. Figure 7 It is the clearest image of the GGD algorithm. The values ​​of other gradient algorithms are 118873791, and the value of the GGD algorithm is 8547906. The GGD algorithm has found the correct and clearest image. The other gradient algorithms mentioned above can be basic gradient methods such as the first-order Roberts operator, Prewitt operator, Scharr operator, and the second-order Laplacian operator other than the Sobel operator in the related technology.

[0133] It should be pointed out that, in the dust example, the basic gradient algorithm can also recognize to a certain extent that the gradient of the dust image is 7275924, and the gradient of the actual image of the object being photographed is 8547906. The correct and clearest image can also be found. This is why the basic gradient algorithm is used to calculate the gradient when calculating the overall degree in the first step of this embodiment.

[0134] The design of global clarity in this implementation includes not only the total gradient of the image, but also the distribution of gradient positions, which solves the problem that the local part is very clear but the whole is not clear. The distribution of gradient positions is calculated using the PCA algorithm. The basic gradient algorithm is selected to calculate the gradient, which is not only fast, but also helps to eliminate the interference of dust images.

[0135] Compared with the image clarity algorithm in the related art, which only considers the total gradient of the image but does not consider the distribution of the gradient position, and cannot solve the problem of local clarity and overall clarity, this embodiment considers both the total gradient of the image and the distribution of the gradient position, and can comprehensively evaluate the clarity of the image. Moreover, the calculation speed is fast. The speed of calculating the total gradient of the image by the basic gradient algorithm is about 100 times that of calculating the gradient by the sober operator.

[0136] Figure 8 Schematic diagram of a data processing device for image definition according to an embodiment of the present invention. Figure 8 As shown, based on the above-mentioned image clarity data processing method provided by the embodiment of the invention, the embodiment of the invention also provides an image clarity data processing device, which is applied to the calculation of image clarity and the clarity screening of the target image in the group image. The image clarity data processing device includes: a gradient calculation module 801, a threshold screening module 802, a position matrix module 803, and a gradient position discrete degree module 804. The device is described in detail below.

[0137] A gradient calculation module 801 is used to calculate the pixel gradient value and the total gradient of each pixel point of the target image through a gradient algorithm; a threshold screening module 802 is connected to the above-mentioned gradient calculation module 801, and is used to screen the pixel points of the target image according to a preset gradient threshold, and determine that the pixel points whose pixel gradient values ​​reach the preset gradient threshold are the target pixels; a position matrix module 803 is connected to the above-mentioned threshold screening module 802, and is used to calculate the position matrix according to the coordinates of the target pixel points; a gradient position discrete degree module 804 is connected to the above-mentioned position matrix module 803, and is used to calculate the gradient position discrete degree of the target image according to the position matrix.

[0138] The above-mentioned image clarity data processing device provided by the embodiment of the invention calculates the pixel gradient value and the total gradient of each pixel point of the target image through a gradient algorithm, calculates the position matrix according to the coordinates of the target pixel points whose pixel gradient values ​​reach the preset gradient threshold, and calculates the degree of gradient position discreteness of the target image, so that the image clarity and the distribution of clarity can be characterized by combining the overall degree, thereby reflecting the overall clarity of the image, achieving the technical effect of being able to express both the overall clarity and the overall distribution of clarity.

[0139] The embodiments of the present invention also provide a non-transitory machine-readable medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to execute the method of the embodiments of the present invention.

[0140] The embodiments of the present invention further provide a computer program product, including a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to execute the method of the embodiments of the present invention.

[0141] The embodiment of the invention also provides an electronic device, comprising: at least one processor; and a memory connected to the at least one processor in communication. The memory stores a computer program that can be executed by the at least one processor, and the computer program is used to enable the electronic device to perform the method of the embodiment of the invention when executed by the at least one processor.

[0142] refer to Fig. 9 , a block diagram of an electronic device that can be used as a server or client of an embodiment of the invention will now be described, which is an example of hardware devices that can be applied to various aspects of the invention. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the invention described and / or required herein.

[0143] like Fig. 9 As shown, the electronic device includes a computing unit 901, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 902 or a computer program loaded from a storage unit 908 to a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the electronic device can also be stored. The computing unit 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0144] Multiple components in the electronic device are connected to the I / O interface 905, including: an input unit 906, an output unit 907, a storage unit 908, and a communication unit 909. The input unit 906 can be any type of device that can input information to the electronic device, and the input unit 906 can receive input digital or character information, and generate key signal input related to user settings and / or function control of the electronic device. The output unit 907 can be any type of device that can present information, and can include but is not limited to a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 908 can include but is not limited to a disk, an optical disk. The communication unit 909 allows the electronic device to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and can include but is not limited to a modem, a network card, an infrared communication device, and / or a wireless communication transceiver, such as a Bluetooth device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.

[0145] The computing unit 901 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a CPU, a graphics processing unit (GPU), various special artificial intelligence (AI) computing units, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 901 performs the various methods and processes described above. For example, in some embodiments, the method embodiments created by the present invention may be implemented as a computer program, which is tangibly contained in a machine-readable medium, such as a storage unit 908. In some embodiments, part or all of the computer program may be loaded and / or installed on an electronic device via a ROM 902 and / or a communication unit 909. In some embodiments, the computing unit 901 may be configured to perform the above-described method in any other appropriate manner (e.g., by means of firmware).

[0146] The computer program for implementing the method of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the computer program, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The computer program can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.

[0147] In the context of the present invention, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or apparatus. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable signal medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, or infrared systems, devices, or equipment, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0148] It should be noted that the term "including" and its variations used in the embodiments of the present invention are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". The modifications of "one" and "multiple" mentioned in the embodiments of the present invention are illustrative and not restrictive. Those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0149] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0150] The various steps described in the method implementation methods provided by the embodiments of the present invention can be performed in different orders and / or in parallel. In addition, the method implementation methods may include additional steps and / or omit the steps shown. The scope of protection of the present invention is not limited in this respect.

[0151] The term "embodiment" in this specification refers to specific features, structures or characteristics described in conjunction with the embodiment that can be included in at least one embodiment of the invention. The appearance of this phrase in various places in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. The various embodiments in this specification are described in a related manner, and the same and similar parts between the various embodiments refer to each other. In particular, for the device, equipment, and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts refer to the partial description of the method embodiment.

[0152] The above-described embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of protection. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all belong to the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the attached claims.

Claims

1. A method for processing image definition data, characterized in that: include: Calculate the pixel gradient value and total gradient of each pixel point of the target image through the gradient algorithm; Screening the pixel points of the target image according to a preset gradient threshold, and determining the pixel points whose pixel gradient values ​​reach the preset gradient threshold as the target pixel points; Calculate a position matrix according to the coordinates of the target pixel points; Calculate the degree of gradient position discreteness of the target image according to the position matrix; The method further includes: calculating a weighted coefficient of the clarity of the target image according to the degree of discreteness of the gradient position, wherein the target image is a single image in a group of images in which the target object is photographed at different heights; calculating the clarity of the target image according to the weighted coefficient and a total gradient calculated by the gradient algorithm; and determining an image with the highest clarity according to the clarity of each image in the group of images.

2. The method according to claim 1, characterized in that: Calculating a weighting coefficient of the target image clarity according to the degree of gradient position dispersion includes: Calculating the degree of gradient position dispersion of each image in the group of images; The weighting coefficient is calculated according to the degree of gradient position dispersion of the target image and the minimum value of the degree of gradient position dispersion in the group of images.

3. The method according to claim 1, characterized in that Calculating the definition of the target image according to the weighted coefficient and the total gradient calculated by the gradient algorithm, comprising: When the number of the target pixel points reaches a preset number threshold, the product of the weighting coefficient and the total gradient is used as the clarity of the target image; When the number of the target pixel points does not reach a preset number threshold, the total gradient is used as the clarity of the target image.

4. The method according to claim 1, characterized in that The pixel gradient value and total gradient of each pixel point of the target image are calculated by the gradient algorithm, including: Calculate the pixel gradient value of the available pixel point by using the pixel values ​​of the pixel points adjacent to the available pixel point according to a preset method, wherein the available pixel point is a pixel point that meets the preset method to calculate the required adjacent pixel point; The total gradient is calculated according to the pixel gradient values ​​of the available pixel points of the target image using the calculation formula of the gradient algorithm.

5. The method according to claim 1, characterized in that According to the coordinates of the target pixel point, a position matrix is ​​calculated, including: Counting the number of target pixels of the target image; When the number reaches a preset number threshold, the position matrix is ​​generated according to the position coordinates of the target pixel points, wherein the number of rows of the position matrix is ​​the number of the target pixel points, and the number of columns is 2.

6. The method according to claim 1, characterized in that Calculating the degree of gradient position discreteness of the target image according to the position matrix includes: According to the position matrix, calculating the corresponding covariance matrix; According to the covariance matrix, calculating the variance features of the projection values ​​of each position in the direction of the eigenvector, wherein the number of the variance features is the same as the order of the covariance matrix; The degree of discreteness of the gradient position is obtained by summing up the variance features.

7. The method according to claim 6, characterized in that According to the position matrix, the corresponding covariance matrix is ​​calculated, including: Calculate the coordinate mean according to the position coordinates of the target pixel point in the position matrix; Decentralizing the position matrix according to the coordinate mean to obtain a normalized matrix; The covariance matrix is ​​calculated based on the normalized matrix.

8. A data processing device for image clarity, characterized in that: include: A gradient calculation module is used to calculate the pixel gradient value and the total gradient of each pixel point of the target image through a gradient algorithm; A threshold screening module, used to screen the pixel points of the target image according to a preset gradient threshold, and determine the pixel points whose pixel gradient values ​​reach the preset gradient threshold as target pixel points; A position matrix module, used to calculate a position matrix according to the coordinates of the target pixel points; A gradient position discreteness module, used for calculating the gradient position discreteness of the target image according to the position matrix; The device is also used to calculate a weighted coefficient of the clarity of the target image according to the degree of discreteness of the gradient position, wherein the target image is a single image in a group of images in which the target object is photographed at different heights; calculate the clarity of the target image according to the weighted coefficient and the total gradient calculated by the gradient algorithm; and determine the image with the highest clarity according to the clarity of each image in the group of images.

9. An electronic device, comprising: A processor and a memory storing a program, wherein the program comprises instructions, which, when executed by the processor, cause the processor to perform the method according to any one of claims 1 to 7.

10. A non-transitory machine-readable medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 7.

11. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Dark channel-based scanning electron microscope image definition no-reference evaluation method

    CN108288267A

  • Image definition determination method, image definition determination device, computer readable storage medium and electronic equipment

    CN113052815A

  • Image recognition method and device and automatic sorting robot

    CN113763311A

  • Image definition evaluation method and device, computer equipment and storage medium

    CN117911338A

  • Method and device for calculating target definition value of region of interest of image and electronic equipment

    CN117952951A