Patent Description:
In a case where a plurality of subjects at greatly different distances from a digital camera or the like is imaged or a subject having a great depth dimension is imaged, only some of the subjects or only a portion of the subject can be in focus due to a lack of depth of field. To solve such an issue, <CIT> discusses a technique for focus stacking by which a plurality of images is picked up at different in-focus positions, only focused areas are extracted from the picked-up images, and the focused areas are combined into one image, thereby generating a composite image in which an entire imaging area is in focus.

Meanwhile, in order to reduce processing time for focus stacking as much as possible, International Publication No. <CIT> discusses a technique for continuously changing the in-focus position during exposure.

However, if imaging is performed while moving the in-focus position during exposure as described above, uneven luminance is caused in a plane of the image due to changes in effective aperture value between timings of exposure of an upper part and a lower part of an imaging element. If only focused areas are extracted from a plurality of images picked up in this manner and combined into one image, a boundary between combined areas may become noticeable due to uneven luminance and may cause defects in the composite image. <CIT> and <CIT> disclose systems in which an image is captured using a rolling shutter whilst an in focus position is continuously changed, and the read out period is syncronised with the reciprocation period of a focus lens. This will compensate for the exposure difference when a plurality of images are stacked, because the exposure differences cancel each other out.

The present invention is directed to, in the case of moving the in-focus position during exposure in imaging for focus stacking, reducing defects in the composite image.

According to a first aspect of the present invention, there is provided an image pick up apparatus as specified in claims <NUM> to <NUM>. According to a second aspect of the present invention, there is provided an image pick up method as specified in claim <NUM>. According to a third aspect of the present invention, there is provided a non-transitory computer-readable storage medium as specified in claim <NUM>.

In the configuration of an embodiment of the present invention, it is possible to obtain a focus-stacked image in which defects at a boundary between combined areas caused by uneven luminance and a difference in level of noise are reduced while reducing the imaging time for picking up a plurality of images having different in-focus positions.

Hereinafter, the embodiment of the present invention will be described with reference to paragraph [<NUM>]. The other embodiments shall be considered as illustrating examples only.

<FIG> is an example of a block diagram illustrating a configuration of a digital camera that is an image pick up apparatus according to the present embodiment. A digital camera <NUM> is capable of picking up still images, recording information on in-focus positions, calculating contrast values, and combining images. The digital camera <NUM> is further capable of enlarging or reducing an image that has been picked-up and saved or an externally input image.

A control unit <NUM> is a signal processor such as a central processing unit (CPU) and a micro processing unit (MPU). The control unit <NUM> reads a program built in a read only memory (ROM) <NUM> described below to control each unit of the digital camera <NUM>. For example, as described below, the control unit <NUM> issues commands for starting and ending image pickup to an imaging unit <NUM> described below. Alternatively, the control unit <NUM> issues a command for image processing based on the program built in the ROM <NUM> to an image processing unit <NUM> described below. A command issued by a user is input into the digital camera <NUM> via an operation unit <NUM> described below, and reaches the corresponding unit of the digital camera <NUM> via the control unit <NUM>.

A drive unit <NUM> includes a motor or the like, and mechanically operates an optical system <NUM> described below under commands from the control unit <NUM>. For example, the drive unit <NUM> moves the position of a focus lens included in the optical system <NUM> based on commands from the control unit <NUM>, thereby adjusting a focal length of the optical system <NUM>.

The optical system <NUM> includes a zoom lens, a focus lens, and a diaphragm. The diaphragm is a mechanism for adjusting an amount of light transmitted. The in-focus position can be changed by changing the positions of the lenses.

The imaging unit <NUM> is an imaging element that photoelectrically converts an incoming light signal into an electric signal. For example, the imaging unit <NUM> may be a charge-coupled device (CCD) sensor, a complementary metal-oxide semiconductor (CMOS) sensor, or the like. The imaging unit <NUM> can be provided with a moving image pickup mode in which a plurality of temporally continuous images is picked up as frames of a moving image. The imaging unit <NUM> can measure luminance of a subject through the optical system <NUM>. Instead of the imaging unit <NUM>, an autoexposure (AE) sensor or the like may be used for light metering.

