Auto focus method and apparatus using the same
09615020 ยท 2017-04-04
Assignee
Inventors
Cpc classification
H04N23/673
ELECTRICITY
International classification
G03B13/00
PHYSICS
Abstract
An auto focus method includes (a) obtaining a selected exposure value and an un-normalized contrast value; (b) executing a normalized contrast value obtaining procedure at each of the stepping positions; and (c) executing a focal point searching procedure according to the normalized contrast values. Accordingly, the normalization procedure is applied to eliminate the effect of the exposure value on the contrast value, so that the focal point of the image can be obtained correctly. In addition, an image capturing apparatus using the focus method is provided.
Claims
1. An auto focus method comprising: (a) obtaining a selected exposure value and an un-normalized contrast value, wherein the un-normalized contrast value corresponds to a stepping position; (b) executing a normalized contrast value obtaining procedure, wherein the normalized contrast value obtaining procedure comprises: (b1) obtaining a next un-normalized contrast value and a next exposure value of a next image at a next stepping position; (b2) determining if the next exposure value and the selected exposure value satisfy a renew condition, and renewing the selected exposure value when the next exposure value and the selected exposure value satisfy the renew condition; and (b3) obtaining a normalized contrast value corresponding to the un-normalized contrast value and a next normalized contrast value corresponding to the next un-normalized contrast value according to the renewed selected exposure value; and (c) executing a focal point searching procedure according to the normalized contrast value and the next normalized contrast value, wherein the focal point searching procedure comprises: (c1) determining if a reverse condition is satisfied according to the normalized contrast values; (c2) outputting the stepping position corresponding to the maximum of the normalized contrast values if the reverse condition is satisfied; and (c3) executing the normalized contrast value obtaining procedure if the reverse condition is not satisfied.
2. The auto focus method according to claim 1, wherein the step (a) comprises: obtaining a first image and a first exposure value and a first contrast value corresponding to the first image at a first stepping position; and setting the first exposure value as the selected value and setting the first contrast value as the un-normalized contrast value.
3. The auto focus method according to claim 1, wherein the renew condition is satisfied when the next exposure value is less than the selected exposure value, the step (b2) utilizes the next exposure value as the selected exposure value, and the step (b3) further comprises: obtaining the normalized contrast values according to a normalization formula, wherein the normalization formula is CV.sub.n=CV.sub.i2.sup.EVminEVi, wherein CV.sub.n are the normalized contrast values, CV.sub.i are the un-normalized contrast values, EV.sub.min is the selected exposure value, and the EV.sub.i are the exposure values.
4. The auto focus method according to claim 1, wherein the renew condition is satisfied when the next exposure value is greater than the selected exposure value, the step (b2) utilizes the next exposure value as the selected exposure value, and the step (b3) further comprises: obtaining the normalized contrast values according to a normalization formula, wherein the normalization formula is CV.sub.n=CV.sub.i2.sup.EVmaxEVi, wherein CV.sub.n is the normalized contrast value, CV.sub.i is the un-normalized contrast value, EV.sub.max is the selected exposure value, and the EV.sub.i is the exposure value.
5. The auto focus method according to claim 1, wherein the un-normalized contrast value is the average of the convolution values of a plurality of selected pixels of each of the images corresponding to the corresponding stepping position.
6. The auto focus method according to claim 5, wherein the selected pixels comprise all the pixels of the image.
7. The auto focus method according to claim 5, wherein the convolution value of the selected pixels is the convolution value of all the pixels of the image excluding the convolution value of oversaturated pixels of the image.
8. The auto focus method according to claim 7, wherein the oversaturated pixel is a pixel having a pixel value greater than an oversaturation threshold.
9. The auto focus method according to claim 8, wherein the convolution value of the selected pixels is the convolution value of all the pixels of the image excluding the convolution value of oversaturated pixels of the image and excluding the convolution value of noise pixels of the image.
10. The auto focus method according to claim 9, wherein the reverse condition is satisfied when the normalized contrast values have a relative maximum value.
11. An image capturing apparatus for executing an auto focus method, wherein the method comprises: (a) obtaining a selected exposure value and an un-normalized contrast value, wherein the un-normalized contrast value corresponds to a stepping position; (b) executing a normalized contrast value obtaining procedure, wherein the normalized contrast value obtaining procedure comprises: (b1) obtaining a next un-normalized contrast value and a next exposure value of a next image at a next stepping position; (b2) determining if the next exposure value and the selected exposure value satisfy a renew condition, and renewing the selected exposure value when the next exposure value and the selected exposure value satisfy the renew condition; and (b3) obtaining a normalized contrast value corresponding to the un-normalized contrast value and a next normalized contrast value corresponding to the next un-normalized contrast value according to the renewed selected exposure value; and (c) executing a focal point searching procedure according to the normalized contrast value and the next normalized contrast value, wherein the focal point searching procedure comprises: (c1) determining if a reverse condition is satisfied according to the normalized contrast values; (c2) outputting the stepping position corresponding to the maximum of the normalized contrast values if the reverse condition is satisfied; and (c3) executing the normalized contrast value obtaining procedure if the reverse condition is not satisfied.
12. The image capturing apparatus according to claim 11, wherein the step (a) comprises: obtaining a first image and a first exposure value and a first contrast value corresponding to the first image at a first stepping position; and setting the first exposure value as the selected value and setting the first contrast value as the un-normalized contrast value.
13. The image capturing apparatus according to claim 11, wherein the renew condition is satisfied when the next exposure value is less than the selected exposure value, the step (b2) utilizes the next exposure value as the selected exposure value, and the step (b3) further comprises: obtaining the normalized contrast values according to a normalization formula, wherein the normalization formula is CV.sub.n=CV.sub.i2.sup.EVminEV1 wherein CV.sub.n are the normalized contrast values, CV.sub.i are the un-normalized contrast values, EV.sub.min is the selected exposure value, and the EV.sub.i are the exposure values.
14. The image capturing apparatus according to claim 11, wherein the renew condition is satisfied when the next exposure value is greater than the selected exposure value, the step (b2) utilizes the next exposure value as the selected exposure value, and the step (b3) further comprises: obtaining the normalized contrast values according to a normalization formula, wherein the normalization formula is CV.sub.n=CV.sub.i2.sup.EVmaxEVi, wherein CV.sub.n is the normalized contrast value, CV.sub.i is the un-normalized contrast value, EV.sub.max is the selected exposure value, and the EV.sub.i is the exposure value.
15. The image capturing apparatus according to claim 11, wherein the un-normalized contrast value is the average of the convolution values of a plurality of selected pixels of each of the images corresponding to the corresponding stepping position.
16. The image capturing apparatus according to claim 15, wherein the selected pixels comprise all the pixels of the image.
17. The image capturing apparatus according to claim 15, wherein the convolution value of the selected pixels is the convolution value of all the pixels of the image excluding the convolution value of oversaturated pixels of the image.
18. The image capturing apparatus according to claim 17, wherein the oversaturated pixel is a pixel having a pixel value greater than an oversaturation threshold.
19. The image capturing apparatus according claim 18, wherein the convolution value of the selected pixels is the convolution value of all the pixels of the image excluding the convolution value of oversaturated pixels of the image and excluding the convolution value of noise pixels of the image.
20. The image capturing apparatus according to claim 19, wherein the reverse condition is satisfied when the normalized contrast values have a relative maximum value.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
(1) The disclosure will become more fully understood from the detailed description given herein accompanying by the following figures, which are illustration only, and thus not limitative of the disclosure, wherein:
(2)
(3)
(4)
(5)
(6)
(7)
(8)
(9)
(10)
DETAILED DESCRIPTION
(11)
(12) The contrast focus method utilizes the change of the contrast values to figure out the focus position at where the image has the highest sharpness; i.e., it is supposed that, the higher the contrast value of an image is, the better the sharpness of the image is. In
(13) In addition to the auto focus function which ensures the image to have a sufficient sharpness, an image capturing apparatus further has an auto exposure function. During the auto exposure procedure, the image capturing apparatus calculates the amount of light of a current capturing image according to a default metering mode or a user-selected metering mode, so that the exposure value for image capturing can be adjusted to meet a preset output brightness. Hence, overexposure or underexposure of the image can be prevented.
(14)
(15)
(16) The pixel value for calculating the convolution value may be a single-colored gray-scale value, any value of the RGB values, or an overall RGB value. Even more, pixels obtained from other chromatic coordinates can be applied to calculate the convolution value as well.
(17) Normally, the auto focus function and the auto exposure function are continuously executing during the focus procedure of video recording or image capturing. When the metering mode is changed, when the ambient brightness is changed, or when the scene of the image is dramatically changed, the auto exposure function may determine that the brightness is improper for the focus procedure so as to adjust the exposure value. Therefore, conditions illustrated in
(18)
(19) Because the average contrast value of the image obtained in the exposure value of +1 EV is twice of the average contrast value of the image obtained in the exposure value of 0 EV, the point having the highest contrast value will be cv45, instead of cv50. Therefore, the focal point cannot be determined correctly.
(20)
(21) In the normalized contrast value obtaining procedure (b), following embodiments can be applied thereto. According to an auto focus method of a first embodiment of the instant disclosure, a minimum exposure value is taken as the selected exposure value. In other words, the renew condition means the next exposure value is taken as the selected exposure value when the next exposure value is less than the selected exposure value. That is, the minimum of all the exposure values obtained at different stepping positions is taken as the selected exposure value.
(22) During the focusing procedure, a first image, a first exposure value, and a first contrast value are obtained at a first stepping position. The first exposure value and the first contrast value correspond to the first image. In the step, the first exposure value is set as the selected exposure value, and the first contrast value is set as the un-normalized contrast value.
(23) And then, a second image, a second exposure value, and a second contrast value are obtained at a second stepping position. The second exposure value and the second contrast value correspond to the second image. The second exposure value is determined if it is less than the first exposure value. If the second exposure value is greater than the first exposure value, the first exposure value is still taken as the selected exposure value; while if the second exposure value is less than the first exposure value, then the second exposure value is taken as the selected exposure value. Next, the normalized contrast value at the first stepping position is calculated and obtained according to the new selected exposure value, the first contrast value, and the first exposure value. And, the normalized contrast value at the second stepping position is calculated and obtained according to the new selected exposure value, the second contrast value, and the second exposure value.
(24) Next, a third image, a third exposure value, and a third contrast value are obtained at a third stepping position. The third exposure value and the third contrast value correspond to the third image. The third exposure value is determined if it is less than the selected exposure value. If the third exposure value is greater than the selected exposure value, the selected exposure value is remained; while if the third exposure value is less than the selected exposure value, the third exposure value is taken as the selected exposure value. Next, the normalized contrast value at the third stepping position is calculated and obtained according to the new selected exposure value, the third contrast value, and the third exposure value. And, the normalized contrast values at the first and second stepping positions are recalculated and re-obtained according to the new selected exposure value.
(25) Similarly, the exposure values and contrast values at a fourth stepping position, a fifth stepping position . . . and a last stepping position are calculated and obtained. When the renew condition is satisfied, i.e., when an even smaller exposure value is available, the selected exposure value is renewed by the smaller exposure value, the normalized contrast values at different stepping positions which are satisfied with the renewed selected exposure value are calculated and obtained, and the normalized contrast values at different stepping positions which are already obtained are renewed accordingly.
(26) According to the first embodiment of the instant disclosure, the auto focus method utilizes a normalization formula to obtain the normalized contrast value.
(27) The normalization formula is
CV.sub.n=CV.sub.i2 EV.sup.minEVi
(28) Wherein, CV.sub.n is the normalized contrast value, CV.sub.i is the un-normalized contrast value of the image obtained at the i-th stepping position, EV.sub.min is the selected exposure value, and the EV.sub.i is the exposure value of the image obtained at the i-th stepping position.
(29) According to the method, the un-normalized contrast value is the average value of the convolution values of a plurality of selected pixels of each of the images corresponding to the corresponding stepping position. The selected pixels may comprise all the pixels of the image.
(30) The calculation of the contrast value of the image corresponding to each of the stepping positions is described as:
Filter=[a.sub.1 a.sub.2 . . . a.sub.n]
CON=[a.sub.1X1+a.sub.2X2+ . . . +a.sub.nXn]
CV=(Sum of all CON)/CV.sub.count
(31) Wherein, Filter means a high pass filter for obtaining the convolution value of the image, a.sub.1a.sub.n are the filter value (or called the weighting parameter for calculating the convolution value), X1Xn are the pixel values (commonly, the brightness values are taken as the pixel values), CON is the convolution value of the image, Sum of all CON is the summation of all the convolution values, and CV.sub.count is the counting amount of all the convolution values.
(32) Take a simple example, when a high pass filter Filter[11] is applied, the convolution value of the two pixels X1 and X2 at the same stepping position shown in
(33) When the exposure value is 0 EV:
Filter=[1 1]
CON=[150+1100]
CV=(50)/1
CV.sub.n=502.sup.00=50
(34) When the exposure value is +1 EV:
Filter=[1 1]
CON=[1100+1200]
CV=(100)/1
CV.sub.n=1002.sup.01=50
(35) Accordingly, the incorrect contrast value caused by the change of the exposure value can be corrected by the normalization step, and the contrast value can be prevented from being determined incorrectly.
(36) In a second embodiment of the instant disclosure, a maximum exposure value EV.sub.max is taken as the selected exposure value. In other words, the renew condition means the next exposure value is taken as the selected exposure value when the next exposure value is greater than the selected exposure value. That is, the maximum of all the exposure values obtained at different stepping positions is taken as the selected exposure value.
(37) The normalization formula of the second embodiment is CV.sub.n=CV.sub.i2.sup.EV maxEVi.
(38) Wherein, CV.sub.n is the normalized contrast value, CV.sub.i is the un-normalized contrast value of the image obtained at the i-th stepping position, EV.sub.max is the selected exposure value, and the EV.sub.i is the exposure value of the image obtained at the i-th stepping position.
(39) Similarly, the convolution value of the two pixels shown in
(40) When the exposure value is +1 EV, CV=1002.sup.11=100.
(41) When the exposure value is 0 EV, CV=502.sup.10=100.
(42) Accordingly, the incorrect contrast value caused by the change of the exposure value can be corrected by the normalization step, and the contrast value can be prevented from being determined incorrectly.
(43) Moreover, when some of the pixels receive light with intensity higher than their saturation intensities, those pixels will output their highest values. Therefore, all the oversaturated pixels are unable to output corresponding pixel values in accordance with the received intensities. For example, when the highest value the hardware (the pixels) can express (output) is 255, all the oversaturated pixels will be outputted as 255. Accordingly, an error in the calculation of the contrast value would occur.
(44) Therefore, according to an auto focus method of a third embodiment of the instant disclosure, the convolution value of the selected pixels is the convolution value of all the pixels of the image excluding the convolution value of oversaturated pixels of the image. The oversaturated pixel is a pixel having a pixel value greater than an oversaturation threshold.
(45) In obtaining the contrast value according to the embodiment, following calculations are carried out:
Filter=[a.sub.1 a.sub.2 . . . a.sub.n]
CON.sub.1=[a.sub.1X1+a.sub.2X2+ . . . +a.sub.nXn] if X.sub.1 X.sub.2 . . . Xn<saturation_TH
CV=(Sum of all CON.sub.1)/CV.sub.count
(46) In other words, when one of the pixel values exceeds the saturation threshold (saturation_TH), the summation of the convolution values would exclude that pixel, and the counting amount of all the convolution values (CV.sub.count) will minus one. The saturation threshold is designated according to the hardware efficiency. Supposed that the highest value the pixel can output is 255, then, the saturation threshold can be designated as 250. Therefore, not only enough samples can be obtained for the calculation, but also those incorrect values can be excluded from the calculation.
(47) Moreover, the calculation efficiency can be improved and the contrast values can be determined correctly.
(48)
(49)
CON.sub.X1-X2=[150+1100]=50
CON.sub.X2-X3=[1100+1150]=50
CV.sub.count=2
CV=(CON.sub.X1-X2+CON.sub.X2-X3)/CV.sub.count=50
(50)
CON.sub.X1-X2=[1100+1200]=100
CON.sub.X2-X3 in which X3>saturation_TH
CV.sub.count=21
CV=(CON.sub.X1-X2)/1=100
(51) Because the exposure values are different in
(52) In
(53) In
(54) In addition, if the obtained images have too many noises, the determination and the calculation speed of the contrast values would be affected. Therefore, according to an auto focus method of a fourth embodiment of the instant disclosure, the convolution value of the selected pixels is the convolution value of all the pixels of the image excluding the convolution value of oversaturated pixels of the image and excluding the convolution value of noise pixels of the image.
(55) In obtaining the contrast value according to the embodiment, following calculations are carried out:
Filter=[a.sub.1 a.sub.2 . . . a.sub.n]
CON.sub.1=[a.sub.1X1+a.sub.2X2+ . . . +a.sub.nXn] if X1 X2 . . . Xn<saturation_TH else
CON.sub.2=CON.sub.1/2.sup.noise.sup._.sup.TH
If CON.sub.21, then CV.sub.count=CV.sub.count+1
CV=(Sum of all CON.sub.2)/CV.sub.count
(56) Wherein, noise_TH represents the noise threshold. When CON.sub.21, the convolution value CON.sub.1 is valid, and the CV.sub.count plus one (namely, CV.sub.count=CV.sub.count+1). Conversely, when CON.sub.2<1, the convolution value CON.sub.1 is indeed a noise and not be calculated. Hence, the CV.sub.count does not plus one.
(57) In executing the focal point searching procedure (c), following embodiments may be applied. According to an auto focus method of a fifth embodiment of the instant disclosure, the reverse condition is satisfied when the normalized contrast values have a relative maximum value.
(58) As mentioned in the foregoing embodiment, after the normalized contrast value obtaining procedure (b) is completed, the curve shown in
(59) In an auto focus method of a sixth embodiment of the instant disclosure, it is no need to calculate all the contrast values at all the stepping positions, which is different from the fifth embodiment. Supposed that in a normal condition, each of the images has one optimal focal point, namely, the curve can have one highest value.
(60)
(61) While if the answer is no, which means the current contrast value is less than the previous contrast value, or the position where the curve reverse occurs. In
(62)
(63) When the image processing module 20 outputs a stepping position corresponding to the maximum normalized contrast value, the driving unit 120 moves the focus lens to the stepping position.
(64) While the instant disclosure has been described by the way of example and in terms of the preferred embodiments, it is to be understood that the invention need not be limited to the disclosed embodiments. On the contrary, it is intended to cover various modifications and similar arrangements included within the spirit and scope of the appended claims, the scope of which should be accorded the broadest interpretation so as to encompass all such modifications and similar structures.