An Automatic Focusing Method and Focusing System for Region of Interest

By automatically identifying and calculating the region of interest and combining the weights for weight fusion, the traditional automatic focusing method has solved the problem of poor focus effect on complex scenes and specific area of ​​attention images, and achieved accurate focus and efficient image processing.

CN119012006BActive Publication Date: 2025-06-20SICHUAN NATIONAL INNOVATION VISION UHD VIDEO TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411078165.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-07
Publication Date
2025-06-20
Estimated Expiration
2044-08-07

AI Technical Summary

Technical Problem

When traditional automatic focusing methods deal with complex scenes or images with specific areas of interest, the focus effect is not ideal, and the user requires manual setting of the area of ​​interest (ROI) template, which is cumbersome and takes up storage space.

Method used

An automatic focus method for the region of interest is provided, by uniformly segmenting the target image, calculating the contrast and distance weights of the blocks, fusion weights are carried out for normalization, and automatically identifying and calculating the region of interest, thereby achieving accurate focus.

Benefits of technology

Accurate focus on the area of ​​interest is achieved, tedious steps and storage space occupation problems of manually setting up the ROI template, and improve the overall quality and focus efficiency of the image.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119012006B_ABST
    Figure CN119012006B_ABST
Patent Text Reader

Abstract

The present invention provides a method and a focusing system for automatically focusing on a region of interest, belonging to the technical field of image processing. First, the region of interest and the non-region of interest are identified and divided, and based on the contrast of the blocks and the distance from the center point, comprehensive weights are assigned to each block. By fusing the contrast weight and the distance weight, it is ensured that the region of interest obtains a higher priority during the focusing process. Subsequently, these weights are used to calculate the overall sharpness of the image by weighted calculation, and the focusing parameters are adjusted accordingly. The focusing method of this application not only improves the accuracy of image focusing, but also realizes the priority processing of specific regions, thereby optimizing the efficiency and effect of image shooting and processing, and avoiding the cumbersome steps of manually setting the ROI template and the problem of storage space occupation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and particularly to a method and a system for automatically focusing on a region of interest. Background Art

[0002] With the continuous development of imaging technology, automatic focusing technology has been widely applied in various electronic devices, such as video surveillance systems, handheld cameras, smartphones, etc. When these devices capture images or videos, it is necessary to focus the images clearly to ensure that the target objects are imaged clearly on the image sensor, thereby improving the overall quality of the images. However, traditional automatic focusing methods often have some problems. Especially when dealing with complex scenes or images with specific regions of interest (ROIs), the focusing effect is often not ideal.

[0003] At present, there are already various automatic focusing technologies, but most methods are processed based on global image information and cannot accurately focus on the regions that users are particularly interested in. In addition, although some methods support users to manually set the region of interest (ROI), this method requires users to preset and store the ROI template in advance, which is not only cumbersome to operate but also occupies a large amount of storage space.

[0004] Therefore, it is necessary to provide a method and a system for automatically focusing on a region of interest to solve the above technical problems. Summary of the Invention

[0005] To solve the above technical problems, the present invention provides a method and a system for automatically focusing on a region of interest, which can automatically identify and calculate the region of interest, and perform accurate focusing according to the characteristics of this region, thereby avoiding the cumbersome steps of manually setting the ROI template and the problem of occupying storage space.

[0006] The present invention provides a method for automatically focusing on a region of interest, and the focusing method includes the following steps:

[0007] S1: Uniformly segment the target image to obtain regions of interest and non-regions of interest, wherein the target image is pre-divided into a region of interest and a non-region of interest;

[0008] S2: Read the contrast of each block, and calculate the first weight of the region of interest and the second weight of the non-region of interest according to the contrast of all blocks in the region of interest and the contrast of all blocks in the non-region of interest;

[0009] S3: Establish a rectangular coordinate system with the center of the region of interest as the origin, and assign distance weights to each block based on the straight-line distance from the center of each block to the origin;

[0010] S4: For the region of interest, fuse the first weight and the distance weight to obtain the third weight of all blocks within the region of interest;

[0011] For the non - region of interest, fuse the second weight and the distance weight to obtain the fourth weight of all blocks within the non - region of interest, and perform normalization processing on the third weight and the fourth weight;

[0012] S5: According to the normalized third weight and fourth weight, and the clarity of each block, calculate the normalized overall clarity of the target image, and perform autofocus on the region of interest according to the normalized overall clarity.

[0013] Preferably, step S1 includes the following steps:

[0014] S101: Identify and determine the region of interest and the non - region of interest in the target image;

[0015] S102: Uniformly divide the target image into multiple equally - sized blocks according to a preset segmentation size;

[0016] S103: Based on the boundary of the region of interest, mark the blocks located within the region of interest as interested blocks, and mark the blocks located within the non - region of interest as non - interested blocks.

[0017] Preferably, step S2 includes the following steps:

[0018] S201: Calculate the contrast of each block;

[0019] S202: Calculate the first weight and the second weight respectively according to the contrast of all blocks within the region of interest and the contrast of all blocks within the non - region of interest. Among them, the calculation formula for the first weight is:

[0020]

[0021] The calculation formula for the second weight is:

[0022]

[0023] Among them, C i represents the i - th block within the region of interest, C j represents the j - th block within the non - region of interest, ω1 represents the first weight, ω2 represents the second weight, m represents the set of all blocks within the region of interest, and n represents the set of all blocks within the non - region of interest.

[0024] Preferably, step S3 includes the following steps:

[0025] S301: Determine the central coordinates of the region of interest, and establish a rectangular coordinate system with the central coordinates of the region of interest as the center;

[0026] S302: Read the central coordinates of each block in the target image, and calculate the straight-line distance to the origin of the rectangular coordinate system. The calculation formula for the straight-line distance is:

[0027]

[0028] where D i represents the straight-line distance, and (x i , y i ) represents the central coordinates of the i-th block;

[0029] S303: Calculate the distance weight of each block according to the straight-line distance of each block. Among them, the calculation formula for the distance weight is:

[0030]

[0031] where ω D (i) represents the distance weight of the i-th block, exp(·) represents the natural exponential function, and α represents a positive number used to control the speed at which the distance weight decreases as the distance increases.

[0032] Preferably, step S4 includes the following steps:

[0033] S401: Perform scaling processing on the first weight, the second weight, and the distance weight to obtain the first weight, the second weight, and the distance weight at the same magnitude level;

[0034] S402: For all blocks in the region of interest:

[0035] Sum the scaled first weight and the distance weight to obtain the third weight of all blocks in the region of interest. The summation formula for the third weight is:

[0036] ω3 = ω1 + ω D (i)

[0037] where ω3 represents the third weight;

[0038] Specifically, for all blocks in the non-region of interest:

[0039] Sum the scaled second weight and the distance weight to obtain the fourth weight of all blocks in the non-region of interest. The summation formula for the fourth weight is:

[0040] ω4 = ω2 + ωD (i)

[0041] Among them, ω4 represents the fourth weight;

[0042] S403: Normalize the third weight and the fourth weight.

[0043] Preferably, step S5 includes the following steps:

[0044] S501: Calculate the weighted clarity of each block according to the corresponding normalized third weight and fourth weight respectively;

[0045] S502: Sum up the weighted clarity of each block to obtain the overall clarity;

[0046] S503: Sum up all the third weights and fourth weights to obtain the weight sum;

[0047] S504: Divide the overall clarity by the weight sum to obtain the normalized overall clarity.

[0048] The present invention also provides a region of interest automatic focusing system for the above-mentioned region of interest automatic focusing method. The focusing system includes:

[0049] An image segmentation module, configured to uniformly segment a target image to obtain a region of interest block and a non-region of interest block, wherein the target image is pre-divided into a region of interest and a non-region of interest;

[0050] A contrast weight calculation module, configured to read the contrast of each block, and calculate the first weight of the region of interest and the second weight of the non-region of interest according to the contrast of all blocks in the region of interest and the contrast of all blocks in the non-region of interest;

[0051] A distance weight calculation module, configured to establish a rectangular coordinate system with the center of the region of interest as the origin, and assign distance weights to each block based on the straight-line distance from the center of each block to the origin;

[0052] A weight fusion module, configured to fuse the first weight and the distance weight for the region of interest to obtain the third weight of all blocks in the region of interest;

[0053] For the non-region of interest, fuse the second weight and the distance weight to obtain the fourth weight of all blocks in the non-region of interest, and normalize the third weight and the fourth weight;

[0054] A focusing module is used to calculate the normalized overall sharpness of the target image based on the normalized third weight and fourth weight, and the sharpness of each block, and automatically focus on the region of interest according to the normalized overall sharpness.