The ROM <NUM> is a read-only non-volatile memory as a recording medium, and stores operational programs for blocks included in the digital camera <NUM> and parameters necessary for operation of the blocks.

The RAM <NUM> is a writable volatile memory that is used as a temporary storage area of data output by the operation of the blocks included in the digital camera <NUM>.

The image processing unit <NUM> performs various types of image processing such as white balance adjustment, color interpolation, filtering, and combining on image data output from the imaging unit <NUM> or on image signal data recorded in a built-in memory <NUM> described below. The image processing unit <NUM> compresses the image signal data picked up by the imaging unit <NUM> using standards such as JPEG.

The image processing unit <NUM> includes an application specific integrated circuit (ASIC) in which circuits performing specific processes are integrated. Alternatively, the control unit <NUM> may perform the processes based on the programs read from the ROM <NUM>, whereby the control unit <NUM> performs some or all of the functions of the image processing unit <NUM>. If the control unit <NUM> performs all of the functions of the image processing unit <NUM>, the image processing unit <NUM> does not need to be provided as hardware.

A display unit <NUM> is a liquid crystal display or an organic electroluminescence (EL) display that displays an image temporarily saved in the RAM <NUM>, an image saved in the built-in memory <NUM> described below, or a setting screen for the digital camera <NUM>.

The built-in memory <NUM> is an area to record images picked up by the imaging unit <NUM>, images processed by the image processing unit <NUM>, and the information on in-focus positions in image pickup. Instead of the built-in memory <NUM>, a memory card or the like may be used.

The operation unit <NUM> includes, for example, a button, a switch, a key, or a mode dial attached to the digital camera <NUM> or a touch panel used also as the display unit <NUM>. The commands from the user reach the control unit <NUM> via the operation unit <NUM>.

Next, a reason why uneven luminance occurs in a plane of an image if the image is picked up while the in-focus position is moved during exposure using a rolling shutter, will be described with reference to the drawings.

When the digital camera <NUM> is in a manual exposure mode or an aperture priority exposure mode, the user can use the operation unit <NUM> to set the aperture value to the digital camera <NUM>. When the digital camera <NUM> is in an auto mode or a shutter speed priority mode, the digital camera <NUM> automatically determines the aperture value. The aperture value set by the user to the digital camera <NUM> is called a displayed aperture value or nominal aperture value.

The digital camera <NUM> instructs the drive unit <NUM> via the control unit <NUM> to change the aperture of the optical system <NUM> to an aperture value set by the user or automatically determined by digital camera <NUM>. However, even if the aperture of the optical system <NUM> is changed to the displayed aperture value, an actual amount of light received by the imaging unit <NUM> through the optical system <NUM> depends on a positional relationship between the optical system <NUM> and the imaging unit <NUM>. Thus, the imaging unit <NUM> may not receive an amount of light corresponding to the displayed aperture value. The actual amount of light received by the imaging unit <NUM> represented in terms of the aperture value is an effective aperture value. The actual aperture value is called the effective aperture value.

In general, however, a lens has a characteristic of changing the effective aperture value thereof when the in-focus position is moved, and the actual aperture value of the lens may be different from the displayed aperture value depending on the state of the lens. A difference between the displayed aperture value and the effective aperture value depends on the position of a focus lens, i.e., the in-focus position. In focus stacking imaging, a rolling shutter is often used to pick up a large number of images. In image pickup using the rolling shutter, pixel reset and pixel read are performed in sequence for each line, and thus the exposure timing gradually shifts from line to line. Exposure times of pixels in each line are basically the same.

