1. Field of Invention. The present invention is related to digital camera auto-focus and in particular Sobel calculations and normalization.
2. Description of related art.
In the digital cameras of today automatic lens focus (auto-focus) is critical for producing pictures that the user expects and desires. The digital camera provide a continuous image before and during the operation to take a picture, and changes as the user moves the camera to take a picture ranging from close-up pictures to distant pictures of buildings and landscape. The movement of an auto-focus lens at the same time a picture is being focused provides a complex situation that the focusing algorithms built into the camera must control.
US Patent Application Publication No. 2009/0115886 A1 (Chen) is directed to an auto focus method for a digital camera, wherein a single image is used to obtain a lens focal position by using an edge detection algorithm to compute distance to an object. US Patent Application Publication No. 2009/0102963 A1 (Yeo et al.) is directed to an auto focus image system, which includes an image sensor coupled to a controller that captures an image that has at least one edge with a width, wherein the controller generates a focus signal that is a function of the edge width. In US Patent Application Publication No. 2008/0181595 A1 (Pnueli et al.) a focusing method is directed to receiving a focusing image and shifting the focusing image to obtain a shifted focusing image whereby a focus metric is calculated from the focusing image and the shifted focusing image. US Patent Application Publication No. 2007/0002152 A1 (Fujiwara) is directed to a digital camera that has an edge enhancing section to enhance edges of image data whereby a focus is determined to be good or bad and adjusts the degree of edge enhancement wherein focusing time is shortened. In U.S. Pat. No. 7,283,663 B2 (Sobel et al.) a method and apparatus is directed to interpolating color image information wherein a processor determines whether there is an edge in the vicinity of a target pixel in which long scale interpolation is performed on image data if there is not an edge in close proximity of the target pixel. In U.S. Pat. No. 7,280,149 B2 (Weintroub et al.) a technique is directed to measuring optimum focus position of a lens in a digital camera, wherein a compressed file associated with an image size increases monotonically as an image is brought into focus. U.S. Pat. No. 5,563,658 (Parulski et al.) is directed to a technique for focusing a digital camera wherein the average contrast of a central portion of an image is used to determine the focus of an image.
Controlling the movement of the auto-focus lens in concert with focus detection algorithm is essential to producing a well-focused image. It is essential that a new image be not formed before the previous image is analyzed for focus quality, and the lens adjusted accordingly.
It is an objective of the present invention to stop a lens focus motor of a digital camera to setup a focus window from which a Sobel and a Luminance value are extracted to determine image focus and calculate a new focus motor position. Care must be taken that the motor movement does not influence the Sobel value, which means that there is no motor movement when the integration of the actual image starts.
It is also an objective of the present invention to shift the Sobel value (Sobelval) and the luminance value (Lumval) to provide accuracy in calculating the ratio of Sobelval/Lumval to determine sharpness of an image.
In the present invention an auto-focus of a digital camera is performed by measuring the sharpness of an image, or the sharpness of a portion of an image to determine the focus of the lens of the digital camera. To determine the focus of the lens adjustment point set by a position of focus motor, a calculation of a focus value is made wherein focus value=Sobelval/Lumval. The Sobelval is a measure of the sharpness of an edge in the image or image portion and the Lumval is a measure of the brightness in the vicinity of the edge. Both the Sobelval and the Lumval are shifted until they are in a given range to provide the best accuracy (e.g. Sobelval must be in the range between 2exp29 and 2exp30). The Lumval itself is shifted proportional to the number of bits the Sobelval is shifted.
When obtaining a focus of an image of a digital camera, a lens focus motor adjusts a movable lens set toward a focus point. Care must be taken that the next image, which is used for focus calculation is without influence of the previous motor movement. A delay is used with the same value as the actual integration time to prevent the influence of a moving motor during image integration. Normally the delay is handled by a series of IRQs, but also could be created with a timer. After an integrated image without motor movement is detected a Sobel window is set up comprising a portion of interest of the image being evaluated for focus quality. The aforementioned values of Sobelval and Lumval are fetched and are shifted into a given range. The quality (goodness) of the present focus is evaluated by calculating focus value=Sobleval/Lumval. Then the lens motor is moved to a new position in an attempt to find the optimum position of the adjustable lens driven by the lens focus motor
This invention will be described with reference to the accompanying drawings, wherein:
In
To get best accuracy of the resulting focus value the Sobel value (Sobelval) is shifted to the right or to the left until the resulting value is within a given range. This approach is needed because the Sobelval is hardly influenced by the luminance of the scene that is being focused. By shifting the Sobelval into a predefined range the resulting focus value gets a comparable value.
If the Sobelval exceeds a given upper range it is shifted to the right to reduce the Sobelval. A shift to the right means a truncation of the lower ordered bits. If the Sobelval is below a given lower range it is shifted to the left to increase the value. The additional used lower ordered bits are filled with 0 (zero) when shifting to the left. After these shift operations the resulting Sobelval is between the lower and upper boundaries of the given range. After the Sobelval is shifted, the amount of shifted bits is used to shift the Lumval in the same way to get into the same output range.
A focus value of the image, or a portion of the image, is calculated 13 by dividing the Sobel value by the luminance value. This division is necessary to minimize the luminance influence of the Sobelval. The Sobelval is influenced by different aspects of luminance, comprising, lens position effects on image luminance and flicker from artificial light (50/60HZ). When the Sobelval is normalized by the Lumval the luminance influence on the resulting focus value can be minimized. The normalization is necessary to increase reliability of the focus system because the resulting focus value for the same scene at different lightning conditions is almost the same.
The autofocus system checks if an additional movement is needed to find the best focusing point. If no additional movement is needed 14 the sequence is stopped 15 wherein the best focusing point is found or an error has occurred. If the best focus position has not been found 16, the focus motor is moved to a new calculated position 17. After waiting for the focus motor to finish movement, the next usable image is acquired 18, and the next image is analyzed 10.
In
The Lumval is also shifted into a given range 23. The Lumval must be shifted in the same way than the Sobelval is shifted. If the Sobelval is shifted to the left the Lumval is also shifted to the left 24, or if the Sobelval is shifted to the right the Lumval is also shifted to the right 25. The shift between Sobelval and Lumval should be proportional. After a focus value is calculated the autofocus algorithm determines the next focus motor position. This sequence (motor movement, sobel/lum calculation, next motor position calculation) is handled in a loop until a focus position is found or an error occurrs and no focus could be found.
In
A variable indicates how many bits the Sobelval is shifted to the left or right. Before starting this value is set to zero 30. The examined Sobelval from the focus window (Sobel window) is checked to see if the value exceeds the upper limit of a given range. If the Sobelval exceeds this limit 31, the Sobelval is shifted to the right by one bit. The lowest bit is truncated and the variable handling the number of shifted bits is decreased 32. The new Sobelval is again checked for the value exceeding the upper limit of the range. If the value is now within the range 33, the lower range of the Sobelval is checked in a similar fashion 33. If the Sobelval exceeds the upper limit, the value is shifted to the right for an additional bit. This loop is performed until the Sobelval is below the upper limit of the range.
After the upper limit is checked the resulting Sobelval is checked against the lower limit of the range. If the value is below the lower limit 34, the Sobelval is shifted to the left by one bit 35. The lowest bits are filled with 0 (zero) when shifting to the left. The variable handling the number of shifted bits is increased 35. If the value is now within the range 36, the Lumval is checked 37 and should be shifted proportional to the Sobelval . If the Sobelval is below the lower limit, the value is shifted to the left for an additional bit. This loop is performed until the Sobelval exceeds the lower limit of the range.
To shift the Lumval similarly to the Sobelval the number of shifted bits is used to check if the Lumval needs to be shifted to the left or to the right. The variable, which handles the number of shifted bits, is checked. If it is above a given upper shift limit 38, the Lumval is shifted to the right 39. The lowest bits are truncated when shifting to the right, and the number of shifted bits is decreased 39. The new number of shifted bits is again checked to see if it is above the given limit. If the value is now within the expected range 40, the upper limit of the shifted bits is checked . If the number of bits is below the upper limit the Lumval is shifted to the right for an additional bit.
After the upper limit of the number of shifted bits is checked, the Lumval is checked against the lower limit. If the number of shifted bits exceeds the lower shifted bits limit 41, the Lumval is shifted to the left. Lowest bits are filled with 0 (zero), and the number of shifted bits is increased 42. If the number of shifted bits is within the given range the Lumval is shifted into the correct range , the focus value is calculated 44.
The Lumval sequence is needed to take care that the Lumval is shifted in the same way that the Sobelval is shifted. The resulting focus value is a normalization of the Sobelval by the Lumval. By shifting both values into given ranges the resulting value is always in the same output range. The dependency of the luminance can be mostly eliminated and the Sobelval is now divided by the Lumval, which leads to the resulting sharpening value (focus value) 44.
In
While the invention has been particularly shown and described with reference to preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made without departing from the spirit and scope of the invention.
This application is related to U.S. patent application docket number DI09-020, Ser. No. ______, filed on ______ , and assigned to the same assignee as the present invention, and which is herein incorporated by reference in its entirety.