Automatic focusing method and focusing system for region of interest

By uniformly segmenting and weight fusion of the target image, automatically identifying and focusing the area of ​​interest, the problem of poor focus effect of traditional automatic focusing methods in complex scenes and specific areas is solved, and the effect of simplifying operations and improving image clarity is achieved.

CN119012006AActive Publication Date: 2024-11-22SICHUAN NATIONAL INNOVATION VISION UHD VIDEO TECHNOLOGY CO LTD

Patent Information

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

AI Technical Summary

Technical Problem

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

Method used

By evenly segmenting the target image, calculating the contrast and distance weights of the blocks, normalizing the fusion weights, automatically identifying and accurately focusing the area of ​​interest, avoiding the steps and storage space occupied by manually setting the ROI template.

Benefits of technology

Automatic focus of the area of ​​interest is achieved, the overall clarity and visual effect of the image is improved, the operation process is simplified, and the storage space requirement is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119012006A_ABST
    Figure CN119012006A_ABST
Patent Text Reader

Abstract

The invention provides a region-of-interest automatic focusing method and focusing system, and belongs to the technical field of image processing, and the method comprises the steps: firstly recognizing and dividing a region-of-interest and a non-region-of-interest, distributing a comprehensive weight for each block based on the contrast of the block and the distance between the block and a central point, and carrying out the fusion of a contrast weight and a distance weight, thereby achieving the automatic focusing of the region-of-interest. According to the focusing method, the priority of the region of interest is ensured to obtain a higher priority in the focusing process, then the overall definition of the image is calculated by using the weights in a weighted manner, and the focusing parameters are adjusted accordingly, so that the focusing method not only improves the accuracy of image focusing, but also realizes priority processing of the specific region, and the focusing accuracy is improved. Therefore, the efficiency and effect of image shooting and processing are optimized, and the problems of tedious steps of manually setting the ROI template and occupation of storage space are avoided.
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 in particular to an area of ​​interest automatic focusing method and focusing system. Background Art

[0002] With the continuous development of imaging technology, autofocus technology has been widely used in various electronic devices, such as video surveillance systems, handheld cameras, smart phones, etc. When these devices shoot images or videos, they need to focus the image clearly to ensure that the target object is clearly imaged on the image sensor, thereby improving the overall quality of the image. However, traditional autofocus methods often have some problems, especially when processing complex scenes or images with specific regions of interest (ROI), the focusing effect is often not ideal.

[0003] There are many auto-focusing technologies, but most of them are based on global image information and cannot accurately focus on the area that the user is particularly interested in. In addition, although some methods support users to manually set the region of interest (ROI), this method requires users to pre-set and store the ROI template, which is not only cumbersome to operate, but also takes up a lot of storage space.

[0004] Therefore, it is necessary to provide a method and system for automatically focusing 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 region of interest automatic focusing method and focusing system, which can automatically identify and calculate the region of interest, and accurately focus according to the characteristics of the region, thereby avoiding the tedious steps of manually setting the ROI template and the problem of storage space occupation.

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

[0007] 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;

[0008] 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;

[0009] 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;

[0010] 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;

[0011] 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;

[0012] 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.

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

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

[0015] S102: evenly dividing the target image into a plurality of equal-sized blocks according to a preset segmentation size;

[0016] 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.

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

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

[0019] 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:

[0020]

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

[0022]

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

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

[0025] 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;

[0026] 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:

[0027]

[0028] Among them, D i represents the straight-line distance, (x i ,y i ) represents the center coordinates of the i-th block;

[0029] 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:

[0030]

[0031] 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.

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

[0033] 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;

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

[0035] 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:

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

[0037] Among them, ω3 represents the third weight;

[0038] Specifically for all blocks of the non-interest area:

[0039] 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:

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

[0041] Wherein, ω4 represents the fourth weight;

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

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

[0044] S501: performing weighted calculation on the clarity of each block according to the third weight and the fourth weight after corresponding normalization processing;

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

[0046] S503: Calculate the sum of all third weights and fourth weights to obtain a weight sum;

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

[0048] The present invention also provides an area of ​​interest automatic focusing system, which is used in the area of ​​interest automatic focusing method, and the focusing system comprises:

[0049] 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;

[0050] 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;

[0051] 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;

[0052] 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;

[0053] 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;

[0054] 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.

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

[0056] The present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 A flowchart of a method for automatically focusing on a region of interest provided by the present invention;

[0058] Figure 2 A module structure diagram of a region of interest automatic focusing system provided by the present invention. DETAILED DESCRIPTION

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

[0060] It should also be noted that, for ease of description, only the part relevant to the present invention but not all the content is shown in the accompanying drawings. It should be mentioned before discussing the exemplary embodiments in more detail that some exemplary embodiments are described as the processing or method described as a flow chart. Although the flow chart describes each operation (or step) as being processed sequentially, many operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. When its operation is completed, the processing can be terminated, but it can also have additional steps not included in the accompanying drawings. The processing can correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.