<FIG> is a graph illustrating a relationship among the displayed aperture value, effective aperture value, and in-focus position according to the present embodiment. As illustrated in the graph of <FIG>, in the optical system <NUM> according to the present embodiment, if the in-focus position is at the closest distance end, the effective aperture value is greater than the displayed aperture value, and as the in-focus position becomes closer to the infinite end, the effective aperture value becomes closer to the displayed aperture value. However, whether changes in the effective aperture value due to the in-focus position are linear or non-linear and monotonic increase or monotonic decrease, and an absolute amount of difference from the displayed aperture value differ depending on the type of the lens. The relationship between the effective aperture value and the in-focus position illustrated in <FIG> is a mere example.

<FIG> is a graph illustrating the relationship between the changes in effective aperture value due to changes in in-focus position and the exposure timing without correction of exposure time according to the present embodiment. <FIG> is a graph illustrating the relationship between the changes in effective aperture value due to changes in in-focus position in a plurality of images and the exposure timing without the correction of exposure time according to the present embodiment. If the imaging unit <NUM> performs imaging while continuously moving the in-focus position toward the infinite end using the drive unit <NUM> during exposure by a rolling shutter, the effective aperture value becomes smaller. Thus, in <FIG>, an N-th line (the last line) is brighter than the first line in a pixel array, so that uneven luminance occurs in the plane of the image due to changes in in-focus position. Referring to <FIG>, when a plurality of images for focus stacking is picked up, all of the images exhibit uneven luminance in the plane as illustrated in <FIG>. If focused areas are extracted from the plurality of images with uneven luminance and are combined into one image, the boundary between combined areas becomes noticeable due to the uneven luminance, thereby causing defects in the composite image.

Next, a focus stacking process without the correction of exposure time according to the present embodiment will be described. <FIG> is a flowchart illustrating the focus stacking process according to the present embodiment.

In step S501, the user operates the operation unit <NUM> to set parameters for imaging such as exposure settings and focus bracket settings. In response to the user operation, the control unit <NUM> calculates the exposure time from the shutter speed, and calculates the amount of movement of the in-focus position in an optical axis direction on the basis of the focus bracket settings. Alternatively, the control unit <NUM> may set the parameters for imaging on the basis of predetermined settings such as default settings, not in response to the user operation immediately before imaging.

In step S502, the control unit <NUM> calculates the amount of exposure time correction for reducing uneven luminance. Hereinafter, a method for calculating the amount of exposure time correction will be described with reference to the drawing. The control unit <NUM> calculates the amount of change in the effective aperture value in picking up one image from the amount of movement of the in-focus position set in step S501 and the relationship between the in-focus position and the effective aperture value illustrated in <FIG>. The information related to the relationship between the in-focus position and the effective aperture value illustrated in <FIG> may be stored in advance in the ROM <NUM> or the like. Alternatively, in the case of a lens mounted camera, the control unit <NUM> may read information saved in a storage unit of the lens.

<FIG> is a graph illustrating the relationship between a pixel reset timing and the effective aperture value of each line according to the present embodiment. The control unit <NUM> calculates a difference in effective aperture value between the first line and the N-th line from the exposure time set in step S501 and the amount of change in the effective aperture value in the optical system <NUM> in picking up the first image calculated in step S502, and converts the difference in effective aperture value into exposure time. A result obtained through the conversion by the control unit <NUM> constitutes the amount of exposure time correction for reducing uneven luminance in the plane of the first image. The control unit <NUM> uses differences in exposure between the first line and the second to N-th lines ("the last line" in <FIG>) to calculate the amounts of exposure time correction for reducing the differences in exposure between the second to N-th lines and the first line. Then, the control unit <NUM> applies the calculated amounts of exposure time correction to the respective second to N-th lines and performs imaging for the corrected exposure times, whereby it can be expected to reduce uneven luminance in the one image.

However, if the difference in effective aperture value is extremely small, the effect of correction is considered to be slight. Thus, the control unit <NUM> compares the difference in effective aperture value with a predetermined threshold. If the difference in effective aperture value is smaller than or equal to the threshold, the control unit <NUM> need not perform the exposure time correction.