[0055] Compared with the related art, an automatic focusing method and a focusing system for a region of interest provided by the present invention have the following beneficial effects:

[0056] The present invention can automatically identify and calculate the region of interest, and perform precise focusing according to the characteristics of the region, thereby avoiding the cumbersome steps of manually setting the ROI template and the problem of occupying storage space. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 is a flowchart of an automatic focusing method for a region of interest provided by the present invention;

[0058] Figure 2 is a module structure diagram of an automatic focusing system for a region of interest provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0059] The present invention will be further described in detail below with reference to the drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the present invention, rather than limiting the present invention. In addition, it should be noted that, for the sake of description, only parts related to the present invention are shown in the drawings rather than all structures. In addition, the embodiments in the present invention and the features in the embodiments can be combined with each other without conflict.

[0060] In addition, it should be noted that, for the sake of description, only parts related to the present invention are shown in the drawings rather than all content. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the operations (or steps) as being processed sequentially, many of the operations can be performed in parallel, concurrently, or simultaneously. In addition, the order of the operations can be rearranged. When the operations are completed, the process can be terminated, but there may also be additional steps not included in the drawings. The process can correspond to a method, a function, a procedure, a subroutine, a subprogram, and the like.

[0061] Embodiment 1

[0062] The present invention provides an automatic focusing method for a region of interest, referring to Figure 1 as shown, the focusing method includes the following steps:

[0063] S1: Uniformly divide the target image to obtain regions of interest and non - regions of interest, where the target image is pre - divided into regions of interest and non - regions of interest.

[0064] In this embodiment, first, the target image is uniformly divided into multiple equally - sized blocks according to a preset size. These blocks can be, but are not limited to, square - shaped. Then, according to the pre - determined region of interest (ROI) and non - region of interest (non - ROI), the blocks located within the region of interest are marked as regions of interest, and the blocks located within the non - region of interest are marked as non - regions of interest.

[0065] Through uniform division, a large image can be effectively decomposed into smaller blocks, facilitating subsequent processing. At the same time, marking regions of interest and non - regions of interest helps to assign different weightings to different blocks in subsequent steps.

[0066] S2: Read the contrast of each block, and calculate the first weight of the region of interest and the second weight of the non - region of interest based on the contrast of all blocks within the region of interest and the contrast of all blocks within the non - region of interest.

[0067] In this embodiment, for each block, calculate its contrast, which can be achieved by calculating the standard deviation of the pixel values within the block. Then, based on the contrast of the regions of interest and non - regions of interest, calculate the first weight and the second weight. The first weight reflects the importance of the region of interest, and the second weight reflects the importance of the non - region of interest.

[0068] Through contrast calculation in this step, important details in the image can be highlighted. By calculating the first weight and the second weight, the importance levels of different regions can be quantified.

[0069] S3: Establish a rectangular coordinate system with the center of the region of interest as the origin, and assign distance weights to each block based on the straight - line distance from the center of each block to the origin.

[0070] In this embodiment, determine the center coordinates of the region of interest and establish a rectangular coordinate system with this as the center. For each block, calculate the straight - line distance from its center to the center of the region of interest, and calculate the distance weight based on this distance. The distance weight decreases as the distance increases.

[0071] The distance weight can reflect the potential impact of the distance between the block and the center of the region of interest on its importance. At the same time, the distance weight can help achieve a smooth transition from the region of interest to the non - region of interest, making the final focusing effect more natural.

[0072] S4: For the region of interest, fuse the first weight and the distance weight to obtain the third weight of all blocks within the region of interest;

[0073] For the non - region of interest, fuse the second weight and the distance weight to obtain the fourth weight of all blocks within the non - region of interest, and perform normalization processing on the third weight and the fourth weight.

[0074] In this embodiment, add the first weight and the distance weight to obtain the third weight of each block within the region of interest; add the second weight and the distance weight to obtain the fourth weight of each block within the non - region of interest; then, perform normalization processing on the third weight and the fourth weight to ensure that the sum of the weights of all blocks is 1.

[0075] By fusing the contrast weight and the distance weight, the contrast and position information of the blocks can be comprehensively considered. At the same time, through normalization processing, it is ensured that the weights of all blocks are within a reasonable range, avoiding the weights of some blocks being too large or too small.

[0076] S5: According to the normalized third weight and fourth weight, and the sharpness of each block, calculate the normalized overall sharpness of the target image, and perform autofocus on the region of interest according to the normalized overall sharpness.

[0077] In this embodiment, according to the sharpness of each block and the corresponding normalized third weight and fourth weight, calculate the normalized overall sharpness of the target image, and then adjust the focus of the region of interest according to the normalized overall sharpness to maximize the overall sharpness.

[0078] By calculating the overall sharpness, the sharpness of the image can be optimized and the image quality can be improved. At the same time, through autofocus, while maintaining the overall sharpness of the image, the region of interest can be highlighted, thereby achieving the purpose of enhancing the visual effect.

[0079] Specifically, step S1 includes the following steps:

[0080] S101: Identify and determine the region of interest and the non - region of interest in the target image.

[0081] In this embodiment, first, identify and determine the region of interest (ROI) and the non - region of interest (non - ROI) on the target image, which can be completed by including but not limited to manual annotation and using automatic detection algorithms. Exemplarily, machine learning methods such as support vector machine (SVM) or deep learning methods such as convolutional neural network (CNN) can be used to automatically detect the ROI.

[0082] By identifying and determining the regions of interest and non - interest regions, it can be ensured that subsequent steps can process specific regions, thereby improving the pertinence and efficiency of image processing.

[0083] S102: Uniformly divide the target image into multiple equally - sized blocks according to a preset segmentation size.

[0084] In this embodiment, according to the preset segmentation size, the target image is uniformly divided into multiple equally - sized blocks. By splitting the target image into multiple equally - sized blocks, the large image can be effectively decomposed into smaller units, facilitating independent processing of each block in subsequent steps and improving the flexibility and efficiency of image processing.

[0085] S103: Based on the boundary of the region of interest, mark the blocks located within the region of interest as interested blocks and mark the blocks located within the non - interest region as non - interested blocks.

[0086] In this embodiment, according to the boundaries of the region of interest and non - interest regions determined in step S101, mark the blocks located within the region of interest as interested blocks and the blocks located within the non - interest region as non - interested blocks.

[0087] By marking the blocks as interested blocks or non - interested blocks, different weight assignments can be made to different types of blocks in subsequent steps, which helps to highlight the region of interest and reduce the influence of the non - interest region at the same time.

[0088] Specifically, step S2 includes the following steps:

[0089] S201: Calculate the contrast of each block.

[0090] In this embodiment, for each block, calculate its contrast, which can be specifically achieved by calculating the standard deviation of the pixel values within the block. By calculating the contrast, the degree of detail richness within each block can be quantified.

[0091] S202: Calculate the first weight and the second weight respectively according to the contrasts of all the blocks within the region of interest and all the blocks within the non - interest region. Among them, the calculation formula for the first weight is:

[0092]

[0093] The calculation formula for the second weight is:

[0094]

[0095] Where C i represents the i - th block within the region of interest, C jDenote the j-th block within the non-interested region, ω1 represents the first weight, ω2 represents the second weight, m represents the set of all blocks within the interested region, and n represents the set of all blocks within the non-interested region.

[0096] In this embodiment, according to the contrast between the interested blocks and the non-interested blocks, the first weight and the second weight are calculated, which can quantify the importance of different regions. A higher first weight means that the blocks within the interested region usually have higher contrast, so they are more worthy of attention. The second weight reflects the importance of the blocks within the non-interested region and helps to determine the relative importance of the non-interested region.

[0097] Specifically, step S3 includes the following steps:

[0098] S301: Determine the central coordinates of the interested region, and establish a rectangular coordinate system with the central coordinates of the interested region as the center.

[0099] In this embodiment, first, calculate the central coordinates of the interested region, which can be achieved by calculating the geometric center of the bounding box of the interested region. Exemplarily, if the upper left coordinate of the interested region is (x1, y1) and the lower right coordinate is (x2, y2), then the central coordinates are Next, establish a rectangular coordinate system with this central coordinate as the origin of the rectangular coordinate system.

[0100] S302: Read the central coordinates of each block in the target image, and calculate the straight-line distance to the origin of the rectangular coordinate system. The calculation formula for the straight-line distance is:

[0101]

[0102] where D i represents the straight-line distance, and (x i , y i ) represents the central coordinates of the i-th block.

[0103] In this embodiment, for each block, calculate its central coordinates, and then calculate the straight-line distance from the block central coordinates to the origin of the rectangular coordinate system according to the calculation formula of the straight-line distance. By calculating the straight-line distances from the centers of each block to the center of the interested region, the relative distances between each block and the center of the interested region can be quantified.