[0061] Embodiment 1

[0062] The present invention provides a method for automatically focusing a region of interest, referring to Figure 1 As shown, the focusing method comprises the following steps:

[0063] S1: Evenly segment a 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.

[0064] In this embodiment, first, the target image is evenly divided into multiple equal-sized blocks according to a preset size, and these blocks can be but are not limited to squares; then, according to the predetermined region of interest (ROI) and region of non-interest (non-ROI), the blocks located in the region of interest are marked as blocks of interest, and the blocks located in the non-region of interest are marked as blocks of non-interest.

[0065] Through uniform segmentation, large images can be effectively decomposed into smaller blocks for subsequent processing. At the same time, marking blocks of interest and non-interest blocks helps to assign different weights to different blocks in subsequent steps.

[0066] 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 no interest according to the contrast of all blocks in the region of interest and the contrast of all blocks in the region of no interest.

[0067] In this embodiment, for each block, its contrast is calculated, which can be achieved by calculating the standard deviation of the pixel values ​​within the block; then, based on the contrast between the block of interest and the block of no interest, a first weight and a second weight are calculated, the first weight reflects the importance of the area of ​​interest, and the second weight reflects the importance of the area of ​​no interest.

[0068] This step can highlight important details in the image by calculating the contrast, and can quantify the importance of different areas by calculating the first weight and the second weight.

[0069] 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.

[0070] In this embodiment, the center coordinates of the region of interest are determined, and a rectangular coordinate system is established with this as the center; for each block, the straight-line distance from its center to the center of the region of interest is calculated, and a distance weight is calculated based on the distance, and 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 region of no interest, making the final focusing effect more natural.

[0072] 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;

[0073] For the non-interested region, the second weight and the distance weight are fused to obtain the fourth weight of all blocks in the non-interested region, and the third weight and the fourth weight are normalized.

[0074] In this embodiment, the first weight and the distance weight are added to obtain the third weight of each block in the area of ​​interest; the second weight and the distance weight are added to obtain the fourth weight of each block in the non-area of ​​interest; then, the third weight and the fourth weight are normalized to ensure that the sum of the weights of all blocks is 1.

[0075] By fusing contrast weights and distance weights, the contrast and position information of the blocks can be comprehensively considered. At the same time, through normalization processing, the weights of all blocks are ensured to be within a reasonable range to avoid excessive or too small weights of some blocks.

[0076] 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.

[0077] In this embodiment, the normalized overall clarity of the target image is calculated based on the clarity of each block and the corresponding normalized third weight and fourth weight, and then the focus of the region of interest is adjusted based on the normalized overall clarity to maximize the overall clarity.

[0078] By calculating the overall clarity, the clarity of the image can be optimized and the image quality can be improved. At the same time, automatic focusing can highlight the area of ​​interest while maintaining the overall clarity of the image, 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 region of no interest in the target image.

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

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

[0083] S102: Evenly divide the target image into a plurality of equal-sized blocks according to a preset segmentation size.

[0084] In this embodiment, the target image is evenly divided into multiple equal-sized blocks according to a preset segmentation size. By dividing the target image into multiple equal-sized blocks, the large image can be effectively decomposed into smaller units, which facilitates independent processing of each block in subsequent steps, thereby improving the flexibility and efficiency of image processing.

[0085] 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.

[0086] In this embodiment, according to the boundary between the region of interest and the region of no interest determined in step S101, the block located in the region of interest is marked as the region of interest, and the block located in the region of no interest is marked as the region of no interest.

[0087] By marking blocks as interesting blocks or non-interesting blocks, different weights can be assigned to different types of blocks in subsequent steps, which helps to highlight the interesting areas while reducing the influence of non-interesting areas.

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

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

[0090] In this embodiment, for each block, the contrast is calculated, which can be specifically achieved by calculating the standard deviation of the pixel values ​​in the block. By calculating the contrast, the richness of the details in each block can be quantified.

[0091] 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:

[0092]

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

[0094]

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

[0096] In this embodiment, the first weight and the second weight are calculated based on the contrast between the blocks of interest and the blocks of no interest, so the importance of different areas can be quantified. A higher first weight means that the blocks in the area of ​​interest usually have a higher contrast and are therefore more worthy of attention. The second weight reflects the importance of the blocks in the area of ​​no interest, helping to determine the relative importance of the area of ​​no interest.

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

[0098] 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.

[0099] In this embodiment, first, the center coordinates of the region of interest are calculated. This can be achieved by calculating the geometric center of the bounding box of the region of interest. For example, if the coordinates of the upper left corner of the region of interest are (x1, y1) and the coordinates of the lower right corner are (x2, y2), then the center coordinates are Next, a rectangular coordinate system is established using this center coordinate as the origin of the rectangular coordinate system.

[0100] 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:

[0101]

[0102] Among them, D i represents the straight-line distance, (x i ,y i ) represents the center coordinates of the i-th block.

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

[0104] 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:

[0105]

[0106] 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.

[0107] In this embodiment, the distance weight is calculated according to the straight-line distance of each block. 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. The closer the distance is, the higher the weight is, and vice versa.

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

[0109] 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.

[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 the scaling process, the first weight, the second weight and the distance weight can be ensured to be at the same order of magnitude, which helps to avoid the offset caused by the magnitude difference when performing weight fusion in the subsequent steps.

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

[0112] 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:

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

[0114] Here, ω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 of the non-interest area:

[0117] 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:

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

[0119] Here, ω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 to obtain the fourth weight of each block.

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

[0122] In this embodiment, normalization processing can ensure that the sum of the weights of all blocks is 1, avoiding excessive or excessively small weights of some blocks, thereby ensuring the balance and consistency of the weights.

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

[0124] S501: performing weighted calculation on the clarity of each block according to the third weight and the fourth weight after corresponding normalization processing.

[0125] In this embodiment, for each block, a weighted calculation is performed based on its clarity and the corresponding normalized weight, wherein the third weight is used for the blocks within the area of ​​interest, and the fourth weight is used for the blocks within the non-area of ​​interest. The clarity can be calculated using methods including but not limited to edge detection.

[0126] By calculating the clarity in a weighted manner, we can ensure that the clarity of each block is combined with its importance, thereby better reflecting the clarity distribution of the entire image.

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

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

[0129] S503: Calculate the sum of all third weights and fourth weights to obtain a weight sum.

[0130] In this embodiment, the normalized weights of all blocks are summed to obtain the weight sum, which can ensure that the normalized overall clarity calculation in subsequent steps is more accurate.

[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 weighted sum to obtain the normalized overall clarity. The normalization process can ensure that the value of the overall clarity is associated with the weighted sum, thereby 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 an automatic focusing effect.

[0133] The working principle of the region of interest automatic focusing method provided by the present invention is as follows:

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

[0135] Next, the contrast of each block is calculated to reflect the detail richness of 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 contrast average of all blocks in the region, so that areas with higher contrast receive higher weights and thus receive more attention during the focusing process.

[0136] In order to further optimize the focusing process, distance weights are introduced. By establishing a rectangular coordinate system with the center of the ROI as the origin, the straight-line distance from the center of each block to the origin is calculated, and a distance weight is assigned to each block based on the distance. The closer the distance, the higher the weight, which means that when focusing, the area close to the center of the ROI will get a higher priority.

[0137] Then, the contrast weight and distance weight are fused to calculate a comprehensive weight for each block in ROI and Non-ROI. Before that, various weights need to be scaled to ensure that they are at the same level to facilitate subsequent calculations and comparisons. The fused weight takes into account both the contrast characteristics of the block and its positional relationship, thereby more accurately reflecting the importance of each block in the focusing process.

[0138] Finally, based on the normalized comprehensive weight, the normalized overall clarity of the target image is calculated. This indicator reflects the clarity of the entire image in a focused state, especially considering the priority of ROI. According to the change of the normalized overall clarity, the focusing parameters (such as lens position) are adjusted to achieve automatic focusing on the region of interest.

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

[0140] Embodiment 2

[0141] The present invention also provides an area of ​​interest automatic focusing system, which is used in the area of ​​interest automatic focusing method. Figure 2 As shown, the focusing system comprises:

[0142] 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;

[0143] 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;

[0144] 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;

[0145] 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;

[0146] 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;

[0147] 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.

[0148] The present application is described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0149] A person skilled 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 related hardware through a program, and the program can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.

[0150] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device that includes a series of elements includes not only those elements, but also other elements that are not explicitly listed, or includes elements that are inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device that includes the elements.

Claims

1. A method for automatically focusing on a region of interest, It is 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; 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; 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. A method for automatically focusing a region of interest according to claim 1, It is 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. A method for automatically focusing a region of interest according to claim 2, It is characterized in that 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-interest area, ω 1 represents the first weight, ω 2 represents the second weight, m ​​represents the set of all blocks in the region of interest, and n represents the set of all blocks in the non-region of interest.

4. A method for automatically focusing a region of interest according to claim 3, It is 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.

5. A method for automatically focusing a region of interest according to claim 4, It is characterized in that Step S4 includes the following steps: 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: oh 3 =ω 1 +oh 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: oh 4 =ω 2 +oh D (i) Among them, ω 4 represents the fourth weight; S403: normalizing the third weight and the fourth weight.

6. A method for automatically focusing a region of interest according to claim 5, It is 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.

7. 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 6, It is 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

  • Automatic focusing method and apparatus, computer device and storage medium

    CN108200342A

  • Automatic focusing method and device, equipment and storage medium

    CN113382155A

  • Focusing processing method and device, electronic equipment and storage medium

    CN113810615A

  • Automatic focusing method, system and device for target object

    CN117082343A

Cited By

  • Picture main body focusing method and device, equipment and storage medium

    CN121414776A