<FIG> is a graph illustrating the relationship between the pixel reset timing and the effective aperture value of each line after the exposure time correction according to the present embodiment. As illustrated in <FIG>, the control unit <NUM> corrects the exposure times to reduce the differences in exposure between the second to N-th lines and the first line so that the exposure times of the respective lines are not identical. In the situation of the present embodiment as illustrated in <FIG>, the control unit <NUM> reduces the exposure times in sequence from the first line to the N-th line, but the present invention is not limited to this. In order to correct the exposure times of the individual lines, the control unit <NUM> may change the pixel reset timing as illustrated in <FIG> or may change the timing for reading the pixels. In <FIG>, the control unit <NUM> uses the exposure time of the first line as a reference and corrects the exposure times of the other lines with reference to the effective aperture value of the first line. However, the present invention is not limited to this, and the control unit <NUM> may use the exposure time of any line as the reference.

<FIG> is a graph illustrating the relationship between the pixel reset timing and the effective aperture value of each line in a plurality of images after the exposure time correction according to the present embodiment. In the case illustrated in <FIG>, the control unit <NUM> corrects the exposure times so that the effective aperture values of all the lines in all the images match the effective aperture value of the first line in the first image. By such a correction, it can be expected that uneven luminance in the composite image will be reduced.

In step S503, the control unit <NUM> detects whether an imaging instruction is issued from the user. If the imaging instruction is issued from the user through operation on the operation unit <NUM> (YES in step S503), the processing proceeds to step S504. If no imaging instruction is issued from the user (NO in step S503), the processing returns to step S502.

In step S504, the control unit <NUM> drives the drive unit <NUM> to perform focus drive for moving the in-focus position to the in-focus position for imaging in next step S505, based on the imaging conditions set in step S501.

In step S505, the imaging unit <NUM> performs imaging at the in-focus position in the optical axis direction set in step S504 using the exposure times corrected by the amount of correction determined in step S502. As described above, the in-focus position is moved (the focus drive is not stopped) during the imaging according to the present embodiment. As illustrated in <FIG>, in the present embodiment, the imaging is performed with movement in the in-focus position while correcting the exposure times.

In step S506, the control unit <NUM> determines whether the imaging is finished. Here, as a criterion for determination on whether the imaging is finished, the control unit <NUM> uses, for example, a condition that a predetermined number of picked-up images has been reached. Otherwise, the control unit <NUM> uses, for example, a condition that a predetermined capacity for saving images has been reached. Otherwise, the control unit <NUM> uses, for example, a condition that a predetermined focus range has been reached.

After the end of the imaging (YES in step S506), in step S507, the drive unit <NUM> stops the focus drive.

In step S508, the image processing unit <NUM> performs a focus stacking process on the picked-up images to generate a composite image. An example of a method for focus stacking will be described. First, the control unit <NUM> calculates the amount of position gap between two images to be combined. An example of a calculation method will be described below. First, the control unit <NUM> sets a plurality of blocks to one of the images. The control unit <NUM> desirably sets the blocks of the same size. Next, the control unit <NUM> sets search ranges larger in size than the blocks to the other image at positions corresponding to the set blocks. Finally, the control unit <NUM> calculates corresponding points in the search ranges in the other image so that the sum of absolute difference (hereinafter, referred to as SAD) in luminance with the set blocks becomes the smallest. A system control unit <NUM> calculates position gaps as vectors from the centers of the set blocks and the corresponding points. In calculating the corresponding points described above, the system control unit <NUM> may use, instead of SAD, the sum of squared difference (hereinafter, referred to as SSD), or normalized cross correlation (hereinafter, referred to as NCC). Next, the control unit <NUM> calculates transform coefficients from the amount of position gap. As the transform coefficients, the control unit <NUM> uses, for example, projective transform coefficients. However, the transform coefficients are not limited to the projective transform coefficients but may also be affine transform coefficients or simplified transform coefficients for horizontal and vertical shifts. Then, the image processing unit <NUM> calculates contrast values for the images after alignment. As an example of a method for calculating the contrast values, the image processing unit <NUM> first calculates luminance Y from color signals Sr, Sg, and Sb of pixels by using the following (Formula <NUM>).

Next, the image processing unit <NUM> calculates contrast values I by using a Sobel filter to a matrix L of luminance Y of <NUM> × <NUM> pixels as described in the following Formulas (<NUM>), (<NUM>), and (<NUM>):
[Math. <NUM>] <MAT> [Math. <NUM>] <MAT> [Math. <NUM>] <MAT>.

The above-described method for calculating the contrast values is a mere example. For example, an edge detection filter such as a Laplacian filter or a band pass filter passing a predetermined band may be used instead. Then, the image processing unit <NUM> generates a composite map. As a method for generating the composite map, the image processing unit <NUM> compares the contrast values of the pixels at the same position in the individual images, and sets the combining proportion of pixels with the highest contrast value to <NUM>% and sets the combining proportion of other pixels at the same position to <NUM>%. The image processing unit <NUM> sets such combining proportions at all the positions in the images. Lastly, the image processing unit <NUM> replaces the pixels based on the composite map to generate the composite image. If the thus calculated combining proportion between the adjacent pixels changes from <NUM>% to <NUM>% (or changes from <NUM>% to <NUM>%), a boundary between combined areas becomes noticeably unnatural. Thus, a filter with a predetermined number of pixels (taps) is applied to the composite map so that the combining proportion does not sharply change between the adjacent pixels.

In the present embodiment, by performing imaging while moving the in-focus position during exposure, it is possible to obtain a focus-stacked image in which defects in the boundary between combined areas caused by uneven luminance are reduced, with a reduced imaging time.

In the present embodiment described above, the digital camera <NUM> performs the focus stacking as a precondition. In many cases, besides the function of focus stacking, the digital camera <NUM> also has a function of picking up one image and recording the picked-up one image. In another embodiment for carrying out the present invention, whether to correct the exposure time is determined depending on whether to record one image or perform the focus stacking.

If the digital camera <NUM> picks up one image without performing the focus stacking while moving the in-focus position during exposure, uneven luminance will occur in the plane of the one image. However, the uneven luminance in the plane of the one image is smaller than the uneven luminance in the composite image having undergone the focus stacking. Thus, in the case where the digital camera <NUM> performs image pickup while moving the in-focus position during exposure, the digital camera <NUM> may not correct the exposure time as described above when recording one image only, and may correct the exposure time as described above when performing the focus stacking.

The above description of the embodiment has been given based on a personal digital camera. However, the embodiment is also applicable to a mobile device, a smartphone, or a network camera connected to a server, as far as they have the function of focus stacking. Alternatively, some of the above-described processes may be performed by the mobile device, the smartphone, or the network camera connected to a server.

Embodiment(s) of the present invention can also be realized by a process of supplying a program for implementing one or more functions of the above-described embodiments to a system or an apparatus via a network or a storage medium, and reading and executing the program by one or more processors in a computer of the system or the apparatus. The present invention can also be realized by a circuit (for example, an application specific integrated circuit (for example, ASIC)) that implements one or more functions.

Claim 1:
An image pick up apparatus (<NUM>) comprising:
imaging means (<NUM>) configured to pick up an image line by line using a rolling shutter wherein pixel reset and pixel read of an image sensor are performed in sequence for each of N lines of pixels while an in-focus position is continuously changed during pickup of the image; and
correction means (<NUM>) configured to perform correction of a difference in exposure resulting from a change in the in-focus position while the imaging means (<NUM>) picks up one image;
characterized in that the correction means (<NUM>) is configured to determine if a difference in exposure resulting from the change in the in-focus position is smaller than or equal to a predetermined threshold and not perform the correction if the difference in exposure is smaller than or equal to the predetermined threshold.