Electronic device for auto focusing function and operating method thereof

A method and an apparatus for operating an electronic device is provided. A first image is obtained at a first position of a focus lens of a camera module of the electronic device. The first image is output through a display. A second image is obtained at a second position of the focus lens while the first image is being output. A defocus amount of the focus lens at the second position is calculated based on the first image and the second image. An on-focus region is detected based on the calculated defocus amount.

PRIORITY

This application is based on and claims priority under 35 U.S.C. § 119(a) to Korean Patent Application No. 10-2019-0030396, filed on Mar. 18, 2019, in the Korean Intellectual Property Office, the entire disclosure of which is incorporated herein by reference.

BACKGROUND

The disclosure relates an electronic device having an auto focusing function and, more particularly, to an electronic device capable of removing wobbling that occurs while an auto focusing function is performed, and an operating method thereof.

2) Description of Related Art

Electronic devices are typically mounted with a camera, such as, for example, a digital camera, a digital camcorder, or a smartphone. These electronic devices equipped with a camera can provide a photographing function. For example, an electronic device can output a preview image on a display using an image obtained in real-time from a camera, and then can acquire an image taken by the camera when receiving an input for photographing.

Further, electronic devices provide an auto focusing function that automatically adjusts a focus on an object.

In general, an auto focusing function adjusts the focus on an object by moving a lens included in a camera back and forth, and an electronic device can output an image received through the camera while the auto focusing function is performed, as a preview image or a live view, through a display. However, the field of view of an image that is output on the display may shake (e.g., wobble) due to frequent movement of a focus lens while the auto focusing function is performed.

SUMMARY

Accordingly, embodiments of the disclosure provide an electronic device for performing auto focusing without shaking of an image in the electronic device, and a method of operating the electronic device.

According to an embodiment, an electronic device is provided that includes a camera module including a focus lens, a display, and a processor. The processor is configured to control the camera module to obtain a first image at a first position of the focus lens, and control the display to output the first image. The processor is also configured to control the camera module to obtain a second image at a second position of the focus lens while the first image is being output, and calculate a defocus amount of the focus lens at the second position based on the first image and the second image. The processor is further configured to detect an on-focus region on the basis of the calculated defocus amount.

According to an embodiment, a method of operating an electronic device is provided. A first image is obtained at a first position of a focus lens of a camera module of the electronic device. The first image is output through a display. A second image is obtained at a second position of the focus lens while the first image is being output. A defocus amount of the focus lens at the second position is calculated based on the first image and the second image. An on-focus region is detected based on the calculated defocus amount.

DETAILED DESCRIPTION

Embodiments of the disclosure are described in detail with reference to the accompanying drawings. The same or similar components may be designated by the same or similar reference numerals although they are illustrated in different drawings. Detailed descriptions of constructions or processes known in the art may be omitted to avoid obscuring the subject matter of the disclosure. Further, the following terminologies are defined in consideration of the functions in the disclosure and may be construed in different ways by the intention or practice of users and operators. Therefore, the definitions thereof should be construed based on the contents herein.

FIG. 1is a block diagram illustrating an electronic device in a network environment, according to an embodiment.

The memory130may store various data used by at least one component (e.g., the processor120or the sensor module176) of the electronic device101. The various data may include, for example, software (e.g., the program140) and input data or output data for a command related thereto. The memory130includes the volatile memory132and the non-volatile memory134.

The program140may be stored in the memory130as software, and includes, for example, an operating system (OS)142, middleware144, and an application146.

The input device150may receive a command or data to be used by another component (e.g., the processor120) of the electronic device101, from the outside (e.g., a user) of the electronic device101. The input device150may include, for example, a microphone, a mouse, a keyboard, or a digital pen (e.g., a stylus pen).

The camera module180may capture a still image or moving images. The camera module180may include one or more lenses, image sensors, image signal processors, or flashes.

The power management module188may manage power supplied to the electronic device101. The power management module188may be implemented as at least part of a power management integrated circuit (PMIC).

The battery189may supply power to at least one component of the electronic device101. The battery189may include a primary cell which is not rechargeable, a secondary cell which is rechargeable, or a fuel cell.

FIG. 2is a block diagram illustrating a camera module, according to an embodiment.

