A method and apparatus for determining image sharpness
By acquiring the horizontal and vertical stripe patterns of the image card during the lens module focusing process, extracting sharpness features, and performing fusion evaluation, the problem of slow manual judgment and large subjective differences in lens module focusing is solved, and efficient and accurate image sharpness evaluation is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN MICROBT ELECTRONICS TECH CO LTD
- Filing Date
- 2024-12-02
- Publication Date
- 2026-06-02
AI Technical Summary
In existing technologies, during the focusing process of a lens module, the determination of image sharpness relies on manual observation, which is slow and subject to significant subjective differences, resulting in low focusing efficiency.
By acquiring the horizontal and vertical stripe patterns in the image, the region of interest is determined, and the sharpness features are extracted using operator templates. The sharpness evaluation results in the horizontal and vertical directions are calculated and fused to achieve an objective image sharpness evaluation.
It improves the accuracy and efficiency of image sharpness determination, reduces the difference in subjective human judgment, and enhances the quality and speed of lens module focusing.
Smart Images

Figure CN122134607A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of imaging detection, and in particular, to a method for determining image sharpness. Background Technology
[0002] Camera devices are widely used in daily production and life. In order to obtain high-quality images and videos, the lens module of the camera device needs to be focused before leaving the factory, so that the focus of the lens module is adjusted to a suitable position before being fixed.
[0003] In a typical lens module focusing process, the lens module continuously acquires images from a chart for image inspection. The sharpness of a designated area within the chart image is used to determine whether the lens module has reached the appropriate focusing position. Currently, this is usually done manually, which is slow and subject to significant differences in individual subjective judgment. Summary of the Invention
[0004] This invention provides a method for determining image sharpness to improve the accuracy of image sharpness determination.
[0005] The first aspect of the present invention provides a method for determining image sharpness, the method comprising:
[0006] An image of a chart pattern for image sharpness detection is obtained. This chart image includes: a first stripe pattern parallel to the horizontal direction of the image coordinate system, and a second stripe pattern parallel to the vertical direction of the image coordinate system. At least partially adjacent and / or overlapping areas exist between the regions containing the first and second stripe patterns.
[0007] Based on the acquired map images, the region of interest, including the adjacent and / or overlapping regions, is determined.
[0008] Based on the determined region of interest, the sharpness features of the first stripe pattern and the second stripe pattern are extracted, respectively. The sharpness features are used to characterize the gradient information between the stripes in the stripe pattern.
[0009] Based on the sharpness features of the first stripe pattern, an evaluation result is determined to characterize the first sharpness in the horizontal direction of the image coordinate system. Based on the sharpness features of the second stripe pattern, an evaluation result is determined to characterize the second sharpness in the vertical direction of the image coordinate system.
[0010] The image sharpness is obtained by fusing the evaluation results of the first sharpness and the evaluation results of the second sharpness.
[0011] As a possible implementation, the step of extracting the sharpness features of the first stripe pattern and the sharpness features of the second stripe pattern based on the determined region of interest includes:
[0012] The pixel values of each pixel in the first stripe pattern image within the region of interest are convolved with a first operator template used to extract gradient information between stripes within a first set range in the first stripe pattern to obtain the sharpness features of the first stripe pattern.
[0013] The pixel values of each pixel in the second stripe pattern image in the region of interest are convolved with the second operator template used to extract gradient information between stripes within a second set range in the second stripe pattern to obtain the sharpness features of the second stripe pattern.
[0014] As a possible implementation, the first operator template is a column vector consisting of n non-zero values, or a first matrix consisting of n rows and m columns of values. This first matrix includes at least one column vector consisting of non-zero values, and the remaining column vectors in the first matrix have the same values. Here, n and m are determined according to a first predetermined range.
[0015] The second operator template is either a row vector consisting of p non-zero values, or a second matrix consisting of q rows and p columns of values. This second matrix includes at least one row vector consisting of non-zero values, and the remaining row vectors in the second matrix have the same values. Here, p and q are determined according to a second predefined range.
[0016] The non-zero values in the vector are arranged sequentially, the difference between adjacent values is equal, and the sum of all non-zero values in the vector is 0.
[0017] As a possible implementation, the first set range is the same as the second set range, the values of n, m, p, and q are equal, the values of the remaining column vectors are 0, and the values of the remaining row vectors are 0.
[0018] In the first matrix, the column vector consisting of non-zero values is located in the center column, which is the number of columns that is half the total number of columns in the first matrix, rounded up.
[0019] The row vector consisting of non-zero values in the second matrix is located in the center row of the second matrix. This center row is the row number that is half the total number of rows in the second matrix, rounded up.
[0020] As a possible implementation, the step of convolving the pixel values of each pixel in the first stripe pattern image within the region of interest with a first operator template used to extract gradient information between stripes within a first set range in the first stripe pattern includes:
[0021] For any pixel in the first stripe pattern image within the region of interest
[0022] Calculate the convolution value of the pixel value and the first operator template to obtain the sharpness feature of the pixel;
[0023] The step of performing convolution operations on the pixel values of each pixel point in the second stripe pattern image within the region of interest with a second operator template used to extract gradient information between stripes within a second set range in the second stripe pattern includes:
[0024] For any pixel in the second stripe pattern image within the region of interest
[0025] The pixel value of the pixel is calculated by convolving it with the second operator template to obtain the sharpness feature of the pixel.
[0026] As a possible implementation, determining the evaluation result for characterizing the first sharpness in the horizontal direction of the image coordinate system based on the sharpness features of the first stripe pattern includes:
[0027] Based on the sharpness features of the first stripe pattern, the variance of the sharpness features of all first stripe patterns is calculated to obtain the first sharpness score, which is used as the evaluation result of the first sharpness.
[0028] The evaluation result for determining the second sharpness in the vertical direction of the image coordinate system based on the sharpness features of the second stripe pattern includes:
[0029] Based on the sharpness features of the second stripe pattern, the variance of the sharpness features of all second stripe patterns is calculated to obtain the second sharpness score, which is used as the evaluation result of the second sharpness.
[0030] As a possible implementation, the fusion of the evaluation results for the first sharpness and the second sharpness includes:
[0031] Using weighted values, the first sharpness score and the second sharpness score are summed to obtain a fusion score, which is then used as the image sharpness.
[0032] in,
[0033] The weighting values are determined based on a fusion strategy that matches the focusing parameters of the lens module.
[0034] As a possible implementation, the weighting values are determined according to a fusion strategy that matches the focusing parameters of the lens module, including:
[0035] For any weighted value of the sharpness score, perform the following steps:
[0036] Calculate the ratio of the evaluation result to a set coefficient, and use this ratio as the exponent to calculate the exponential function value of the Euler number, thus obtaining the exponential function value of the sharpness score.
[0037] The weighted value of the sharpness score is obtained by calculating the ratio of the exponential function value of the sharpness score to the sum of the exponential function values of all sharpness scores.
[0038] When the set coefficient value is much larger than the positive value of the sharpness score, the obtained fusion score reaches the average value of all sharpness scores.
[0039] When the set coefficients are positive values approaching 0, the resulting fusion score reaches the maximum value among all sharpness scores.
[0040] When the set coefficient is a negative value approaching 0, the resulting fusion score reaches the minimum value among all sharpness scores, or
[0041] When the set coefficients are close to the sharpness score, the resulting fusion score is the weighted sum of the sharpness scores.
[0042] As a possible implementation, determining the region of interest, which includes adjacent and / or overlapping regions, based on the acquired map image, includes:
[0043] The acquired image is subjected to target detection based on the proximity of the first and second stripe patterns and / or the overlap of the first and second stripe patterns. The region of interest is determined based on the target detection results.
[0044] or,
[0045] The set image template is matched with the acquired image card, and the region of interest is determined based on the matching result. The image template includes patterns in which the first stripe pattern and the second stripe pattern are adjacent and / or overlap.
[0046] A second aspect of this application provides an image sharpness determination apparatus, the apparatus comprising:
[0047] The positioning module is used to acquire an image of a pattern card used for image sharpness detection, and based on the acquired image card image, to determine a region of interest including the adjacent and / or overlapping regions. The image card image includes: a first stripe pattern parallel to the horizontal direction of the image coordinate system, and a second stripe pattern parallel to the vertical direction of the image coordinate system. At least partially adjacent and / or overlapping regions exist between the regions containing the first and second stripe patterns.
[0048] The sharpness feature extraction module is used to extract the sharpness features of the first stripe pattern and the second stripe pattern based on the determined region of interest. The sharpness features are used to characterize the gradient information between the stripes in the stripe pattern.
[0049] The sharpness determination module is used to determine an evaluation result of the first sharpness in the horizontal direction of the image coordinate system based on the sharpness features of the first stripe pattern, and to determine an evaluation result of the second sharpness in the vertical direction of the image coordinate system based on the sharpness features of the second stripe pattern. The evaluation results of the first sharpness and the evaluation results of the second sharpness are fused to obtain the image sharpness.
[0050] A third aspect of this application provides a computer storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the methods for determining image sharpness.
[0051] The image sharpness determination method provided in this application extracts sharpness features from different patterns in the region of interest of the image card used for image sharpness detection, so that the sharpness of the pattern is accurately represented. By fusing the evaluation results of the sharpness represented by the sharpness features, the image sharpness is objectively described, which is conducive to obtaining a sharpness index that matches the result of human subjective judgment. Attached Figure Description
[0052] Figure 1 This is a flowchart illustrating a method for determining image sharpness according to an embodiment of this application.
[0053] Figure 2 This is a schematic diagram of a pattern for an embodiment of this application.
[0054] Figure 3 This is a flowchart illustrating a method for determining image sharpness in this embodiment.
[0055] Figure 4 This is a schematic diagram of a card image with horizontal and vertical stripe patterns in this embodiment.
[0056] Figure 5 This is a schematic diagram of an image sharpness determination device according to an embodiment of this application.
[0057] Figure 6 This is another schematic diagram of the image sharpness determination device according to an embodiment of this application. Detailed Implementation
[0058] To make the objectives, technical means, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings.
[0059] This application embodiment extracts the sharpness features of the image card used for image sharpness detection to obtain the sharpness evaluation result, and then fuses the obtained evaluation result to determine the image sharpness.
[0060] See Figure 1 As shown, Figure 1 This is a flowchart illustrating a method for determining image sharpness according to an embodiment of this application. The method includes:
[0061] Step 101: Obtain the image of the pattern card used for image sharpness detection.
[0062] As an example, the image includes: a first stripe pattern parallel to the horizontal direction of the image coordinate system, and a second stripe pattern parallel to the vertical direction of the image coordinate system, wherein there are at least partially adjacent and / or overlapping regions between the regions containing the first stripe pattern and the regions containing the second stripe pattern.
[0063] See Figure 2 As shown, Figure 2 This is a schematic diagram of an image card according to an embodiment of this application. The horizontal direction in the figure represents the horizontal direction of the image coordinate system, and the vertical direction represents the vertical direction of the image coordinate system. Examples of combinations of the horizontal stripe pattern (i.e., the area where the first stripe pattern is located) and the vertical stripe pattern (i.e., the area where the second stripe pattern is located) being partially adjacent, partially overlapping, completely adjacent, completely overlapping, partially adjacent, and partially overlapping are shown.
[0064] It should be understood that the size of adjacent and / or overlapping areas is sufficient to meet the requirements for determining image sharpness. The spacing between adjacent stripes and the width of the stripes themselves in the first stripe pattern can be the same as or different from the spacing between adjacent stripes and the width of the stripes themselves in the second stripe pattern.
[0065] Step 102: Based on the acquired image card, determine the region of interest that includes the adjacent and / or overlapping regions.
[0066] As an example, target detection is performed on the acquired image card, targeting the first stripe pattern as adjacent to the second stripe pattern and / or the first stripe pattern as overlapping with the second stripe pattern. The region of interest is determined based on the target detection results.
[0067] or,
[0068] The set image template is matched with the acquired image card, and the region of interest is determined based on the matching result. The image template includes patterns in which the first stripe pattern and the second stripe pattern are adjacent and / or overlap.
[0069] Step 103: Based on the determined region of interest, extract the sharpness features of the first stripe pattern and the second stripe pattern, respectively. The sharpness features are used to characterize the gradient information between the stripes in the stripe pattern.
[0070] As an example, the pixel values of each pixel in the first stripe pattern image within the region of interest are convolved with a first operator template used to extract gradient information between stripes within a first set range in the first stripe pattern to obtain the sharpness features of the first stripe pattern.
[0071] The pixel values of each pixel in the second stripe pattern image in the region of interest are convolved with the second operator template used to extract gradient information between stripes within a second set range in the second stripe pattern to obtain the sharpness features of the second stripe pattern.
[0072] in,
[0073] The first operator template is either a column vector consisting of n non-zero values, or a first matrix consisting of n rows and m columns of values. This first matrix includes at least one column vector consisting of non-zero values, and the remaining column vectors in the first matrix have the same values. Here, n and m are determined according to a first predetermined range.
[0074] The second operator template is either a row vector consisting of p non-zero values, or a second matrix consisting of q rows and p columns of values. This second matrix includes at least one row vector consisting of non-zero values, and the remaining row vectors in the second matrix have the same values. Here, p and q are determined according to a second predefined range.
[0075] The non-zero values in the vector are arranged sequentially, the difference between adjacent values is equal, and the sum of all non-zero values in the vector is 0.
[0076] As an example, the first set range is the same as the second set range, the values of n, m, p, and q are equal, the values of the remaining column vectors are 0, and the values of the remaining row vectors are 0.
[0077] In the first matrix, the column vector consisting of non-zero values is located in the center column, which is the number of columns that is half the total number of columns in the first matrix, rounded up.
[0078] In the second matrix, the row vector consisting of non-zero values is located in the center row of the second matrix. This center row is the row number obtained by rounding up half the total number of rows in the second matrix.
[0079] For example, sharpness features can characterize the gradient information between two adjacent stripes in a striped pattern.
[0080] n, m, p, and q take values of 3. The first operator template is a column vector consisting of 3 non-zero values, or a first matrix consisting of 3 rows and 3 columns of values. The values in the first column of this first matrix are the same as the values in the third column, the values in the second column are different from the values in the first column, the second column is a non-zero value, and the difference between the values in the first row of the second column and the values in the second row of the second column is equal to the difference between the values in the third row of the second column and the values in the second row of the second column. Furthermore, the sum of the 3 values in the second column is 0.
[0081] The second operator template is either a row vector consisting of three non-zero values, or a second matrix consisting of three rows and three columns of values. In this second matrix, the values in the first row are the same as those in the third row, the values in the second row are different from those in the first row, the second row contains non-zero values, and the difference between the value in the first column of the second row and the value in the second column of the second row is equal to the difference between the value in the third column of the second row and the value in the second column of the second row. Furthermore, the sum of the three values in the second row is 0.
[0082] In the column vector and row vector, the non-zero values are arranged in order, the difference between the first and second values is equal to the difference between the third and second values, and the sum of the three values is 0.
[0083] The values in the first and third columns of the first matrix are 0, and the values in the first and third rows of the second matrix are 0, which helps to reduce the resources used by convolution operations.
[0084] It should be understood that when performing convolution operations, the first operator template and the second operator template used can be the same or different.
[0085] Step 104: Based on the sharpness features of the first stripe pattern, determine the evaluation result for the first sharpness characterizing the horizontal direction of the image coordinate system; based on the sharpness features of the second stripe pattern, determine the evaluation result for the second sharpness characterizing the vertical direction of the image coordinate system.
[0086] As an example,
[0087] The first sharpness assessment result is obtained by calculating the variance of the sharpness features of all first stripe patterns.
[0088] The second sharpness assessment result was obtained by calculating the variance of the sharpness features of all second stripe patterns.
[0089] The evaluation results can be represented by a clarity score.
[0090] Step 105: The evaluation results of the first sharpness and the evaluation results of the second sharpness are fused to obtain the image sharpness.
[0091] As an example, a weighted sum is taken from the first sharpness score and the second sharpness score using weighted values to obtain a fusion score, which is used as the image sharpness. The weighted values are determined according to a fusion strategy that matches the focusing index of the lens module. The fusion strategy includes at least one of the following: the average of all sharpness scores, the maximum of all sharpness scores, the minimum of all sharpness scores, and the weighted sum of all sharpness scores.
[0092] This application embodiment extracts sharpness features corresponding to different stripe patterns in the image to characterize the gradient information between adjacent stripes, thereby obtaining the sharpness of the area where the stripe pattern is located. The sharpness features can be used to obtain the sharpness evaluation result. The sharpness evaluation result is fused as the image sharpness, so that the image sharpness can be objectively characterized, improving the accuracy of image sharpness, avoiding subjective human judgment, and helping to improve the quality and speed of lens module focusing.
[0093] To facilitate understanding of this application, the following description uses a pattern for image sharpness detection as an example. It should be understood that this application is not limited to the pattern of this embodiment.
[0094] See Figure 3 As shown, Figure 3 This is a schematic flowchart illustrating a method for determining image sharpness in this embodiment. The method includes:
[0095] Step 301: During the lens module focusing process, an image of a pattern card for image sharpness detection is acquired. This pattern card image includes: a horizontal stripe pattern in the horizontal direction of the image plane and a vertical stripe pattern in the vertical direction of the image. As an example, the stripe pattern consists of equally spaced stripes. The horizontal stripe pattern is located in a first region, and the vertical stripe pattern is located in a second region. There are some adjacent areas between the first and second regions. (See [link to previous section]). Figure 4 As shown, Figure 4 This is a schematic diagram of a card image with horizontal and vertical stripe patterns in this embodiment.
[0096] Step 302: Determine the Region of Interest (ROI) in the acquired image. The ROI includes: horizontal stripe patterns and vertical stripe patterns along the vertical direction of the image.
[0097] As an example, target detection methods such as YOLOX can be used to locate ROI regions that have both horizontal and vertical stripe patterns. For example, in this embodiment, adjacent regions of horizontal and vertical stripe patterns can be detected. Alternatively, image template matching and other methods can be used to locate ROI regions that have both horizontal and vertical stripe patterns. The image template includes image data that is the same as the adjacent region pattern in the card pattern.
[0098] For example, this embodiment uses an image template matching method to first obtain the approximate location of the ROI region, and then crop it according to a fixed ratio to obtain the precise ROI region.
[0099] See Figure 4 As shown, Figure 4 This is a schematic diagram illustrating the determination of the Region of Interest (ROI) based on the acquired image. In the diagram, the red area represents the ROI.
[0100] To improve the accuracy of image sharpness, the area containing the horizontal stripe pattern in the ROI region is the same size as the area containing the vertical stripe pattern.
[0101] Step 303: Obtain the features of the horizontal stripe pattern and the vertical stripe pattern in the ROI region respectively, so as to obtain the sharpness feature map of the horizontal stripe pattern and the sharpness feature map of the vertical stripe pattern.
[0102] As an example,
[0103] For the horizontal stripe pattern within the ROI region, the gradient information between each horizontal stripe and its adjacent horizontal stripes is calculated to serve as the sharpness feature of the horizontal stripe pattern.
[0104] For example, a first operator template for calculating gradient information between horizontal stripes is set. This template can be a column vector consisting of a first value, a second value, and a third value in sequence, wherein the difference between the first value and the second value is equal to the difference between the third value and the second value, and the sum of the three values is 0.
[0105] The first operator template can also be a 3x3 matrix, where the values in the first and third columns are the same, and the values in the second column are different from those in the first and third columns. Furthermore, in the second column, the difference between the values in the first and second rows is equal to the difference between the values in the third and second rows, and the sum of the three values in the second column is 0. To reduce computational resources, the values in the first and third columns are set to 0, and the values in the second column are non-zero.
[0106] For the vertical stripe pattern in the ROI region, the gradient information between each vertical stripe and its adjacent vertical stripes is calculated as a sharpness feature of the vertical stripe pattern.
[0107] For example, a second operator template for calculating gradient information between vertical stripes is set. This template can be a row vector composed of a first value, a second value, and a third value in sequence, wherein the difference between the first value and the second value is equal to the difference between the third value and the second value, and the sum of the three values is 0.
[0108] The second operator template can also be a 3x3 matrix, where the values in the first and third rows are the same, and the values in the second row are different from those in the first and third rows. Furthermore, in the second row, the difference between the value in the first column and the value in the second column is equal to the difference between the value in the third row and the value in the second column, and the sum of the three values in the second row is 0. To reduce computational resources, the values in the first and third rows are set to 0, and the values in the second row are non-zero.
[0109] Gradient information is calculated as follows:
[0110] For any pixel,
[0111] Using the operator template as the convolution kernel, the pixel value of the pixel is convolved with the operator template to obtain the convolution result that represents the gradient value of the pixel, which is used as the sharpness feature of the pixel.
[0112] After each pixel is convolved with the operator template, the sharpness feature map of the vertical stripe pattern and the sharpness feature map of the horizontal stripe pattern can be obtained respectively. The position of each pixel in the sharpness feature map represents the sharpness feature of that pixel. That is, the position of each pixel in the sharpness feature map of the vertical stripe pattern represents the sharpness feature of that pixel in the horizontal direction, and the position of each pixel in the sharpness feature map of the horizontal stripe pattern represents the sharpness feature of that pixel in the vertical direction.
[0113] To improve the accuracy of image sharpness, the operator templates used for calculating gradient information of horizontal and vertical stripe patterns have the same value and shape. For example, both can use vector-based operator templates or matrix-based operator templates.
[0114] Step 303: Based on the sharpness feature map of the horizontal stripe pattern and the sharpness feature map of the vertical stripe pattern, determine the sharpness evaluation results in the horizontal direction and the sharpness evaluation results in the vertical direction, respectively.
[0115] As an example, the sharpness assessment results are determined in the following manner:
[0116] Based on the sharpness feature map, the variance of the sharpness features of all pixels is calculated to obtain the sharpness score, which serves as the sharpness evaluation result. The mathematical expression is as follows:
[0117]
[0118] Where, σ 2 The variance of the eigenvalues, i.e., the sharpness score, is represented by x. i Let μ represent the sharpness feature of pixel i, μ be the average sharpness feature of all pixels, and N be the total number of pixels included in the sharpness feature map.
[0119] Step 304: The sharpness assessment results in the horizontal direction and the sharpness assessment results in the vertical direction are fused so that the fused assessment results can be used to characterize the image sharpness.
[0120] To obtain the final sharpness metric, the sharpness scores are merged.
[0121] Since different lens modules require different image sharpness levels for focusing based on actual needs, different sharpness score fusion strategies are employed. In this embodiment, the sharpness evaluation results in the horizontal direction and the sharpness evaluation results in the vertical direction are weighted and fused. The weighting coefficient is determined according to the different required sharpness levels, so as to achieve a sharpness score fusion effect with maximum, minimum, average, weighted, etc.
[0122] For example, the fusion of sharpness assessment results can be represented as:
[0123] P = c1*w1 + c2*w2
[0124] Where P is the sharpness fusion score, c1 and c2 are the sharpness evaluation results, and w1 and w2 are the weighted values.
[0125] The weighted values can be determined as follows:
[0126] For any sharpness score, the weighted value,
[0127] Calculate the ratio of the sharpness score to a set coefficient, and then use this ratio as an exponent to calculate the exponential function value of the Euler number, thus obtaining the exponential function value of the sharpness score.
[0128] The weighted value of the sharpness score is obtained by calculating the ratio of the exponential function value of the sharpness score to the sum of the exponential function values of all sharpness scores.
[0129] Expressed mathematically as follows:
[0130]
[0131] In the formula, T is the coefficient and e is the Euler number.
[0132] When T is much larger than a positive value of the sharpness score, the obtained fusion score reaches the average of the two sharpness scores.
[0133] When T is a positive value close to 0, the obtained fusion score reaches the maximum value of the two sharpness scores.
[0134] When T takes a negative value close to 0, the obtained fusion score reaches the minimum value of the two sharpness scores.
[0135] When T approaches a certain sharpness score, the resulting fusion score is the weighted sum of the two sharpness scores.
[0136] In this way, different sharpness score fusion effects can be achieved simply by adjusting the values of the coefficients, based on the focusing requirements of different lens modules. This improves the consistency between sharpness indicators and human judgment, and enhances the quality and speed of lens module focusing.
[0137] Step 306: Adjust the focus of the lens module according to the image sharpness.
[0138] See Figure 5 As shown, Figure 5 This is a schematic diagram of an image sharpness determination device according to an embodiment of this application. The device includes:
[0139] The positioning module is used to acquire an image of a patterned chart for image sharpness detection, and based on the acquired chart image, to determine a region of interest including the adjacent and / or overlapping regions. The chart image includes: a first stripe pattern parallel to the horizontal direction of the image coordinate system, and a second stripe pattern parallel to the vertical direction of the image coordinate system. At least partially adjacent and / or overlapping regions exist between the regions containing the first and second stripe patterns.
[0140] The sharpness feature extraction module is used to extract the sharpness features of the first stripe pattern and the second stripe pattern based on the determined region of interest.
[0141] The sharpness determination module is used to determine an evaluation result of the first sharpness in the horizontal direction of the image coordinate system based on the sharpness features of the first stripe pattern, and to determine an evaluation result of the second sharpness in the vertical direction of the image coordinate system based on the sharpness features of the second stripe pattern. The evaluation results of the first sharpness and the evaluation results of the second sharpness are fused to obtain the image sharpness.
[0142] See Figure 6 As shown, Figure 6This is another schematic diagram of an image sharpness determination apparatus according to an embodiment of this application. The apparatus includes a memory and a processor. The memory stores a computer program, and the processor is configured to execute the computer program to implement the steps of the image sharpness determination method described in this embodiment of the application.
[0143] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0144] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0145] This invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the image sharpness determination method described in this application.
[0146] For the device / network-side equipment / storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and relevant parts can be referred to in the description of the method embodiments.
[0147] In this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, without necessarily requiring or implying any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0148] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for determining image sharpness, characterized in that, The method includes: An image of a chart pattern for image sharpness detection is obtained. This chart image includes: a first stripe pattern parallel to the horizontal direction of the image coordinate system, and a second stripe pattern parallel to the vertical direction of the image coordinate system. At least partially adjacent and / or overlapping areas exist between the regions containing the first and second stripe patterns. Based on the acquired map images, the region of interest, including the adjacent and / or overlapping regions, is determined. Based on the determined region of interest, the sharpness features of the first stripe pattern and the second stripe pattern are extracted, respectively. The sharpness features are used to characterize the gradient information between the stripes in the stripe pattern. Based on the sharpness features of the first stripe pattern, an evaluation result is determined to characterize the first sharpness in the horizontal direction of the image coordinate system. Based on the sharpness features of the second stripe pattern, an evaluation result is determined to characterize the second sharpness in the vertical direction of the image coordinate system. The image sharpness is obtained by fusing the evaluation results of the first sharpness and the evaluation results of the second sharpness.
2. The determination method according to claim 1, characterized in that, The step of extracting the sharpness features of the first stripe pattern and the second stripe pattern based on the determined region of interest includes: The pixel values of each pixel in the first stripe pattern image within the region of interest are convolved with a first operator template used to extract gradient information between stripes within a first set range in the first stripe pattern to obtain the sharpness features of the first stripe pattern. The pixel values of each pixel in the second stripe pattern image in the region of interest are convolved with the second operator template used to extract gradient information between stripes within a second set range in the second stripe pattern to obtain the sharpness features of the second stripe pattern.
3. The determination method according to claim 2, characterized in that, The first operator template is either a column vector consisting of n non-zero values, or a first matrix consisting of n rows and m columns of values. This first matrix includes at least one column vector consisting of non-zero values, and the remaining column vectors in the first matrix have the same values. Here, n and m are determined according to a first predetermined range. The second operator template is either a row vector consisting of p non-zero values, or a second matrix consisting of q rows and p columns of values. This second matrix includes at least one row vector consisting of non-zero values, and the remaining row vectors in the second matrix have the same values. Here, p and q are determined according to a second predefined range. in, The non-zero values in the vector are arranged sequentially, the difference between adjacent values is equal, and the sum of all non-zero values in the vector is 0.
4. The determination method according to claim 3, characterized in that, The first set range is the same as the second set range, the values of n, m, p, and q are equal, the values of the remaining column vectors are 0, and the values of the remaining row vectors are 0. In the first matrix, the column vector consisting of non-zero values is located in the center column, which is the number of columns that is half the total number of columns in the first matrix, rounded up. The row vector consisting of non-zero values in the second matrix is located in the center row of the second matrix. This center row is the row number that is half the total number of rows in the second matrix, rounded up.
5. The determination method according to claim 1, characterized in that, The step of performing convolution operations on the pixel values of each pixel point of the first stripe pattern image in the region of interest with a first operator template used to extract gradient information between stripes within a first set range in the first stripe pattern includes: For any pixel in the first stripe pattern image within the region of interest Calculate the convolution value of the pixel value and the first operator template to obtain the sharpness feature of the pixel; The step of performing convolution operations on the pixel values of each pixel point in the second stripe pattern image within the region of interest with a second operator template used to extract gradient information between stripes within a second set range in the second stripe pattern includes: For any pixel in the second stripe pattern image within the region of interest The pixel value of the pixel is calculated by convolving it with the second operator template to obtain the sharpness feature of the pixel.
6. The determination method according to claim 1, characterized in that, The evaluation result for determining the first sharpness in the horizontal direction of the image coordinate system based on the sharpness features of the first stripe pattern includes: Based on the sharpness features of the first stripe pattern, the variance of the sharpness features of all first stripe patterns is calculated to obtain the first sharpness score, which is used as the evaluation result of the first sharpness. The evaluation result for determining the second sharpness in the vertical direction of the image coordinate system based on the sharpness features of the second stripe pattern includes: Based on the sharpness features of the second stripe pattern, the variance of the sharpness features of all second stripe patterns is calculated to obtain the second sharpness score, which is used as the evaluation result of the second sharpness.
7. The determination method according to claim 6, characterized in that, The fusion of the evaluation results for the first sharpness and the evaluation results for the second sharpness includes: Using weighted values, the first sharpness score and the second sharpness score are summed to obtain a fusion score, which is then used as the image sharpness. in, The weighting values are determined based on a fusion strategy that matches the focusing parameters of the lens module.
8. The determination method according to claim 4, characterized in that, The weighting values are determined based on a fusion strategy that matches the focusing parameters of the lens module, including: For any weighted value of the sharpness score, perform the following steps: Calculate the ratio of the evaluation result to a set coefficient, and use this ratio as the exponent to calculate the exponential function value of the Euler number, thus obtaining the exponential function value of the sharpness score. The weighted value of the sharpness score is obtained by calculating the ratio of the exponential function value of the sharpness score to the sum of the exponential function values of all sharpness scores. When the set coefficient value is much larger than the positive value of the sharpness score, the obtained fusion score reaches the average value of all sharpness scores. When the set coefficients are positive values approaching 0, the resulting fusion score reaches the maximum value among all sharpness scores. When the set coefficient is a negative value approaching 0, the resulting fusion score reaches the minimum value among all sharpness scores, or When the set coefficients are close to the sharpness score, the resulting fusion score is the weighted sum of the sharpness scores.
9. The determination method according to claim 1, characterized in that, The determination of the region of interest, which includes adjacent and / or overlapping regions, based on the acquired map image, includes: The acquired image is subjected to target detection based on the proximity of the first and second stripe patterns and / or the overlap of the first and second stripe patterns. The region of interest is determined based on the target detection results. or, The set image template is matched with the acquired image card, and the region of interest is determined based on the matching result. The image template includes patterns in which the first stripe pattern and the second stripe pattern are adjacent and / or overlap.
10. An apparatus for determining image sharpness, characterized in that, The device includes: The positioning module is used to acquire an image of a pattern card used for image sharpness detection, and based on the acquired image card image, to determine a region of interest including the adjacent and / or overlapping regions. The image card image includes: a first stripe pattern parallel to the horizontal direction of the image coordinate system, and a second stripe pattern parallel to the vertical direction of the image coordinate system. At least partially adjacent and / or overlapping regions exist between the regions containing the first and second stripe patterns. The sharpness feature extraction module is used to extract the sharpness features of the first stripe pattern and the second stripe pattern based on the determined region of interest. The sharpness features are used to characterize the gradient information between the stripes in the stripe pattern. The sharpness determination module is used to determine an evaluation result of the first sharpness in the horizontal direction of the image coordinate system based on the sharpness features of the first stripe pattern, and to determine an evaluation result of the second sharpness in the vertical direction of the image coordinate system based on the sharpness features of the second stripe pattern. The evaluation results of the first sharpness and the evaluation results of the second sharpness are fused to obtain the image sharpness.
11. A computer storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for determining image sharpness as described in any one of claims 1 to 9.