[0104] S303: Calculate the distance weight for each block according to the straight-line distance of each block. Among them, the calculation formula for the distance weight is:

[0105]

[0106] where ω D(i) represents the distance weight of the i-th block, exp(·) represents the natural exponential function, and α represents a positive number used to control the rate at which the distance weight decreases as the distance increases.

[0107] In this embodiment, according to the straight-line distance of each block, the distance weight is calculated. By calculating the distance weight, the potential influence of the distance between each block and the center of the region of interest on its importance can be reflected. Blocks closer to the center have higher weights, and vice versa.

[0108] Specifically, step S4 includes the following steps:

[0109] S401: Scale the first weight, the second weight, and the distance weight to obtain the first weight, the second weight, and the distance weight at the same order of magnitude.

[0110] In this embodiment, in order to ensure that the first weight, the second weight, and the distance weight are at the same order of magnitude, they need to be scaled. This is because the first weight, the second weight, and the distance weight come from different calculation methods and their numerical ranges may be different. Through scaling, it can be ensured that the first weight, the second weight, and the distance weight are at the same order of magnitude, which helps to avoid offsets caused by differences in order of magnitude when performing weight fusion in subsequent steps.

[0111] S402: For all blocks in the region of interest:

[0112] Sum the scaled first weight and the distance weight to obtain the third weight for all blocks in the region of interest. The summation formula for the third weight is:

[0113] ω3 = ω1 + ω D (i)

[0114] where ω3 represents the third weight.

[0115] By summing the first weight and the distance weight, the contrast and position information of the block can be comprehensively considered, thereby obtaining the third weight of each block.

[0116] Specifically, for all blocks in the non-region of interest:

[0117] Sum the scaled second weight and the distance weight to obtain the fourth weight for all blocks in the non-region of interest. The summation formula for the fourth weight is:

[0118] ω4 = ω2 + ω D (i)

[0119] where ω4 represents the fourth weight.

[0120] By summing the second weight and the distance weight, the contrast and position information of the block can be comprehensively considered, so as to obtain the fourth weight of each block.

[0121] S403: Normalize the third weight and the fourth weight.

[0122] In this embodiment, through normalization, it can be ensured that the sum of the weights of all blocks is 1, avoiding the weights of some blocks being too large or too small, thus ensuring the balance and consistency of the weights.

[0123] Specifically, step S5 includes the following steps:

[0124] S501: Calculate the weighted clarity of each block according to the normalized third weight and the fourth weight respectively.

[0125] In this embodiment, for each block, weighted calculation is performed according to its clarity and the corresponding normalized weight. Among them, for the blocks within the region of interest, the third weight is used; for the blocks outside the region of interest, the fourth weight is used. The clarity can be calculated using, including but not limited to, edge detection.

[0126] By calculating the weighted clarity, it can be ensured that the clarity of each block is combined with its importance, so as to better reflect the clarity distribution of the entire image.

[0127] S502: Sum up the weighted clarity of each block to obtain the overall clarity.

[0128] In this embodiment, the weighted clarity of all blocks is summed up to obtain the overall clarity of the entire image. By summing up the weighted clarity of all blocks, a quantitative overall clarity index of the target image can be obtained, which is helpful for automatically focusing on the region of interest according to the clarity in the subsequent steps.

[0129] S503: Sum up all the third weights and the fourth weights to obtain the weight sum.

[0130] In this embodiment, the normalized weights of all blocks are summed up to obtain the weight sum, which can ensure the accuracy of the subsequent calculation of the normalized overall clarity.

[0131] S504: Divide the overall clarity by the weight sum to obtain the normalized overall clarity.

[0132] In this embodiment, the overall clarity is divided by the sum of weights to obtain the normalized overall clarity. Through normalization, it can be ensured that the value of the overall clarity is associated with the sum of weights, thus more accurately reflecting the quality of the image. The normalized overall clarity can be used to adjust the focus of the region of interest in subsequent steps to achieve the effect of autofocus.

[0133] The working principle of an autofocus method for a region of interest provided by the present invention is as follows:

[0134] First, preprocess the target image to identify the region of interest (ROI) and non-region of interest (Non-ROI) in the image. Subsequently, according to the preset segmentation size, the entire target image is evenly divided into multiple equal-sized blocks, and based on their positional relationship with the ROI, these blocks are marked as interested blocks or non-interested blocks.

[0135] Next, calculate the contrast of each block to reflect the richness of details in the image content within the block. Based on these contrast values, weights are assigned to all blocks within the ROI and Non-ROI respectively. The weight calculation takes into account the average contrast of all blocks within the region, such that regions with higher contrast obtain higher weights, thus receiving more attention during the focusing process.

[0136] To further optimize the focusing process, a distance weight is also introduced. By establishing a rectangular coordinate system with the center of the ROI as the origin, calculate the straight-line distance from the center of each block to the origin, and assign a distance weight to each block according to this distance. The closer the distance, the higher the weight, which means that regions closer to the center of the ROI will receive higher priority during focusing.

[0137] Then, fuse the contrast weight and the distance weight to calculate a comprehensive weight for each block within the ROI and Non-ROI respectively. Before that, various weights need to be scaled to ensure that they are in the same order of magnitude for subsequent calculation and comparison. The fused weight takes into account both the contrast characteristics of the block and its positional relationship, thus being able to more accurately reflect the importance of each block during the focusing process.

[0138] Finally, based on the normalized comprehensive weight, calculate the normalized overall clarity of the target image. This indicator reflects the clarity of the entire image in the focused state, especially considering the priority of the ROI. Adjust the focusing parameters (such as the lens position) according to the change of the normalized overall clarity to achieve autofocus on the region of interest.

[0139] In summary, the automatic focusing method of the present invention realizes priority focusing on a specific area in the target image by comprehensively considering the contrast of the image, the block position, and the user-defined region of interest, improving the efficiency and effect of image shooting and processing.

[0140] Embodiment 2

[0141] The present invention also provides a region of interest automatic focusing system for the above-mentioned region of interest automatic focusing method. Referring to Figure 2 as shown, the focusing system includes:

[0142] An image segmentation module for uniformly segmenting the target image to obtain regions of interest and non-regions of interest. Among them, the target image is pre-divided into regions of interest and non-regions of interest;

[0143] A contrast weight calculation module for reading the contrast of each block and calculating the first weight of the region of interest and the second weight of the non-region of interest according to the contrast of all blocks in the region of interest and the contrast of all blocks in the non-region of interest;

[0144] A distance weight calculation module for establishing a rectangular coordinate system with the center of the region of interest as the origin and assigning distance weights to each block based on the straight-line distance from the center of each block to the origin;

[0145] A weight fusion module for fusing the first weight and the distance weight for the region of interest to obtain the third weight of all blocks in the region of interest;

[0146] For the non-region of interest, fusing the second weight and the distance weight to obtain the fourth weight of all blocks in the non-region of interest, and normalizing the third weight and the fourth weight;

[0147] A focusing module for calculating the normalized overall sharpness of the target image according to the normalized third weight and fourth weight and the sharpness of each block, and automatically focusing on the region of interest according to the normalized overall sharpness.

[0148] This application is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams can be implemented by computer program instructions, and the combination of flows and / or blocks in the flowcharts and / or block diagrams can also be implemented. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a means for implementing the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or a means for implementing the functions specified in multiple blocks.

[0149] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing relevant hardware through a program, and this program can be stored in a computer-readable storage medium. The storage medium includes read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM), or other optical disc memories, magnetic disk memories, tape memories, or any other medium that can be used to carry or store data and is computer-readable.

[0150] It should also be noted that the term "comprising", "including", or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity, or device comprising a series of elements not only includes those elements, but also includes other elements not explicitly listed, or still includes elements inherent in such a process, method, commodity, or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the existence of another identical element in the process, method, commodity, or device comprising the element.

Claims