Referring to a block diagram200ofFIG. 2, the camera module180ofFIG. 1includes a lens assembly210, a flash220, an image sensor230, an image stabilizer240, memory250(e.g., buffer memory), and an image signal processor260. The lens assembly210may collect light emitted or reflected from an object whose image is to be taken. The lens assembly210may include one or more lenses. The camera module180may include a plurality of lens assemblies210. The camera module180may form, for example, a dual camera, a 360-degree camera, or a spherical camera. Some of the plurality of lens assemblies210may have the same lens attribute (e.g., view angle, focal length, auto-focusing, f number, or optical zoom), or at least one lens assembly may have one or more lens attributes different from those of another lens assembly. The lens assembly210may include a wide-angle lens or a telephoto lens.

The flash220may emit light that is used to reinforce light reflected from an object. The flash220may include one or more light emitting diodes (LEDs) (e.g., a red-green-blue (RGB) LED, a white LED, an infrared (IR) LED, or an ultraviolet (UV) LED) or a xenon lamp. The image sensor230may obtain an image corresponding to an object by converting light emitted or reflected from the object and transmitted via the lens assembly210into an electrical signal. The image sensor230may include one selected from image sensors having different attributes, such as, for example, a RGB sensor, a black-and-white (BW) sensor, an IR sensor, or a UV sensor, a plurality of image sensors having the same attribute, or a plurality of image sensors having different attributes. Each image sensor included in the image sensor230may be implemented using a charged coupled device (CCD) sensor or a complementary metal oxide semiconductor (CMOS) sensor.

The image stabilizer240may move the image sensor230or at least one lens included in the lens assembly210in a particular direction, or control an operational attribute (e.g., adjust the read-out timing) of the image sensor230in response to the movement of the camera module180or the electronic device101including the camera module180. This allows compensating for at least part of a negative effect (e.g., image blurring) by the movement on an image being captured. The image stabilizer240may sense such a movement by the camera module180or the electronic device101using a gyro sensor or an acceleration sensor disposed inside or outside the camera module180. The image stabilizer240may be implemented, for example, as an optical image stabilizer.

