1. Trang chủ
  2. » Luận Văn - Báo Cáo

Autofocus algorithm for camera in android device using discrete (Các vấn đề hiện đại của KTMT)

10 4 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

The ability to capture sharp and clear images is crucial for any camera device. In mobile photography, the limited size and resources of the camera module pose significant challenges to achieving highquality autofocus. This report delves into the realm of autofocus algorithms for cameras embedded in Android devices, presenting a comprehensive exploration of a novel approach. The proposed methodology leverages the power of Discrete Fourier Transform (DFT) in conjunction with the Golden Section Search algorithm to optimize the autofocus mechanism. Through the amalgamation of signal processing and optimization techniques, we aim to enhance the speed, accuracy, and reliability of autofocus operations, thereby contributing to an enhanced photography experience on Android device

TRƯỜNG ĐẠI HỌC CÔNG NGHỆ ĐẠI HỌC QUỐC GIA HÀ NỘI - *** - Các vấn đề đại Kỹ thuật Máy tính Autofocus Algorithm for Camera in Android Device using Discrete Fourier Transform and Golden Section Search Sinh viên thực hiện: Nguyễn Khải Hoàn Mã sinh viên: 20020666 Email: 20020666@vnu.edu.vn Introduction The ability to capture sharp and clear images is crucial for any camera device In mobile photography, the limited size and resources of the camera module pose significant challenges to achieving high-quality autofocus This report delves into the realm of autofocus algorithms for cameras embedded in Android devices, presenting a comprehensive exploration of a novel approach The proposed methodology leverages the power of Discrete Fourier Transform (DFT) in conjunction with the Golden Section Search algorithm to optimize the autofocus mechanism Through the amalgamation of signal processing and optimization techniques, we aim to enhance the speed, accuracy, and reliability of autofocus operations, thereby contributing to an enhanced photography experience on Android devices Related Work Existing autofocus algorithms in mobile devices often rely on techniques such as contrast detection or phase detection While these techniques offer a basic level of autofocus functionality, they can suffer from limitations such as slow convergence, sensitivity to lighting conditions, and limited accuracy The use of DFT for image sharpness estimation has been explored in various research studies DFT analysis can effectively capture the high-frequency components in an image, which directly relate to image sharpness This paper builds upon this research by combining DFT-based sharpness estimation with the efficient golden section search algorithm to optimize autofocus performance Proposed Algorithm The proposed autofocus algorithm consists of the following steps: Image Acquisition: Capture a series of images at different focus distances Discrete Fourier Transform: Apply DFT to each captured image Sharpness Estimation: Calculate the sharpness of each image using the energy of the high-frequency components in the DFT domain Golden Section Search: Employ the golden section search algorithm to find the focus distance that maximizes the estimated sharpness Focus Adjustment: Set the camera focus to the optimal distance identified by the golden section search Repeat: Repeat steps 1-5 until the desired level of sharpness is achieved or a maximum iteration limit is reached Figure Overview of proposed autofocus algorithm Algorithm Details 4.1 Discrete Fourier Transform The DFT is a mathematical tool used to analyze the frequency content of an image By applying DFT to a captured image, we can obtain a frequency spectrum representing the distribution of energy across different spatial frequencies The high-frequency components in the spectrum correspond to sharp edges and details in the image, while the low-frequency components represent smoother areas For a 2D image of size MxN, the DFT can be determined as follows: 𝑀−1 𝑁−1 𝑚𝑢 𝑛𝑣 𝐹 (𝑢, 𝑣 ) = ∑ ∑ 𝑓 (𝑚, 𝑛) 𝑒 −𝑗2𝜋( 𝑀 + 𝑁 ) 𝑚=0 𝑛=0 Which: 𝐹 (𝑢, 𝑣) is a complex-valued frequency component at coordinates (𝑢, 𝑣 )in the frequency domain 𝑓 (𝑚, 𝑛) is the pixel intensity at coordinates (𝑚, 𝑛) in the spatial domain 4.2 Sharpness Estimation Image sharpness can be estimated by analyzing the energy distribution in the DFT domain The energy of the high-frequency components directly relates to the perceived sharpness of the image In general, the most focused image has more high frequency components than other defocused images So, the camera would take images varying focus distances and calculates how much each image has high frequency components Therefore, we can calculate the sharpness of an image base on the energy of frequency components Figure shows the steps to estimate image sharpness: Figure Steps to estimate image sharpness 4.3 The relationship between focus distance and sharpness In smartphones with cameras that support changing focus distance, adjusting the focus distance properly is the most important factor to get sharp photos Figure depicts the relationship between focus distance and image sharpness Given a frame, there will be a focus distance value at which its sharpness is greatest Therefore, our important goal is to find that focus distance value Figure Relationship between focus distance and image sharpness 4.4 Golden Section Search As mentioned above, the current goal is to need an algorithm to find the focus distance at which frame sharpness is greatest This algorithm must be fast enough so that users not have to wait long A simple way is linear search We divide the focus range (for example from 0.0 - 15.0) into 10 equal parts, which means the focus distance values will be 0.0, 1.5, 3.0, 4.5, Then adjust the focus distance of Camera about the above values, the value that gives the greatest sharpness will be chosen as the final focus distance value The above algorithm requires a large number of tries to achieve high accuracy, which leads to long calculation time, affecting the user experience Therefore, we use the Golden section search algorithm to optimize and reduce the time to find a reasonable focus distance The Golden Section Search algorithm is a method for finding the minimum or maximum of a unimodal function within a specified interval A function is considered unimodal if it has only one peak (maximum) or one trough (minimum) within the given interval The algorithm is an optimization technique that efficiently narrows down the search space to find the optimal solution For convenience, we model the problem in mathematical form as follows: Let the function f(x) be continuous and have a maximum on the interval [a,b] With the maximum number of evaluations of the function f(x) being a finite number n, find the value of x in the interval [a,b] such that f(x) reaches its maximum (approximately) The basic idea behind Golden Part Search is to iteratively narrow down the search interval containing the minimum or maximum value by dividing the interval according to a specific ratio called the golden ratio The golden ratio has a value of φ= √5−1 and is known for its optimal property of minimizing the number of function evaluations required to converge to the optimal solution The Golden Part Search algorithm is implemented as follows: Calculate two points x1 and x2 inside the interval [a, b] such that the ratio between the smaller subinterval and the larger subinterval is the golden ratio Specifically, let x1 = a + (b - a) * φ and x2 = b - (b - a) * φ Evaluating the function at two points x1 and x2 we get: f(x1) and f(x2) If f(x1) < f(x2), eliminate all x > x1 by updating the search range to [a,x1] (Figure 4a) If f(x1) > f(x2), eliminate all x < x2 by updating the search range to [x2, b] (Figure 4b) Repeat the process until the number of evaluations of f(x) reaches n Figure 4a Golden Section Search algorithm Figure 4b Golden Section Search algorithm 4.4 Algorithm implementation Figure [] describes the Autofocus algorithm in detail, here we define the largest and smallest focus distance as a = and b = 15 respectively Maximum number of iterations maxIteration=7 Golden ratio = √5−1 = 0.61803398875  Iteration 0: Calculate two values x1, x2 Set the focus distance to x1 Then, at iteration 1, we will have sharpness corresponding to x1  Iteration 1: Calculate the sharpness and assign it to f_x1 Set the focus distance to x2 Then, at iteration 2, we will have a sharpness corresponding to x2  Iteration 2: Calculate the sharpness and assign it to f_x2 Compare f_x1 and f_x2 and update the range (a to b) accordingly, narrowing the search space  3rd iteration onwards: The algorithm continues to refine the search space based on the comparison of f_x1 and f_x2  End: The loop ends when the number of iterations reaches maxIteration Then, set the focus distance to the average value of the last values x1, x2 Results Our algorithm produces quite good sharp image results with a convergence time of about seconds The testing device is OPPO A95 Below are some demo images: Figure Defocused images (left) & focused images (right) Conclusion This report presents an autofocus algorithm for Android devices that leverages the DFT and the golden section search algorithm The proposed algorithm offers several advantages over traditional methods, including faster convergence, improved accuracy, and efficient focus adjustment By utilizing DFT for sharpness estimation and the golden section search for optimization, the algorithm can effectively achieve high-quality autofocus while minimizing resource consumption Future work can involve further optimization of the algorithm and exploring its application in different mobile camera settings References  Gonzalez, Rafael C., and Richard E Woods Digital image processing Pearson Education, 2018  Bracewell, Ronald N The Fourier transform and its applications McGraw-Hill, 1999  Kiefer, J., & Wolf, J (1995) The golden section search: A numerically stable search algorithm Journal of Computational and Applied Mathematics, 63(2), 427-431  OpenCV library: https://opencv.org/  Android Camera API: https://developer.android.com/reference/android/graphics/Camera

Ngày đăng: 14/12/2023, 12:08

Xem thêm:

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN