Image definition evaluation method, device and equipment
By dividing the image into sub-regions and dynamically filtering the effective regions, and replacing the evaluation values of invalid regions with the mean, the problem of edge misjudgment in traditional methods is solved, achieving a more stable image sharpness evaluation and improving the robustness and accuracy of the autofocus system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-11
- Publication Date
- 2026-03-17
AI Technical Summary
Traditional image sharpness evaluation methods suffer from misjudgments due to edge regions during continuous autofocus, affecting the robustness and accuracy of the system.
The original image is divided into multiple sub-regions, and the sharpness evaluation value of each sub-region is calculated. Valid and invalid regions are filtered out, and the evaluation value of the invalid regions is replaced with the mean value of the valid regions. The overall sharpness evaluation value is then calculated.
This improves the robustness and accuracy of the autofocus system, reduces misjudgments caused by changes in sample position, and increases production efficiency.
Smart Images

Figure CN121691908A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of industrial focusing technology, and in particular to an image sharpness evaluation method, apparatus and equipment. Background Technology
[0002] With the rapid development of industrial automation and machine vision technologies, autofocus technology has been widely applied in fields such as intelligent manufacturing, quality inspection, and precision measurement. Especially on automated production lines, camera systems need to quickly and accurately complete focusing operations during high-speed operation to ensure the acquisition of clear images for subsequent analysis and judgment. Autofocus methods in related technologies typically employ a focus evaluation function-based approach. This involves adjusting the lens position to scan images at different focal lengths and using the evaluation function to calculate a sharpness score at each position. When the score reaches a preset threshold, focusing is considered successful, and the current parameters are locked.
[0003] Commonly used focus evaluation functions include the Vollath function and the Brenner gradient function. These methods mainly rely on the degree of change in pixel grayscale in the image to reflect sharpness. They have the advantages of simple calculation and fast response, and are therefore widely used in industrial camera systems. In practical applications, the equipment is often in a continuous feeding state, with the material to be tested passing through the shooting area sequentially. The system needs to independently complete focusing and imaging for each incoming material. However, when the same sample appears repeatedly, if the edge area of the material enters the imaging field of view, the large abrupt change in pixel distribution at the edge will cause the output value of the focus evaluation function to rise abnormally or fluctuate. This may cause the camera system to misjudge that a sharp state has been reached and terminate the focusing process prematurely. Conversely, local feature interference may cause the sharpness score to fail to effectively exceed the set threshold, resulting in incorrect feedback of focus failure, affecting the overall detection efficiency and stability. Summary of the Invention
[0004] The purpose of this application is to provide an image sharpness evaluation method, apparatus, and device to solve the problem of misjudgment caused by edges in traditional image sharpness evaluation methods during continuous autofocus.
[0005] In a first aspect, embodiments of this application provide an image sharpness evaluation method, the method comprising: obtaining sharpness evaluation values for multiple sub-regions in an original image; filtering out valid and invalid sub-regions from the multiple sub-regions based on the sharpness evaluation values of the multiple sub-regions; determining sharpness correction values based on the sharpness of the valid sub-regions; replacing the sharpness evaluation values of all invalid sub-regions with the sharpness correction values; and determining the overall sharpness evaluation value of the original image based on the sharpness evaluation values of the valid sub-regions and the sharpness correction values of the replaced invalid sub-regions.
[0006] The image sharpness evaluation method provided in this application divides the original image into multiple sub-regions and calculates the sharpness evaluation value for each. Then, based on the evaluation values of all regions, a filtering threshold is dynamically determined to distinguish between valid sub-regions containing effective image information and invalid sub-regions containing invalid information such as edges and defects. The average evaluation value of the valid sub-regions is calculated as the sharpness correction value, which replaces the original low score of the invalid sub-regions. Finally, the overall image score is calculated comprehensively. This image sharpness evaluation method abandons the direct accumulation of low scores in invalid regions in traditional algorithms. Instead, it uses a value representing the typical level of the sharp part of the image, thus significantly reducing the negative impact of invalid regions on the overall score. For the same sharp focus surface, regardless of whether the sample is located in the center or at the edge of the field of view, the calculated final image score is closer and more stable. This allows for judgment based on a more stable score threshold during continuous autofocus, greatly reducing misjudgments caused by changes in sample position and improving the robustness, accuracy, and production efficiency of the autofocus system.
[0007] One possible implementation involves obtaining sharpness evaluation values for multiple sub-regions in an original image, including: dividing the original image into multiple sub-regions of a preset size; for any target sub-region among the multiple sub-regions, obtaining the grayscale value differences of multiple sets of pixel pairs within the target sub-region. Each pixel pair includes a first pixel and a second pixel. The first pixel and the second pixel are separated by a preset distance. Based on the grayscale value differences of the multiple sets of pixel pairs, a sharpness evaluation value for the target sub-region is determined.
[0008] One possible implementation involves determining the sharpness evaluation value of a target sub-region based on the grayscale value differences between multiple sets of pixel pairs. This includes: calculating the square of the grayscale value difference for each set of pixel pairs; and summing the squares of the grayscale value differences for all pixel pairs to obtain the sharpness evaluation value of the target sub-region.
[0009] One possible implementation involves filtering valid and invalid sub-regions based on sharpness evaluation values of multiple sub-regions, including: determining a first statistical value based on the sharpness evaluation values of the multiple sub-regions; determining a filtering threshold for the multiple sub-regions based on the first statistical value; comparing the sharpness evaluation values of the multiple sub-regions with the filtering thresholds; determining a valid sub-region if the sharpness evaluation value of a sub-region is greater than or equal to the filtering threshold; and / or determining an invalid sub-region if the sharpness evaluation value of a sub-region is less than the filtering threshold.
[0010] One possible implementation involves determining a sharpness correction value based on the sharpness of the effective sub-regions, including: calculating the average sharpness evaluation value of all effective sub-regions to obtain the sharpness correction value.
[0011] One possible implementation involves determining the overall sharpness evaluation value of the original image based on the sharpness evaluation values of the effective sub-regions and the sharpness correction values of the replaced invalid sub-regions. This includes calculating the sum of the sharpness evaluation values of all effective sub-regions and the sharpness correction values of all replaced invalid sub-regions to obtain the overall sharpness evaluation value.
[0012] One possible implementation, the image sharpness evaluation method provided in this application embodiment, further includes: comparing the overall sharpness evaluation value of the original image with a preset focus success threshold. Based on the comparison result, it is determined whether the original image has been successfully focused.
[0013] Secondly, embodiments of this application provide an image sharpness evaluation device, which includes: an acquisition module, a filtering module, a determination module, and a final determination module.
[0014] The acquisition module is used to acquire the sharpness evaluation values of multiple sub-regions in the original image.
[0015] The filtering module is used to filter out valid and invalid sub-regions from multiple sub-regions based on the sharpness evaluation values of multiple sub-regions.
[0016] The determination module is used to determine the sharpness correction value based on the sharpness of the effective sub-regions.
[0017] The replacement module is used to replace the sharpness evaluation values of all invalid sub-regions with sharpness correction values.
[0018] The determination module is also used to determine the overall sharpness evaluation value of the original image based on the sharpness evaluation value of the effective sub-regions and the sharpness correction value of the replaced invalid sub-regions.
[0019] One possible implementation involves an acquisition module that divides the original image into multiple sub-regions of a preset size. For any target sub-region, the module acquires the grayscale differences between multiple sets of pixel pairs within that sub-region. Each pixel pair includes a first pixel and a second pixel. The first pixel and the second pixel are spaced at a preset distance. Based on the grayscale differences between the multiple sets of pixel pairs, a sharpness evaluation value for the target sub-region is determined.
[0020] One possible implementation involves determining a module specifically used to calculate the square of the grayscale difference for each pair of pixels. The squares of the grayscale differences for all pixel pairs are then summed to obtain the sharpness evaluation value for the target sub-region.
[0021] One possible implementation involves a filtering module, specifically used to determine a first statistical value based on the sharpness evaluation values of multiple sub-regions. Based on the first statistical value, filtering thresholds for the multiple sub-regions are determined. The sharpness evaluation values of each sub-region are compared with the filtering thresholds. If the sharpness evaluation value of a sub-region is greater than or equal to the filtering threshold, the corresponding sub-region is determined as a valid sub-region. And / or, if the sharpness evaluation value of a sub-region is less than the filtering threshold, the corresponding sub-region is determined as an invalid sub-region.
[0022] One possible implementation involves determining a module specifically used to calculate the average sharpness evaluation value of all valid sub-regions to obtain a sharpness correction value.
[0023] One possible implementation involves determining a module specifically used to calculate the sharpness evaluation value of all valid sub-regions and the sum of the sharpness correction values of all replaced invalid sub-regions, to obtain the overall sharpness evaluation value.
[0024] One possible implementation, as provided in this application embodiment, is to compare the overall sharpness evaluation value of the original image with a preset focus success threshold. Based on the comparison result, it is determined whether the original image has been successfully focused.
[0025] Thirdly, embodiments of this application provide an image sharpness evaluation device that has the function of implementing the image sharpness evaluation method of the first aspect or any possible implementation thereof. This function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above-described function.
[0026] Fourthly, embodiments of this application provide a computer-readable storage medium storing instructions that, when executed on a computer, enable the computer to perform the image sharpness evaluation method described in the first aspect or any possible implementation thereof.
[0027] Fifthly, embodiments of this application provide a computer program product containing instructions that, when run on a computer, enable the computer to execute the image sharpness evaluation method described in the first aspect or any possible implementation thereof.
[0028] The technical effects of any of the design methods in aspects two through five can be found in aspect one or in different possible implementations of aspect one, and will not be repeated here. Attached Figure Description
[0029] To more clearly illustrate the technical solutions in the specific embodiments of this application or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0030] Figure 1 A comparison diagram of the central and edge regions of a sample provided in this application embodiment. Figure 2 A system architecture diagram of an autofocus system provided in this application embodiment; Figure 3 A flowchart illustrating an image sharpness evaluation method provided in this application embodiment; Figure 4 A schematic diagram of an image sharpness evaluation device provided in an embodiment of this application; Figure 5 This is a system architecture diagram of an image sharpness evaluation system provided in an embodiment of this application. Detailed Implementation
[0031] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0032] Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0033] In autofocus systems, image sharpness evaluation algorithms play a crucial role, as the accuracy of their evaluation results directly affects focusing precision and the reliability of image selection. Commonly used sharpness evaluation algorithms, such as Vollath and Brenner, characterize image sharpness by calculating the degree of change in pixel grayscale values and output an image score to determine whether focusing was successful.
[0034] However, in actual continuous autofocus processes, such as industrial visual inspection, microscope imaging, or continuous camera shooting, the sample under test may not always be completely centered in the field of view. Figure 1As shown, Figure 1 The image shows a comparison between the central and edge regions of a mobile phone screen. Figure 1 In (a), the entire sample is within the field of view, and the image only shows the central area of the mobile phone screen. Figure 1 In (b), the sample portion is within the field of view. When the sample edge appears in the field of view, the image contains large areas of textureless black or low-contrast regions. Traditional sharpness evaluation algorithms perform global calculations on the entire image. These textureless regions significantly lower the overall image score, causing the score to fall below the preset focus success threshold even if the sharp image is in focus. Consequently, the system misjudges this as a focus failure, generating false alarms. This score instability caused by image edges or incomplete areas reduces the robustness and reliability of continuous autofocus systems.
[0035] Based on this, embodiments of this application provide an image sharpness evaluation method, apparatus, and device. The method includes obtaining sharpness evaluation values for multiple sub-regions in an original image. Based on the sharpness evaluation values of the multiple sub-regions, valid and invalid sub-regions are selected from the multiple sub-regions. Based on the sharpness of the valid sub-regions, sharpness correction values are determined. The sharpness evaluation values of all invalid sub-regions are replaced with the sharpness correction values. Based on the sharpness evaluation values of the valid sub-regions and the sharpness correction values of the replaced invalid sub-regions, the overall sharpness evaluation value of the original image is determined.
[0036] The image sharpness evaluation method provided in this application divides the original image into multiple sub-regions and calculates the sharpness evaluation value for each. Then, based on the evaluation values of all regions, a filtering threshold is dynamically determined to distinguish between valid sub-regions containing effective image information and invalid sub-regions containing invalid information such as edges and defects. The average evaluation value of the valid sub-regions is calculated as the sharpness correction value, which replaces the original low score of the invalid sub-regions. Finally, the overall image score is calculated comprehensively. This image sharpness evaluation method abandons the direct accumulation of low scores in invalid regions in traditional algorithms. Instead, it uses a value representing the typical level of the sharp part of the image, thus significantly reducing the negative impact of invalid regions on the overall score. For the same sharp focus surface, regardless of whether the sample is located in the center or at the edge of the field of view, the calculated final image score is closer and more stable. This allows for judgment based on a more stable score threshold during continuous autofocus, greatly reducing misjudgments caused by changes in sample position and improving the robustness, accuracy, and production efficiency of the autofocus system.
[0037] The methods provided in the embodiments of this application will now be described in conjunction with the specific accompanying drawings.
[0038] On one hand, embodiments of this application provide an autofocus system. For example... Figure 2 As shown, the autofocus system 200 may include: a carrier module 201, a lens module 202, an image processing module 203, and a focus control module 204.
[0039] The carrier module 201 is used to carry and transport the object to be inspected. For example, the carrier module 201 can be a conveyor belt. In a continuous production process, the conveyor belt carries at least one material to be inspected, such as a mobile phone screen, precision components, packaging boxes, etc. The conveyor belt moves continuously in a set direction, transporting the materials sequentially to designated inspection stations. The conveyor belt itself typically has a single, low-texture surface (such as black or gray rubber or a metallic surface), which differs significantly in texture and contrast from the surface texture of the material.
[0040] Lens module 202, positioned above or to the side of the inspection station, is used to acquire raw images of the material to be inspected within its field of view. Lens module 202 may include an industrial camera and its optical lens, and may include built-in or external lighting units (such as ring light sources, coaxial light sources, etc.) to ensure image quality. Because the material may not be perfectly centered on the carrier module 201, or the material itself may be smaller than the camera's field of view, a single frame of raw image acquired by lens module 202 may simultaneously contain two parts: the first part is the effective image area, i.e., the clearly presented material to be inspected itself; the second part is the ineffective image area, i.e., the surface of carrier module 201 or other background not covered by the material. The ineffective image area typically appears as a large area of a single color or extremely low texture, and its image features (such as pixel gradients) differ somewhat from the material area.
[0041] The image processing module 203 is communicatively connected to the lens module 202. The image processing module 203 receives the original image acquired by the lens module 202 and, by executing the image sharpness evaluation method provided in this embodiment, divides the original image into multiple sub-regions; calculates the sharpness evaluation value of each sub-region; dynamically determines a filtering threshold based on the evaluation values of all sub-regions to distinguish between valid sub-regions corresponding to materials and invalid sub-regions corresponding to the background; calculates the average of the evaluation values of the valid sub-regions as a sharpness correction value; replaces the evaluation values of the invalid sub-regions with this sharpness correction value; and finally, calculates the overall sharpness evaluation value (i.e., the final image score) of the original image frame based on the replaced evaluation values of all sub-regions.
[0042] During this process, even if the image contains a large amount of conveyor belt background, its impact on the final score of the frame image is greatly suppressed, so that when the material part is in sharp focus, the calculated final image score tends to be stable regardless of whether it is located in the center or at the edge of the field of view.
[0043] The focus control module 204 is communicatively connected to the lens module 202 and the image processing module 203. The focus control module 204 receives the overall sharpness evaluation value output by the image processing module 203; compares the evaluation value with a preset focus success threshold to determine whether the current frame image has been successfully focused; and generates focus control commands based on the comparison result.
[0044] It should be noted that the above Figure 2 The illustrated autofocus system 200 is merely an example of the application scenario of the solution in this application and is not intended to limit the application scenario of the solution in this application.
[0045] On the one hand, embodiments of this application provide an image sharpness evaluation method, which can be performed by... Figure 1 The autofocus system 200 shown is activated. For example... Figure 3 As shown, the method may include the following steps.
[0046] S301, Obtain the sharpness evaluation values of multiple sub-regions in the original image.
[0047] One possible implementation involves dividing the original image into multiple sub-regions of a preset size. For any target sub-region, the grayscale differences between multiple sets of pixel pairs within that sub-region are obtained. Each pixel pair includes a first pixel and a second pixel. The first pixel and the second pixel are spaced at a preset distance. Based on the grayscale differences between the multiple sets of pixel pairs, a sharpness evaluation value for the target sub-region is determined.
[0048] Specifically, the original image is first preprocessed to convert it to grayscale. Then, the preprocessed image is evenly divided into multiple sub-regions of a preset size. This preset size is a configurable parameter that requires a trade-off between computational precision and efficiency. For example, the image can be divided into 36 identical rectangular sub-regions (6 rows x 6 columns). This division ensures that each sub-region has enough pixels for stable statistical calculations, while avoiding being too coarse to effectively distinguish detailed areas in the image.
[0049] For any defined target sub-region, the sharpness evaluation value of the target sub-region is calculated based on the gray-level gradient.
[0050] One possible implementation, based on the grayscale differences of multiple pixel pairs, involves determining the sharpness evaluation value of a target sub-region. This step may include: calculating the square of the grayscale difference for each pixel pair; and summing the squares of the grayscale differences for all pixel pairs to obtain the sharpness evaluation value of the target sub-region.
[0051] Specifically, within any target sub-region, multiple sets of pixel pairs are defined. Each pixel pair includes a first pixel and a second pixel, which are spatially separated by a preset distance (e.g., 2 pixels horizontally). By traversing all pixel positions within the sub-region that satisfy this distance constraint, the difference in grayscale values between the two pixels in each pixel pair is calculated, resulting in a set of grayscale difference values. This grayscale difference value directly reflects the local grayscale changes of the original image within that sub-region.
[0052] Then, calculate the square of the grayscale difference corresponding to each pair of pixels. Finally, sum the squares of the grayscale differences for all pairs of pixels.
[0053] For example, when the sharpness evaluation algorithm for each region uses Brenner, the sharpness evaluation value of a sub-region can be determined by the following formula.
[0054]
[0055]
[0056] in, This is used to represent the set of sharpness evaluation values for each sub-region in the original. The sharpness score for the nth region. gray represents the grayscale image of the original image, and the size of the original image is [size missing]. The size of the region block is , For pixel coordinates, The range is .
[0057] S302, based on the sharpness evaluation values of multiple sub-regions, filters out valid and invalid sub-regions from multiple sub-regions.
[0058] Specifically, based on the sharpness evaluation values of multiple sub-regions, valid and invalid sub-regions are selected from these sub-regions. This includes: determining a first statistical value based on the sharpness evaluation values of multiple sub-regions; determining a selection threshold for multiple sub-regions based on the first statistical value; and comparing the sharpness evaluation values of each sub-region with the selection threshold.
[0059] One possible implementation is to determine the corresponding sub-region as a valid sub-region if the sharpness evaluation value of the determined sub-region is greater than or equal to the screening threshold.
[0060] Another possible implementation is to determine the corresponding sub-region as an invalid sub-region if the sharpness evaluation value of the determined sub-region is less than the screening threshold.
[0061] For example, the sharpness evaluation values of multiple sub-regions are first averaged to obtain a first statistical value representing the initial sharpness level of the original image. This first statistical value is the arithmetic mean (mean1) of the sharpness evaluation values of all sub-regions.
[0062] When the original image is divided into 36 sub-regions
[0063] Here, mean1 is the first statistical value.
[0064] Then, based on this first statistical value, a filtering threshold (th) is determined to separate the valid / invalid regions. For example, the filtering threshold can be half of the first statistical value, i.e.:
[0065] in, This is the filtering threshold.
[0066] This process sets the filtering threshold to half the average sharpness evaluation value of all sub-regions in the original image, allowing the threshold to dynamically change with the image content. When the image is generally sharp (large material proportion or good focus), mean1 is higher, and th is correspondingly increased, making the filtering criteria more stringent. When the image is generally blurry or the background proportion is large, mean1 is lower, and th is also reduced, avoiding misjudging some blurry valid areas as invalid. This effectively filters out scores for black areas without image (the evaluation values of these areas are usually much lower than mean1 / 2), while avoiding incorrectly filtering out scores for some valid areas when the overall image is sharp (because the evaluation values of these valid areas are usually significantly higher than mean1 / 2).
[0067] Furthermore, after determining the filtering threshold th, the sharpness evaluation value of each sub-region is compared with the filtering threshold th.
[0068] If the clarity evaluation value of the determined sub-region is greater than or equal to the screening threshold (i.e.) In the case of [missing information], the corresponding sub-region is determined as the effective sub-region. This effective sub-region typically corresponds to the part of the material to be detected in the image that has rich texture and clear edges.
[0069] When the clarity evaluation value of the determined sub-region is less than the screening threshold (i.e.) In the case of [missing information], the corresponding sub-region is determined to be an invalid sub-region. This invalid sub-region typically corresponds to a flat grayscale, detail-lacking conveyor belt background or other informationless areas in the image.
[0070] For example, the original image yields scores for 36 sub-regions, with a mean of 100. The filtering threshold th = 100 / 2 = 50. All regions with scores greater than or equal to 50 (e.g., regions with scores of 80, 120, and 65) will be marked as valid sub-regions; all regions with scores less than 50 (e.g., regions with scores of 5, 15, and 30) will be marked as invalid sub-regions.
[0071] S303, Determine the sharpness correction value based on the sharpness of the effective sub-region.
[0072] One possible implementation involves determining a sharpness correction value based on the sharpness of the effective sub-regions, including: calculating the average sharpness evaluation value of all effective sub-regions to obtain the sharpness correction value.
[0073] Specifically, after dividing the sub-regions of the original image into valid sub-regions and invalid sub-regions, the arithmetic mean of the sharpness evaluation values of all valid sub-regions is calculated using the following formula: mean2.
[0074]
[0075]
[0076]
[0077] Where rn is the validity marker of the nth valid region. The effective fraction used to represent the effective region of the nth region. is the score for the nth sub-region. mean2 is the sharpness correction value.
[0078] For example, the filtering threshold of the original image is th = 100 / 2 = 50. 20 sub-regions are identified as valid sub-regions, and the sum of the sharpness evaluation values of these valid sub-regions is 2000. Therefore, the sharpness correction value mean2 = 2000 / 20 = 100.
[0079] S304, replace the sharpness evaluation values of all invalid sub-regions with sharpness correction values.
[0080] Specifically, for any invalid sub-region, the sharpness evaluation value of that sub-region is replaced with the sharpness correction value mean2. Meanwhile, for any valid sub-region, its original sharpness evaluation value is retained. The process remains unchanged. This replacement can be determined using the following formula.
[0081]
[0082] in, Used to represent the sharpness evaluation value of the nth sub-region after the replacement operation.
[0083] S305, Based on the sharpness evaluation value of the effective sub-region and the sharpness correction value of the replaced invalid sub-region, determine the overall sharpness evaluation value of the original image.
[0084] One possible implementation is to calculate the sharpness evaluation value of all valid sub-regions and the sum of the sharpness correction values of all replaced invalid sub-regions to obtain the overall sharpness evaluation value.
[0085] Specifically, the final score for all sub-regions The summation is performed, and the resulting total is the overall sharpness evaluation value of the original image, denoted as score.
[0086]
[0087] Where n is the total number of sub-regions. Used to represent the sharpness evaluation value of the nth sub-region after the replacement operation.
[0088] Furthermore, after calculating the overall sharpness evaluation value of the original image, this value is compared with a preset focus success threshold. Based on the comparison result, it is determined whether the original image has been successfully focused. Then, based on this focus result, the corresponding control logic is triggered.
[0089] One possible implementation is to determine that the original image is successfully focused if the score is greater than or equal to the focus success threshold. At this point, the focusing mechanism can be controlled to lock the current focus position, triggering subsequent detection processes (such as capturing a high-resolution detection image), and sending a focus ready or detection passed signal to the host computer.
[0090] Another possible implementation is to determine that the original image has failed to focus if the score is less than the focus success threshold. In this case, the focusing mechanism can be controlled to continue executing the focus search algorithm to find a clearer focus position. Alternatively, a focus anomaly alarm can be issued, indicating that manual intervention may be necessary. This failure event should be recorded for statistical analysis.
[0091] The image sharpness determination method provided in this embodiment first divides the image into m... m (usually set to 6) The system divides the image into 36 regions (6 in total). For each region, a sharpness evaluation algorithm (such as Volleyath, Brenner, etc.) is used to calculate and save a region score. The mean of all region scores is then calculated to set a discrimination threshold. This threshold is used to divide the region scores into valid regions. The sum of the valid region scores and the number of valid regions are used to calculate the mean of the valid regions. Finally, the scores of non-valid regions are replaced with the mean of the valid regions. The sum of all region scores is the calculated image score, used for subsequent image focusing. This application ensures focusing accuracy and image selection accuracy while minimizing the score difference between edge and center regions, avoiding misjudgments caused by focusing results not meeting the set focusing parameter threshold.
[0092] The foregoing mainly describes the solutions provided in the embodiments of this application from the perspective of the working principle of the device. It is understood that, in order to achieve the above functions, the image sharpness evaluation device includes corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should readily recognize that, in conjunction with the algorithm steps of the various examples described in the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0093] This application embodiment can divide the image sharpness evaluation device into functional modules according to the above method example. For example, each function can be divided into a separate functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module.
[0094] It should be noted that the module division in this embodiment is illustrative and represents only one logical functional division; in actual implementation, other division methods may be used. When dividing functional modules according to their respective functions, Figure 4 A schematic diagram of a possible composition of the image sharpness evaluation device involved in the above and embodiment is shown. For example... Figure 4 As shown, the image sharpness evaluation device 400 may include: an acquisition module 401, a filtering module 402, a determination module 403, and a replacement module 404.
[0095] The acquisition module 401 is used to support the image sharpness evaluation device 400 in performing its functions. Figure 3 S301 in the illustrated image sharpness evaluation method.
[0096] The filtering module 402 is used to support the image sharpness evaluation device 400 in performing its functions. Figure 3 S302 in the illustrated image sharpness evaluation method.
[0097] Determining module 403 is used to support the image sharpness evaluation device 400 in performing its functions. Figure 3 The diagram illustrates S303 and S305 in the image sharpness evaluation method.
[0098] Replacement module 404, used to support the execution of image sharpness evaluation device 400 Figure 3 S304 in the illustrated image sharpness evaluation method.
[0099] One possible implementation involves an acquisition module that divides the original image into multiple sub-regions of a preset size. For any target sub-region, the module acquires the grayscale differences between multiple sets of pixel pairs within that sub-region. Each pixel pair includes a first pixel and a second pixel. The first pixel and the second pixel are spaced at a preset distance. Based on the grayscale differences between the multiple sets of pixel pairs, a sharpness evaluation value for the target sub-region is determined.
[0100] One possible implementation involves determining a module specifically used to calculate the square of the grayscale difference for each pair of pixels. The squares of the grayscale differences for all pixel pairs are then summed to obtain the sharpness evaluation value for the target sub-region.
[0101] One possible implementation involves a filtering module, specifically used to determine a first statistical value based on the sharpness evaluation values of multiple sub-regions. Based on the first statistical value, filtering thresholds for the multiple sub-regions are determined. The sharpness evaluation values of each sub-region are compared with the filtering thresholds. If the sharpness evaluation value of a sub-region is greater than or equal to the filtering threshold, the corresponding sub-region is determined as a valid sub-region. And / or, if the sharpness evaluation value of a sub-region is less than the filtering threshold, the corresponding sub-region is determined as an invalid sub-region.
[0102] One possible implementation involves determining a module specifically used to calculate the average sharpness evaluation value of all valid sub-regions to obtain a sharpness correction value.
[0103] One possible implementation involves determining a module specifically used to calculate the sharpness evaluation value of all valid sub-regions and the sum of the sharpness correction values of all replaced invalid sub-regions, to obtain the overall sharpness evaluation value.
[0104] One possible implementation, as provided in this application embodiment, is to compare the overall sharpness evaluation value of the original image with a preset focus success threshold. Based on the comparison result, it is determined whether the original image has been successfully focused.
[0105] It should be noted that all relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.
[0106] The image sharpness evaluation device 400 provided in this application embodiment is used to perform the above-mentioned... Figure 2 The image sharpness evaluation method shown can therefore achieve the same effect as the image sharpness evaluation method described above.
[0107] This application also provides an image sharpness evaluation device, which can perform the image sharpness evaluation method and related steps described in the above method embodiments.
[0108] This application also provides a computer-readable storage medium storing instructions that, when executed, perform the image sharpness evaluation method and related steps described in the above method embodiments.
[0109] This application also provides a computer program product that, when run on a computer, causes the computer to execute the image sharpness evaluation method and related steps described in the above method embodiments.
[0110] In some embodiments, the methods shown in this application can be implemented as computer program instructions encoded in a machine-readable format on a computer-readable storage medium or on other non-transitory media or articles of art.
[0111] This application also provides an image sharpness evaluation system 500, such as... Figure 5 As shown, the image sharpness evaluation system 500 includes at least one processor 501 and at least one interface circuit 502.
[0112] As an example, when the image sharpness evaluation system 500 includes a processor and an interface circuit, the processor can be... Figure 5 The processor 501 shown in the solid box (or the processor 501 shown in the dashed box) can be an interface circuit. Figure 5 The interface circuit 502 is shown in the solid box (or the dashed box). When the image sharpness evaluation system 500 includes two processors and two interface circuits, the two processors include... Figure 5 The processor 501 shown in the solid box and the processor 501 shown in the dashed box, these two interface circuits include Figure 5 Interface circuit 502 is shown in both solid and dashed boxes. No limitations are imposed on this.
[0113] The processor 501 and the interface circuit 502 can be interconnected via a line. For example, the interface circuit 502 can be used to receive signals. Alternatively, the interface circuit 502 can be used to send signals to other devices (such as the processor 501). For instance, the interface circuit 502 can read computer instructions stored in memory and send those instructions to the processor 501. The processor 501 executes the instructions and, in conjunction with input / output devices, implements the various steps in the above embodiments, such as implementing... Figure 3 The methods illustrated are the steps performed in the embodiments shown. Of course, this image sharpness evaluation system may also include other discrete components, and this application embodiment does not specifically limit this.
[0114] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0115] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0116] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0117] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0118] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, or the part that contributes to it, or all or part of the technical solution, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0119] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. An image sharpness evaluation method characterized by, The method comprises: obtaining sharpness evaluation values of a plurality of sub-regions in an original image; based on the sharpness evaluation values of the plurality of sub-regions, screening out effective sub-regions and ineffective sub-regions from the plurality of sub-regions; based on the sharpness of the effective sub-regions, determining a sharpness correction value; replacing the sharpness evaluation values of all the ineffective sub-regions with the sharpness correction value; based on the sharpness evaluation values of the effective sub-regions and the sharpness correction values of the replaced ineffective sub-regions, determining an overall sharpness evaluation value of the original image.
2. The method of claim 1, wherein, The method comprises: dividing the original image into a plurality of sub-regions of a preset size; for any target sub-region in the plurality of sub-regions, obtaining the gray value difference of a plurality of pixel pairs in the target sub-region; each pixel pair comprises a first pixel and a second pixel; the first pixel and the second pixel are separated by a preset distance; based on the gray value difference of the plurality of pixel pairs, determining the sharpness evaluation value of the target sub-region.
3. The method of claim 2, wherein, The method comprises: calculating the square of the gray value difference of each pixel pair; summing the squares of the gray value differences of all pixel pairs to obtain the sharpness evaluation value of the target sub-region.
4. The method of claim 1, wherein, The method comprises: based on the sharpness evaluation values of the plurality of sub-regions, determining a first statistical value; based on the first statistical value, determining a screening threshold value of the plurality of sub-regions; comparing the sharpness evaluation values of the plurality of sub-regions with the screening threshold value respectively; in the case where it is determined that the sharpness evaluation value of the sub-region is greater than or equal to the screening threshold value, determining that the corresponding sub-region is the effective sub-region; and / or, in the case where it is determined that the sharpness evaluation value of the sub-region is less than the screening threshold value, determining that the corresponding sub-region is the ineffective sub-region.
5. The method of claim 1, wherein, The method comprises: calculating the average of the sharpness evaluation values of all the effective sub-regions to obtain the sharpness correction value.
6. The method of claim 1, wherein, The method comprises: calculating the sum of the sharpness evaluation values of all the effective sub-regions and the sharpness correction values of all the replaced ineffective sub-regions to obtain the overall sharpness evaluation value.
7. The method of claim 1, wherein, The method further comprises: comparing the overall sharpness evaluation value of the original image with a preset focus success threshold value; judging whether the original image is successfully focused according to the comparison result of the overall sharpness evaluation value and the focus success threshold value.
8. An image sharpness evaluation apparatus characterized by comprising: The device comprises: an acquisition module for obtaining sharpness evaluation values of a plurality of sub-regions in an original image; a screening module for screening out effective sub-regions and ineffective sub-regions from the plurality of sub-regions based on the sharpness evaluation values of the plurality of sub-regions; determining a sharpness correction value based on the sharpness of the valid sub-region; replacing the sharpness evaluation values of all the invalid sub-regions with the sharpness correction value; the determining module is further configured to determine an overall sharpness evaluation value of the original image based on the sharpness evaluation value of the valid sub-region and the sharpness correction value of the replaced invalid sub-region.
9. An image sharpness evaluation apparatus characterized by comprising: The image sharpness evaluation device includes a processor and a memory, the memory stores machine executable instructions capable of being executed by the processor, and the processor executes the machine executable instructions to implement the image sharpness evaluation method in any one of claims 1 to 7.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the image sharpness evaluation method in any one of claims 1 to 7.
Citation Information
Patent Citations
Automatic focusing method and apparatus based on interested area
CN106973219A
Image processing method, image processing device and recording medium
CN108846806A
Image definition identification method, image definition identification device and terminal device
CN110175980A
Image definition determination method and device, projector equipment and storage medium
CN110706183A
Image definition detection method and device, electronic equipment and storage medium
CN114022416A