The memory250may store, at least temporarily, at least part of an image obtained via the image sensor230for a subsequent image processing task. If image capturing is delayed due to shutter lag or multiple images are quickly captured, a raw image obtained (e.g., a Bayer-patterned image, a high-resolution image) may be stored in the memory250, and its corresponding copy image (e.g., a low-resolution image) may be previewed via the display device160. Thereafter, if a specified condition is met (e.g., by a user's input or system command), at least part of the raw image stored in the memory250may be obtained and processed, for example, by the image signal processor260. The memory250may be configured as at least part of the memory130or as a separate memory that is operated independently from the memory130.

The image signal processor260may perform one or more image processing with respect to an image obtained via the image sensor230or an image stored in the memory250. The one or more image processing may include depth map generation, three-dimensional (3D) modeling, panorama generation, feature point extraction, image synthesizing, and/or image compensation (e.g., noise reduction, resolution adjustment, brightness adjustment, blurring, sharpening, or softening). Additionally or alternatively, the image signal processor260may perform control (e.g., exposure time control or read-out timing control) with respect to at least one (e.g., the image sensor230) of the components included in the camera module180. An image processed by the image signal processor260may be stored back in the memory250for further processing, or may be provided to an external component (e.g., the memory130, the display device160, the electronic device102, the electronic device104, or the server108) outside the camera module180. The image signal processor260may be configured as at least part of the processor120, or as a separate processor that is operated independently from the processor120. If the image signal processor260is configured as a separate processor from the processor120, at least one image processed by the image signal processor260may be displayed, by the processor120, via the display device160as it is or after being further processed.

The electronic device101may include a plurality of camera modules180having different attributes or functions. At least one of the plurality of camera modules180may form a wide-angle camera and at least another of the plurality of camera modules180may form a telephoto camera. Similarly, at least one of the plurality of camera modules180may form a front camera and at least another of the plurality of camera modules180may form a rear camera.

FIG. 3is diagram illustrating an auto focusing operation of an electronic device, according to an embodiment.

Referring toFIG. 3, the electronic device includes a camera module180, a processor120, and a display160.

According to an embodiment, the camera module180includes a focus lens310and an actuator312.

The focus lens312can collect light emitted from an object that is the target for taking images. According to an embodiment, it is possible to adjust the focus of a lens assembly (e.g., the lens assembly210ofFIG. 2) by adjusting the position of the focus lens310. For example, the focus lens310can be moved to an on-focus region.

The actuator312can drive the focus lens310. The actuator312can move the focus lens410to the on-focus region such that an on-focus state is entered. The actuator312may include a servo motor or an ultrasonic motor and may be referred as an auto focusing motor, etc. However, this is only an example and embodiments are not limited thereto. The actuator312may be implemented by various auto focusing motors that can move the focus lens312to the on-focus region.

The processor120includes an image analyzer320, a defocus amount calculator322, and an output controller324.

The processor120can generate an on-focus image by performing the auto focusing function. The on-focus image may be an image focused on an object. The auto focusing function may include a search position determination operation and an on-focus region detection operation. The search position determination operation may be an operation that determines a start position of the on-focus region detection operation. The on-focus region detection operation may be an operation that moves the focus lens310step by step to the on-focus region based on a search position. The search position determination operation and the on-focus region detection operation may be referred to by various names.

The processor120can perform the search position determination operation using various techniques known in the art. The processor120can determine a search position based on a defocus amount of the focus lens310. The defocus amount may be a value that shows the degree of departure from the on-focus region of the focus lens310. For example, the image analyzer320of the processor120can calculate a focus signal value by performing frequency analysis on at least a portion of a first image and at least a portion of a second image, in which the first image and the second image have different focuses. The defocus amount calculator322of the processor120can calculate a defocus amount based on the focus signal value. The focus signal value may be associated with a blur image between the first image (or a portion of the first image) and the second image (or a portion of the second image). However, this is only an example and embodiments are not limited thereto. The processor120may use a contrast between the first image and the second image, or a phase difference between the first image and the second image, as the focus signal value.

When a defocus amount of the focus lens310is calculated, the processor120can estimate an approximate position of the on-focus region based on the defocus amount, and can determine the movement direction and movement amount of the focus lens310based on the approximate position. For example, when the focus lens310departs from the on-focus region over a reference range, the processor120can determine a position spaced apart from the current position of the focus lens310by a first distance toward the focus region, as a search position. As another example, when the focus lens310does not depart from the on-focus region over the reference range, the processor120can determine a position spaced apart from the current position of the focus lens310by a second distance shorter than the first distance toward the focus region, as a search position. Although the movement direction and position of the focus lens310are changed based on a defocus amount inFIG. 3, this is only an example and embodiments are not limited thereto. The processor120can adjust the movement speed of the focus lens310based on the defocus amount. For example, when the focus lens310departs from the on-focus region over the reference range, the processor120can move the focus lens310at a first speed to the search position. As another example, when the focus lens310does not depart from the on-focus region over the reference range, the processor120can move the focus lens310at a second speed, lower than the first speed, to the search position.

The processor120can limit output of the second image while determining a search position. The output controller324of the processor120can process a first image obtained with the focus lens310at a first position to be output through the display160while a search position is determined. For example, the output controller324can output the first image instead of a second image, even though the focus lens310at the first position is moved away from the on-focus region toward a second position in the opposite direction. Accordingly, it is possible to prevent an image of which the magnification is changed by a position change of the focus lens310, and it is possible to provide an effect that removes wobbling in which an image that is output through the display160.

When finishing the search position determination operation, the processor120can detect the on-focus region based on the determined search position. The processor120can determine whether the focus lens310has approached the on-focus region while moving the focus lens310, step by step, from the second position. For example, the processor120can analyze a focus signal value (e.g., a contrast value) of an image that is obtained at the position to which the focus lens310has moved, and can determine that the focus lens has approached the on-focus region when a maximum focus signal value is measured.

The processor120may output an image obtained in the search position determination operation when performing the on-focus region detection operation. The output controller324of the processor120can process a second image obtained at the second position to be output through the display160while the focus lens310is moved from the second position to a third position that is a search position. Accordingly, as will be described below with reference toFIGS. 9, 10A to 10C, and 11, it is possible to reduce a change in magnification of an image that a user actually perceives.

The configuration in which the auto focusing function is performed by the processor120separated from the camera module180is described above. However, this is only an example and embodiments are not limited thereto. The auto focusing function of an electronic device may be performed by a processor (e.g., the image signal processor260ofFIG. 2) included in the camera module180.

An electronic device, according to an embodiment of the disclosure, includes a camera module including a focus lens, a display, and a processor. The processor is configured to control the camera module to obtain a first image at a first position of the focus lens, control the display to output the first image, control the camera module to obtain a second image at a second position of the focus lens while the first image is being output, calculate a defocus amount of the focus lens at the second position based on the first image and the second image, and detect an on-focus region based on the calculated defocus amount.

The processor is further configured to control the display such that an output of the second image is limited until the defocus amount is calculated.

The processor is further configured to control the camera module to obtain a third image at a third position of the focus lens, and control the display to replace the first image with the third image based on the defocus amount.

The processor is further configured to control the display to output the second image before the first image is replaced with the third image.

When the second position exists in a first direction in proximity to the on-focus region with respect to the first position, the processor is further configured to control the display to output the second image before the first image is replaced with the third image.

When the focus lens is moved over a reference distance from the second position in the first direction, the processor is further configured to control the display to output the second image before the first image is replaced with the third image.

When the focus lens is moved less than reference distance from the second position in the first direction, the processor is further configured to control the display to continue outputting the first image before the first image is replaced with the third image.

When the second position exists in a second direction that moves away from the on-focus region with respect to the first position, the processor is further configured to control the display to continue outputting the first image before the first image is replaced with the third image.

The processor is further configured to detect the on-focus region based on the contrast of the third image.

The processor is further configured to calculate the defocus amount based on a blur between the first image and the second image.

FIG. 4is a flowchart illustrating a method for providing an auto focusing operation in an electronic device, according to an embodiment. The operations in the embodiments described below may be sequentially performed, but are not necessarily sequentially performed. For example, the orders of the operations may be changed and at least two operations may be performed in parallel.

Referring a flowchart400ofFIG. 4, an electronic device300obtains a first image for calculating a defocus amount and outputs the obtained first image on the display160, in operation410. The first image may be an image obtained with a focus lens (e.g., the focus lens310ofFIG. 3) at a first position. The processor120can control a camera module to obtain the first image.

The electronic device300obtains a second image for calculating a defocus amount, in operation420. The second image may be an image obtained with the focus lens310moved to a second position from the first position. For example, the processor120can obtain the second image of which the image magnification has increased or decreased in comparison to the first image due to a position change of the focus lens310by controlling the camera module. The processor120can obtain a second image with the first image output on the display106. For example, the processor120can limit output of the obtained second image, as described in greater detail below with reference toFIG. 5B.

The electronic device300calculates a defocus amount of the focus lens310based on the first image and the second image, in operation430. As described above with reference toFIG. 3, the defocus amount may be a value showing the current degree of departure from the on-focus region of the focus lens310. The processor120can calculate a defocus amount with the first image output. For example, the processor120can process the first image to be output on the display106instead of the second image before the defocus amount of the focus lens310is calculated.

The electronic device300performs the operation of detecting an on-focus region based on the calculated defocus amount, in operation440. For example, the processor120can determine the position where the operation of detecting an on-focus region is started based on the defocus amount. Further, the processor120can move the focus lens310, step by step, to the on-focus region based on the determined start position.

FIG. 5Ais a diagram illustrating the auto focusing function of a common electronic device.FIG. 5Bis a diagram illustrating the auto focusing function of an electronic device, according to an embodiment.

Referring a diagram500ofFIG. 5A, a common electronic device can provide an auto focusing function that adjusts a focus on an object by moving a camera included in a camera module back and forth. The electronic device outputs an image502obtained through a camera module through the display in a preview image or a live view type504while an auto focusing function is performed. For example, as shown inFIG. 5A, when the focus lens is moved to a second lens position while a first image obtained at a first lens position is output, the electronic device102can update the screen using a second image obtained at the second lens position. As shown inFIG. 5A, when the focus lens310is moved to the second lens position opposite to the first lens position, and then moved to a third lens position opposite to the second lens position, the electronic device102outputs the second image with screen magnification reduced in comparison to the first image, and then outputs a third image of which the screen magnification has been increased in comparison to the second image, so wobbling in which an output image is shaken, may occur.

Referring to a diagram550ofFIG. 5B, the electronic device102, according to an embodiment of the disclosure, can prevent wobbling by controlling output of an image while an auto focusing function is performed. Specifically, the electronic device102can limit output of a second image and can keep outputting a first image at least while a defocus amount is calculated. For example, when the focus lens310is moved to a second lens position opposite to a first lens position, and then moves to a third lens position opposite to the second lens position, the electronic device102outputs a first image and then outputs a third image (as shown in506), whereby a user can recognize a linear increase or decrease of the image magnification.

FIG. 6is a flowchart illustrating a method for calculating a defocus amount in an electronic device, according to an embodiment. The operations ofFIG. 6may be various embodiments of operation410and operation430ofFIG. 4. Further, the operations described below may be sequentially performed, but are not necessarily sequentially performed. For example, the order of the operations may be changed and at least two operations may be performed in parallel.

Referring to a flowchart600ofFIG. 6, the electronic device300obtains and outputs a first image based on a first lens position, in operation610. The processor can obtain a first image of an object by sensing light of the object that has traveled inside through a focus lens (e.g., the focus lens310ofFIG. 3) at the first position.

The electronic device300extracts a partial region of the obtained first image, in operation620. According to an embodiment, the partial region of the first image may be a part that is used to detect focus. The processor120can use the center portion of the first image to detect a focus. However, this is only an example and embodiments are not limited thereto. The processor120may use various portions of the first image, such as, for example, a corner of the first image or an edge detected from the first image, to detect a focus. According to an embodiment, the processor120may store the obtained first image or a partial region of the first image inside or outside the electronic device300(e.g., the external electronic devices102and104or the server108ofFIG. 1).

The electronic device300changes the focus lens310at the first position to the second position, in operation630. The second position to which the focus lens310is moved may be determined by an algorithm determined in advance.

The electronic device300obtains a second image based on the second lens position, in operation640. The processor120can obtain a second image of an object by sensing light of the object that has traveled inside through the focus lens310that has been moved to the second position from the first position.

The electronic device300obtains limit output of the second image and outputs the first image, in operation650. The processor120can prevent the second image from being output with the image magnification increased or decreased in comparison to the first image due to a change of the movement direction of the focus lens310.

The electronic device300extracts a partial region of the obtained second image, in operation660. The partial region of the second image may be a part that is used to detect focus. The processor120can use the center portion of the second image to detect a focus. However, this is only an example and embodiments are not limited thereto. The processor120may use various portions of the second image, such as, for example, a corner of the second image or an edge detected from the second image, to detect a focus. The processor120may store the obtained second image or a partial region of the second image inside or outside the electronic device300(e.g., the external electronic devices102and104or the server108ofFIG. 1).

The electronic device300measures a focus signal value based on the extracted regions, in operation670. The processor120can measure a focus signal value such as blur between image, a contrast, and a phase difference by performing frequency analysis on the first image (or a partial region of the first image) and the second image (or a partial region of the second image), as described above with reference toFIG. 3.

The electronic device300calculates a defocus amount of the focus lens310based on the calculated focus signal value, in operation680. The processor120can store a defocus amount defined in advance for defocus amounts corresponding to various focus signal values. In this case, the processor120can calculate the current defocus amount of the focus lens310by comparing the calculated focus signal value with the reference defocus amount. The processor120can determine a search position based on a calculated defocus amount, as described above with reference toFIG. 3. When the focus lens310departs from the on-focus region over a reference range, the processor120can determine a position spaced apart from the current position of the focus lens310by a first distance toward the focus region as a search position. When the focus lens310does not depart from the on-focus region over the reference range, the processor120can determine a position spaced apart from the current position of the focus lens310by a second distance shorter than the first distance toward the focus region as a search position.

FIG. 7is a flowchart illustrating a method for defecting an on-focus region in an electronic device, according to an embodiment of the disclosure.FIG. 8is a diagram illustrating the operation of defecting an on-focus region in an electronic device, according to an embodiment of the disclosure. The operations ofFIG. 7may be various embodiments of operation440ofFIG. 4. Further, the operations described below may be sequentially performed, but are not necessarily sequentially performed. For example, the order of the operations may be changed and at least two operations may be performed in parallel.

Referring to a flowchart ofFIG. 7, the electronic device300keeps outputting the first image, in operation710. The first image may be an image obtained at the previous position of a focus lens (e.g., the focus lens310ofFIG. 3). The processor120can output the first image obtained at the previous position of the focus lens310instead of a second image even if the second image is obtained based on a second lens position.

The electronic device300moves the focus lens310based on a search position, in operation720.

The electronic device300performs a search operation using the focus lens310moved to the search position, in operation730. The processor120can measure a focus signal value (e.g., a contrast value) of an image that is obtained through the focus lens310moved to the search position. Further, the processor120can obtain an image while moving the focus lens310, step by step, to an on-focus lens, and can measure a focus signal value of the obtained image.

The electronic device300determines whether the focus lens310has approached the on-focus region, in operation740. For example, the processor120can determine that the focus lens310has approached the on-focus region when a focus signal value of the image obtained at the position to which the focus lens310has been moved is measured as a maximum focus signal value. The processor120can calculate the ratio of the focus signal value (e.g., a second focus signal value) for the current position of the focus lens310to the focus signal value (e.g., a first focus signal value) for the previous position of the focus lens310(e.g., second focus signal value/first focus signal value). Further, the processor120can determine that the focus lens310has approached the on-focus region at the point in time when the ratio of focus signal values increases and then decreases or the ratio of focus signal values decreases and then increases, as the focus lens310is moved.

When it is determined that the focus lens310has not approached the on-focus region, that is, when the ratio of focus signal values continuously increases or decreases as the focus lens310is moved, the electronic device300repeats the search operation by returning to operation730. For example, the processor120, as stated with reference to operation730, obtains an image while moving the focus lens310, step by step, to an on-focus lens, and can measure a focus signal value of the obtained image.

When it is determined that the focus lens310has approached the on-focus region, that is, when the ration of focus signal values increases and then decreases or decreases and then increases as the focus lens310is moved, the electronic device300(e.g., the processor120ofFIG. 3) generates an on-focus image, in operation750. The on-focus image may be an image focused on an object through the focus lens310positioned in the on-focus region. For example, the processor120can detect an on-focus position and can move the focus lens310to the detected on-focus position to generate an on-focus image.

For example, the processor120, as shown inFIG. 8, can detect an on-focus position using three-point interpolation. Specifically, the processor120can calculate a focus signal value for each position while moving the focus lens310step by step. For example, the processor120can calculate a focus signal value while moving from a first position to a seventh position. Further, the processor120can determine that an on-focus region is approached at a point where the focus lens320is moved from the sixth position to the seventh position. The processor120can determine that the point P where a line L1connecting the focus signal values at the fifth position and the sixth position and a tangential line L2of the focus signal value at the seventh position meet each other as an on-focus point, and can finally move the focus lens310to the point P. However, this is only an example and embodiments are not limited thereto. The processor120may determine an on-focus point based on various methods known in the art. The processor120can output a generated on-focus image as a preview image or a live view. However, this is only an example and embodiments are not limited thereto. For example, the processor120may store the on-focus image inside or outside the electronic device300(e.g., in the external electronic devices102and104or the server108ofFIG. 1).

FIG. 9is a flowchart illustrating a method for moving a focusing lens based on a search position in an electronic device, according to an embodiment. The operations ofFIG. 9may be various embodiments of operation720ofFIG. 7. Further, the operations described below may be sequentially performed, but are not necessarily sequentially performed. For example, the order of the operations may be changed and at least two operations may be performed in parallel.

Referring to a flowchart900ofFIG. 9, the electronic device300determines whether the second lens position exists in the first direction with respect to the first lens position, or whether the second lens position exists in the second direction with respect to the first lens position, in operation910. For example, the first lens position may be a position where a first image for calculating a defocus amount is obtained and the second lens position may be a position where a second image for calculating a defocus amount is obtained. Further, the first direction may be a direction coming closer to the on-focus region than the first lens position and the second direction may be a direction going away from the on-focus position more than the first lens position.

When it is determined that the second lens position exists in the first direction, the electronic device300updates the screen based on the second image previously obtained, in operation920. The processor120can process the second image is displayed on the screen until a focus lens (e.g., the focus lens310ofFIG. 3) is moved to a search position. For example, as will be described in detail below with reference toFIGS. 10A to 10C, the processor120can decrease the magnification of an image that a user actually perceives when outputting a third image by temporarily outputting the second image after outputting the first image.

When it is determined that the second lens position exists in the second direction, the electronic device300keeps outputting the first image, in operation930. The processor120can keep outputting the first image until the focus lens310is moved to the search position.

FIG. 10Ais a diagram illustrating the operation of moving a focusing lens based on a search position in an electronic device, according to an embodiment of the disclosure.FIG. 10Bis a diagram illustrating the operation of moving a focusing lens based on a search position in an electronic device, according to an embodiment of the disclosure.FIG. 10Cis a diagram illustrating the operation of moving a focusing lens based on a search position in an electronic device, according to an embodiment of the disclosure.

Referring toFIG. 10A, as described above, the electronic device300can calculate a defocus amount based on a first image obtained based on the first lens position and a second image1002obtained based on the second lens position. The electronic device300can prevent wobbling by limiting output of the second image and outputting only the first image while a defocus amount is calculated (as shown by1004). The electronic device300can perform an operation that detects an on-focus region by moving the focus lens310to the third lens position based on the defocus amount.

The electronic device300can control the second image to be output while moving the focus lens310to the third position. As shown inFIG. 10A, images of which the image magnification linearly increases may be obtained due to movement of the focus lens310, but the electronic device300outputs the first image instead of the second image and then outputs the second image1002while the focus lens310is moved to the third lens position (or before the third image is output) in order to prevent wobbling, thereby being able to decrease a change in magnification of images that a user actually perceives.

As shown in a diagram1010ofFIG. 10B, when a first image1011keeps being output until a third image1013is output, the change in magnification of an image that a user actually perceives may increase. In contrast, as shown in a diagram1020ofFIG. 10C, when the second image1012is temporarily output before the third image1013is output, it is possible to decrease a change in magnification of an image that a user actually perceives in comparison to the situation shown inFIG. 10B.

FIG. 11is a flowchart illustrating a method for updating a picture based on a second image in an electronic device, according to an embodiment of the disclosure. The operations ofFIG. 11are detailed description of operation920ofFIG. 9. Further, the operations described below may be sequentially performed, but are not necessarily sequentially performed. For example, the order of the operations may be changed and at least two operations may be performed in parallel.

Referring to a flowchart1100ofFIG. 11, the electronic device300determines whether a focus lens (the focus lens310ofFIG. 3) is spaced a predetermined reference distance from the second lens position and a search operation is performed, in operation1110. The reference distance may be a value for determining a situation in which a user can actually feel a change in magnification of an image.

When a search operation is performed with the focus lens spaced by the reference distance, that is, when it is a situation in which a user can actually perceive a change in magnification of an image, the electronic device300updates the screen based on the second image, in operation1120. The processor120can process the second image to be displayed on the screen until the focus lens310is moved to the search position.

When a search operation is performed without the focus lens spaced by the reference distance, that is, when it is a situation in which a user cannot actually perceive a change in magnification of an image, the electronic device300keeps outputting the first image, in operation1130. According to an embodiment, the processor120can keep outputting the first image until the focus lens310is moved to the search position.

According to an embodiment, a method is provided for operating an electronic device and includes obtaining a first image at a first position of a focus lens of a camera module of the electronic device, outputting the first image through a display of the electronic device, obtaining a second image at a second position of the focus lens while the first image is being output, calculating a defocus amount of the focus lens at the second position based on the first image and the second image, and detecting an on-focus region based on the calculated defocus amount.

Calculating the defocus amount includes limiting an output of the second image while the first image is being output.

Detecting the on-focus region includes obtaining a third image at a third position of the focus lens and replacing the first image with the third image.

Detecting the on-focus region includes outputting the second image before the first image is replaced with the third image.

Detecting the on-focus region includes outputting the second image before the first image is replaced with the third image when the second position is in a first direction in proximity to the on-focus region with respect to the first position.

Detecting the on-focus region includes outputting the second image before the first image is replaced with the third image when the focus lens is moved over a reference distance from the second position in the first direction.

Detecting the on-focus region includes continuing to output the first image before the first image is replaced with the third image when the focus lens is moved less than a reference distance from the second position in the first direction.

Detecting the on-focus region includes continuing to output the first image before the first image is replaced with the third image when the second position exists in a second direction that moves away from the on-focus region with respect to the first position.

Detecting the on-focus region includes calculating a contrast of the third image.

Calculating the defocus amount includes calculating a blur between the first image and the second image.

According to various embodiments, a computer-readable recording medium may include programs for performing obtaining a first image at a first position of a focus lens, outputting a first image through a display, obtaining a second image at a second position of the focus lens while the first image is output, calculating a defocus amount of the focus lens at the second position on the basis of the first image and the second image, and detecting an on-focus region on the basis of the calculated defocus amount.

Various embodiments of the disclosure and the terms used therein are not intended to limit the technological features set forth herein to particular embodiments and include various changes, equivalents, or replacements for a corresponding embodiment.