1. Field of the Invention
The present invention relates to a focusing method for an image device, more particularly, to a method for moving a lens to a focal position when shooting a target object.
2. Description of the Prior Art
When an image device, such as a digital camera or a digital video recorder, is utilized for shooting a target object, the image device can initiate a focusing procedure to have a clearer image of the target object. In the conventional focusing procedure, the lens of the image device is moved back and forth so that the image device can take pictures of the target object at different lens positions. Each of the obtained images is then processed by the image device for calculating a corresponding focus value. Finally, a focal position for the lens is determined according to the plurality of focus values, and a clearer image can be obtained while shooting the target object with the lens at the determined focal position.
When determining the focal position and calculating the focus value for each image, one conventional method utilizes a gradient operator to generate the focus value by using every available pixels in an image. However, the above-mentioned method requires a significant amount of calculation to complete the focusing procedure. As the quantity of the pixels within an image increases, so does the burden of calculation and the time consumption.
In another conventional method for calculating a focus value of an image, the image is divided into a plurality of sub-blocks. The user of the image device may select one or more predetermined focusing blocks and have their focus values calculated. For example, as shown in
An objective of the claimed invention is to provide a focusing method for moving a lens to a focal position when shooting a target object. The focusing method comprises: photographing the target object respectively at a plurality of initial testing positions to determine an initial sampling position and a sampling direction; determining a plurality of candidate position according to the initial sampling position and the sampling direction; photographing the target object respectively with the lens at the plurality of the candidate positions to generate a plurality of candidate images; calculating at least a focus value corresponding to each candidate image; and determining the focal position according to the plurality of focus values corresponding to the candidate images.
The claimed invention also provides a focusing method for moving a lens to a focal position when shooting a target object. The focusing method comprises: photographing the target object respectively with the lens at a plurality of candidate position to obtain a plurality of candidate images; dividing each candidate image into a plurality of sub-blocks; calculating a plurality of focus values of sub-blocks corresponding to specific sub-block positions; and determining the focal position according to the focus values corresponding to the candidate images.
These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings.
Please refer to
Step 200: process starts;
Step 202: select two initial testing positions p1 and p2 for the lens; define a direction d1 as the direction from the initial testing position p1 to the initial testing position p2 and a direction d2 opposite to the direction d1;
Step 204: obtain an initial test image fp1 by photographing the target object with the lens at the initial testing position p1, and obtain an initial test image fp2 by photographing the target object with the lens at the initial testing position p2;
Step 206: calculate initial test focus value fv1 and initial test focus value fv2 corresponding to the initial test images fp1 and fp2, respectively;
Step 208: compare initial focus values fv1 and fv2; if the initial focus value fv2 is greater than the initial focus value fv1, then the process proceeds to step 210; otherwise, the process proceeds to step 212;
Step 210: set the initial testing position p2 as a candidate position t(1), and define n candidate positions t(2), t(3), . . . , and t(n+1) according to the direction d1; then the process proceeds to step 214;
Step 212: set the initial testing position p1 as a candidate position t(1), and define n candidate positions t(2), t(3), . . . , and t(n+1) according to the direction d2; then the process proceeds to step 214;
Step 214: divide the candidate image ft(1) corresponding to the candidate position t(1) into p sub-blocks, and calculate focus values for i sub-blocks among the p sub-blocks;
Step 216: select j greater focus values fv(x,y) and their corresponding sub-blocks b(x,y) among the calculated focus values of the i sub-blocks, wherein x=1, y=1˜j, and j≦i≦p;
Step 218: shoot the target object with the lens respectively at n candidate positions t(x) (x=2˜n+1) to obtain n corresponding candidate image ft(x) (x=2˜n+1);
Step 220: for each candidate image ft(x) (x=2˜n+1), divide the candidate image ft(x) into p sub-blocks with the same scheme utilized in Step 214, and calculate each focus value fv(x,1), fv(x,2), . . . , and fv(x,j) of each sub-block sb(x,1), sb(x,2), . . . , and sb(x,j), wherein the sub-block sb(x,1), sb(x,2), . . . , and sb(x,j) are respectively at substantially the same positions as sub-block sb(1,1), sb(2,2), . . . , and sb(1,j) in the candidate image ft(1);
Step 222: for each of the j designated positions of sub-blocks sb(x,y), select a greatest focus value M(y) (y=1˜j) from n+1 focus values fv(1,y), fv(2,y), . . . , and fv(n+1, y); identify each of the sub-block sb(x,y) corresponding to M(y);
Step 224: when no less than a predetermined number of identified sub-blocks sb(x,y) corresponding to M(y) mentioned in Step 222 having a common x value, the process proceeds to step 226; otherwise, the process proceeds to step 228;
Step 226: set the candidate position corresponding to the common x value mentioned in Step 224 as the focal position; process proceeds to step 232;
Step 228: for each x value (x=1˜n+1), sum up the focus values fv(x,1 ), fv(x,2), . . . , and fv(x,j) to generate an accumulated focus value fv_sum(x);
Step 230: select the greatest accumulated focus value fv_sum_M from n+1 accumulated focus values fv_sum(x), and set the candidate position corresponding to the greatest accumulated focus value fv_sum_M as the focal position; and
Step 232: end of the process.
The operation of the focusing procedure will be further explained with a preferred embodiment in the following paragraphs. Please refer to
In step 206, the initial test images fp1 and fp2 are divided respectively into a plurality of sub-blocks, and a portion of the sub-block is utilized for the calculation of initial focus values fv1 and fv2. Please refer to
Please note that the present invention is not limited to dividing an image into a six-by-six array of sub-blocks, the image can also be divided into sub-blocked having different quantities, shapes, or unevenly sizes. The present invention is also not limited to take only the central portion of the image into consideration when calculating the focus value. The present invention can be easily utilized with other combination of positions or quantities of sub-blocks in an image for calculating the focus value.
Please refer to
Next, the image device 20 photographs the target object 50 with the lens at n candidate position t(x) (x=2˜n+1) to obtain n corresponding candidate image ft(x) (x=2˜n+1) (step 218). Each of the n corresponding candidate image ft(x) is divided into p sub-blocks according to the method when dividing the candidate image ft(l), and each of the focus value fv(x,1), fv(x,2), . . . , and fv(x,j) of the sub-block sb(x,1), sb(x,2), . . . , sb(x,j) is calculated, wherein the sub-block sb(x,1), sb(x,2), . . . , and sb(x,j) are at the positions identical to the sub-block sb(1,1), sb(1,2), . . . , and sb(x,j) in the candidate image ft(1) (step 220). And the sub-blocks sb(x,y) (x=1˜+1, y=1˜j) become the focusing area when the image device 20 is shooting the target object 50. As Shown in
The image device 20 determines whether a predetermined number of sub-blocks sb(x,y) corresponding to M(y) having a common x value. In the preferred embodiment, the predetermined number is a smallest positive integer that is greater than j/2, which means that when j=3, the predetermined number is 2, and the image device 20 determines whether if there are at least two sub-blocks corresponding to focus values M(1), M(2), and M(3) having the same x value (step 224). If so, the candidate position corresponding to the x value is set as the focal position of the lens 22 (step 226, 230), and a clearer image can be obtained when shooting the target object 50 with the lens 22 at the focal position. In contrary, if the sub-blocks corresponding to the focus values M(1), M(2), and M(3) having different x values, the image device 20 sums up fv(x,1), fv(x,2), fv(x,3) to obtain an accumulated focus value fv_sum(x) for each candidate image ft(x) (x=1˜n+1) (step 228). After that, the image device 20 selects the greatest accumulated focus value fv_sum_M from n+1 accumulated focus value fv_sum, and sets the candidate position corresponding to the greatest accumulated focus value fv_sum_M as the focal position of the lens 22 (step 230, 232).
Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.
Number | Date | Country | Kind |
---|---|---|---|
094140992 | Nov 2005 | TW | national |