1. A method for automatically focusing a region of interest, characterized in that: The focusing method comprises the following steps: S1: Evenly segmenting the target image to obtain blocks of interest and blocks of non-interest, wherein the target image is pre-divided into blocks of interest and blocks of non-interest; S2: reading the contrast of each block, and calculating a first weight of the region of interest and a second weight of the region of non-interest according to the contrast of all blocks in the region of interest and the contrast of all blocks in the region of non-interest; Step S2 includes the following steps: S201: Calculate the contrast of each block; S202: Calculate a first weight and a second weight respectively according to the contrast of all blocks in the region of interest and the contrast of all blocks in the non-region of interest, wherein the calculation formula of the first weight is: The calculation formula of the second weight is: Among them, C i represents the i-th block in the region of interest, C j represents the jth block in the non-interested area, ω1 represents the first weight, ω2 represents the second weight, m ​​represents the set of all blocks in the interested area, and n represents the set of all blocks in the non-interested area; S3: establishing a rectangular coordinate system with the center of the region of interest as the origin, and assigning a distance weight to each block based on the straight-line distance from the center of each block to the origin; S4: For the region of interest, the first weight and the distance weight are integrated to obtain a third weight of all blocks in the region of interest; For the non-interested area, fusing the second weight and the distance weight to obtain a fourth weight of all blocks in the non-interested area, and normalizing the third weight and the fourth weight; S401: Scaling the first weight, the second weight and the distance weight to obtain the first weight, the second weight and the distance weight at the same level; S402: For all blocks in the region of interest: The first weight and the distance weight after the scaling process are summed to obtain the third weight of all blocks in the region of interest. The summation formula of the third weight is: ω3=ω1+ω D (i) Among them, ω3 represents the third weight; Specifically, for all blocks of the non-interest area: The second weight after scaling and the distance weight are summed to obtain the fourth weight of all blocks in the non-interested area. The summation formula of the fourth weight is: ω4=ω2+ω D (i) Wherein, ω4 represents the fourth weight; S403: normalizing the third weight and the fourth weight; S5: Calculate the normalized overall clarity of the target image according to the normalized third weight and fourth weight, and the clarity of each block, and automatically focus the region of interest according to the normalized overall clarity.

2. The method for automatically focusing a region of interest according to claim 1, characterized in that: Step S1 includes the following steps: S101: Identify and determine the region of interest and non-region of interest in the target image; S102: evenly dividing the target image into a plurality of equal-sized blocks according to a preset segmentation size; S103: Based on the boundary of the region of interest, marking a block located in the region of interest as a block of interest, and marking a block located in a non-region of interest as a block of non-interest.

3. The method for automatically focusing a region of interest according to claim 2, characterized in that: Step S3 includes the following steps: S301: Determine the center coordinates of the region of interest, and establish a rectangular coordinate system with the center coordinates of the region of interest as the center; S302: Read the center coordinates of each block in the target image, and calculate the straight-line distance to the origin of the rectangular coordinate system. The calculation formula of the straight-line distance is: Among them, D i represents the straight-line distance, (x i ,y i ) represents the center coordinates of the i-th block; S303: Calculate the distance weight of each block according to the straight-line distance of each block, wherein the calculation formula of the distance weight is: Among them, ω D (i) represents the distance weight of the i-th block, exp(·) represents the natural exponential function, and α represents a positive number used to control the speed at which the distance weight decreases with increasing distance.

4. The method for automatically focusing a region of interest according to claim 3, characterized in that: Step S5 includes the following steps: S501: performing weighted calculation on the clarity of each block according to the third weight and the fourth weight after corresponding normalization processing; S502: Sum the weighted clarity of each block to obtain the overall clarity; S503: Calculate the sum of all third weights and fourth weights to obtain a weight sum; S504: Divide the overall clarity by the weight sum to obtain the normalized overall clarity.

5. A region of interest automatic focusing system, used to execute a region of interest automatic focusing method according to any one of claims 1 to 4, characterized in that: The focusing system comprises: An image segmentation module is used to evenly segment the target image to obtain blocks of interest and blocks of no interest, wherein the target image is pre-divided into blocks of interest and blocks of no interest; A contrast weight calculation module, used for reading the contrast of each block, and calculating a first weight of the region of interest and a second weight of the region of non-interest according to the contrast of all blocks in the region of interest and the contrast of all blocks in the region of non-interest; A distance weight calculation module, used to establish a rectangular coordinate system with the center of the region of interest as the origin, and to assign a distance weight to each block based on the straight-line distance from the center of each block to the origin; A weight fusion module, used for fusing the first weight and the distance weight for the region of interest to obtain a third weight for all blocks in the region of interest; For the non-interested area, fusing the second weight and the distance weight to obtain a fourth weight of all blocks in the non-interested area, and normalizing the third weight and the fourth weight; A focusing module is used to calculate the normalized overall clarity of the target image according to the normalized third weight and fourth weight and the clarity of each block, and automatically focus on the region of interest according to the normalized overall clarity.

Citation Information

Patent Citations

  • Automatic focusing method and apparatus based on interested area

    CN106973219A