[go: up one dir, main page]

CN103973963A - Image acquisition device and image processing method thereof - Google Patents

Image acquisition device and image processing method thereof Download PDF

Info

Publication number
CN103973963A
CN103973963A CN201310260044.3A CN201310260044A CN103973963A CN 103973963 A CN103973963 A CN 103973963A CN 201310260044 A CN201310260044 A CN 201310260044A CN 103973963 A CN103973963 A CN 103973963A
Authority
CN
China
Prior art keywords
image
those
pixel
gradient
map
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201310260044.3A
Other languages
Chinese (zh)
Other versions
CN103973963B (en
Inventor
庄哲纶
周宏隆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Altek Semiconductor Corp
Original Assignee
Altek Semiconductor Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Altek Semiconductor Corp filed Critical Altek Semiconductor Corp
Publication of CN103973963A publication Critical patent/CN103973963A/en
Application granted granted Critical
Publication of CN103973963B publication Critical patent/CN103973963B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Image Processing (AREA)

Abstract

本发明提供一种图像获取装置及其图像处理方法。此图像处理方法包括下列步骤。以第一焦距获取第一图像,以第二焦距获取第二图像。对第二图像进行几何校正程序,产生位移校正后的第二图像。对第一图像的每一像素点执行梯度运算以产生多个第一梯度值,以及对位移校正后的第二图像的每一像素点执行梯度运算以产生多个第二梯度值。比较各第一梯度值与相对应的各第二梯度值以产生多个第一像素比较结果,根据第一像素比较结果产生第一参数地图。依据第一参数地图与第一图像产生合成图像,至少根据合成图像产生输出图像。

The invention provides an image acquisition device and an image processing method thereof. This image processing method includes the following steps. A first image is acquired at a first focal length and a second image is acquired at a second focal length. Perform a geometric correction procedure on the second image to generate a displacement-corrected second image. A gradient operation is performed on each pixel of the first image to generate a plurality of first gradient values, and a gradient operation is performed on each pixel of the displacement-corrected second image to generate a plurality of second gradient values. Each first gradient value is compared with each corresponding second gradient value to generate a plurality of first pixel comparison results, and a first parameter map is generated according to the first pixel comparison results. A composite image is generated based on the first parameter map and the first image, and an output image is generated based on at least the composite image.

Description

图像获取装置及其图像处理方法Image acquisition device and image processing method thereof

技术领域technical field

本发明是有关于一种图像获取装置及其图像处理方法,且特别是有关于一种通过计算像素梯度值来据以混合图像的图像获取装置及其图像处理方法。The present invention relates to an image acquisition device and its image processing method, and in particular to an image acquisition device and its image processing method for blending images by calculating pixel gradient values.

背景技术Background technique

随着光学技术的进步,可调整光圈、快门甚至可更换镜头的数码相机逐渐普及,数码相机的功能也趋于多样化。数码相机除了要提供良好的成像品质之外,对焦技术的准确性与速度更是消费者在购买产品时会参考的因素。但以现有的光学系统而言,由于多个物体在立体场景中具有不同的远近,故无法在单次拍摄图像的过程中取得完全清晰的全景深图像。亦即,受到镜头光学特性的限制,在使用数码相机取像时只能选择其中一个深度来进行对焦,故在成像中处于其他深度的景物会较为模糊。With the advancement of optical technology, digital cameras with adjustable aperture, shutter and even interchangeable lenses are gradually popularized, and the functions of digital cameras are also tending to be diversified. In addition to providing good imaging quality for digital cameras, the accuracy and speed of focusing technology are factors that consumers will refer to when purchasing products. However, with the existing optical system, since multiple objects have different distances in the stereoscopic scene, it is impossible to obtain a completely clear panoramic depth image in a single image capture process. That is to say, limited by the optical characteristics of the lens, only one of the depths can be selected for focusing when using a digital camera to capture images, so scenes at other depths will be blurred in the imaging.

现有产生全景深图像的方法大多采用多种不同摄影条件进行拍摄所得的多张图像组合而成。通过改变摄影条件中的一或多个参数进而对同一场景拍摄出不同的多张图像,再通过清晰度判别方法来将这些图像组合成一张清晰的图像。采用上述多种不同摄影条件进行拍摄以合成全景深图像的技巧须仰赖固定的图像获取装置进行拍摄。一般而言,使用者常利用稳定的脚架来固定图像获取装置,以确保所获取的图像之间无明显的几何扭曲。另外,在拍摄过程中,还须避免被摄场景中有任何目标的移动。Most of the existing methods for generating a depth-of-view image use a combination of multiple images obtained by shooting under different shooting conditions. By changing one or more parameters in the shooting conditions, multiple different images of the same scene are taken, and then these images are combined into a clear image through a sharpness discrimination method. The technique of using the above-mentioned various shooting conditions to synthesize a full-depth image must rely on a fixed image acquisition device for shooting. Generally speaking, users often use a stable tripod to fix the image acquisition device to ensure that there is no obvious geometric distortion among the acquired images. In addition, during the shooting process, it is necessary to avoid any movement of the target in the scene.

另一方面,在使用相机拍摄图像时,为了突显所拍摄图像中的主题,一般会采用所谓散景(bokeh)的拍摄技巧。散景即表示在景深较浅的摄影成像中,落在景深以外的画面会有逐渐产生松散模糊的效果。一般而言,相机镜头所能制造出的散景效果有限。若要获得较佳的散景效果,通常需要同时满足下列几项重要的条件:大光圈、长焦距。换言之,为了达到散景效果需倚赖大孔径镜头来加强远距离目标的模糊化,而让清楚成像的主题得以从背景中突显出来。然而,大孔径镜头的体积庞大且价格昂贵,并非一般消费型相机所能配备。On the other hand, when using a camera to capture an image, in order to highlight the subject in the captured image, a shooting technique called bokeh is generally used. Bokeh means that in photographic imaging with a shallow depth of field, images falling outside the depth of field will gradually produce a loose and blurred effect. In general, camera lenses are limited in the amount of bokeh they can produce. To obtain a better bokeh effect, the following important conditions usually need to be met at the same time: large aperture and long focal length. In other words, in order to achieve the bokeh effect, it is necessary to rely on a large-aperture lens to enhance the blurring of distant objects, so that the clearly imaged subject can stand out from the background. However, large-aperture lenses are bulky and expensive, and cannot be equipped with general consumer cameras.

总而言之,现有产生全景深或是产生散景图像的方法都易导致处理后的图像产生景深不连续或是不够自然的问题。此外,对于拍摄图像上的操作限制更是让使用者感到不便,像是其平均总拍摄时间相当长或繁复的过程,甚至导致最终的结果图像无法令人感到满意。All in all, the existing methods for generating the depth of field or bokeh images tend to cause discontinuous or unnatural depth of field in the processed image. In addition, the restrictions on the operation of capturing images make users feel even more inconvenient, such as the average total shooting time is rather long or complicated, and even the final result images are not satisfactory.

发明内容Contents of the invention

有鉴于此,本发明提供一种图像获取装置及其图像处理方法,可通过不同焦距值所拍摄的图像来判断出图像中的主体,进而产生主体清晰且散景效果自然的图像。另一方面,本发明的图像处理方法也可通过不同焦距值所拍摄的图像来避免产生全景深图像时的鬼影问题。In view of this, the present invention provides an image acquisition device and an image processing method thereof, which can determine the subject in the image through images captured with different focal length values, and then generate an image with a clear subject and a natural bokeh effect. On the other hand, the image processing method of the present invention can also avoid the ghosting problem when generating the full depth image by using the images captured with different focal length values.

本发明提出一种图像处理方法,适用于图像获取装置,此图像处理方法包括下列步骤。以第一焦距获取一第一图像,并以第二焦距获取第二图像,其中第一焦距对焦于至少一主体。对第二图像进行几何校正程序,产生位移校正后的第二图像。对第一图像的每一像素点执行梯度运算以产生多个第一梯度值,以及对位移校正后的第二图像的每一像素点执行梯度运算以产生多个第二梯度值。比较各第一梯度值与相对应的各第二梯度值以产生多个第一像素比较结果,并根据这些第一像素比较结果产生第一参数地图。依据第一参数地图与第一图像产生合成图像,并至少根据合成图像产生输出图像。The invention proposes an image processing method suitable for an image acquisition device, and the image processing method includes the following steps. A first image is acquired with a first focal length, and a second image is acquired with a second focal length, wherein the first focal length focuses on at least one subject. A geometric correction procedure is performed on the second image to generate a displacement-corrected second image. A gradient operation is performed on each pixel of the first image to generate a plurality of first gradient values, and a gradient operation is performed on each pixel of the displacement-corrected second image to generate a plurality of second gradient values. Each first gradient value is compared with each corresponding second gradient value to generate a plurality of first pixel comparison results, and a first parameter map is generated according to the first pixel comparison results. A composite image is generated according to the first parameter map and the first image, and an output image is generated at least according to the composite image.

在本发明的一实施例中,上述的图像处理方法,其中至少根据合成图像产生输出图像的步骤包括:以第三焦距获取第三图像。对第三图像进行几何校正程序,产生位移校正后的第三图像。对合成图像的每一像素点执行梯度运算以产生多个第三梯度值,以及对位移校正后的第三图像的每一像素点执行梯度运算以产生多个第四梯度值。比较各第三梯度值与相对应的各第四梯度值以产生多个第二像素比较结果,并根据这些第二像素比较结果产生第二参数地图。依据第二参数地图,混合位移校正后的第三图像与合成图像而产生输出图像。In an embodiment of the present invention, in the above image processing method, at least the step of generating an output image according to the synthesized image includes: acquiring a third image with a third focal length. A geometric correction procedure is performed on the third image to generate a displacement-corrected third image. A gradient operation is performed on each pixel of the synthesized image to generate a plurality of third gradient values, and a gradient operation is performed on each pixel of the displacement-corrected third image to generate a plurality of fourth gradient values. Each third gradient value is compared with each corresponding fourth gradient value to generate a plurality of second pixel comparison results, and a second parameter map is generated according to the second pixel comparison results. According to the second parameter map, the displacement-corrected third image is mixed with the composite image to generate an output image.

在本发明的一实施例中,上述的图像处理方法,其中对第二图像进行几何校正程序,产生位移校正后的第二图像的步骤包括:对第一图像与第二图像进行移动量估测,藉以计算单应性(homography matrix)矩阵。依据单应性矩阵对第二图像进行几何仿射转换(affine transformation),以获得位移校正后的第二图像。In an embodiment of the present invention, in the above-mentioned image processing method, the step of performing a geometric correction procedure on the second image, and generating the displacement-corrected second image includes: performing movement estimation on the first image and the second image , to calculate the homography matrix. A geometric affine transformation is performed on the second image according to the homography matrix to obtain a displacement-corrected second image.

在本发明的一实施例中,上述的图像处理方法,其中比较各第一梯度值与相对应的各第二梯度值以产生多个第一像素比较结果,并根据这些第一像素比较结果产生参数地图的步骤包括:将这些第二梯度值除以相对应的第一梯度值,产生多个梯度比较值。依据这些梯度比较值产生多个参数值,并将这些参数值记录为参数地图。In an embodiment of the present invention, in the above-mentioned image processing method, each first gradient value is compared with each corresponding second gradient value to generate a plurality of first pixel comparison results, and a plurality of first pixel comparison results are generated according to these first pixel comparison results The step of parameter mapping includes dividing the second gradient values by the corresponding first gradient values to generate a plurality of gradient comparison values. A plurality of parameter values are generated from the gradient comparison values and recorded as a parameter map.

在本发明的一实施例中,上述的图像处理方法,其中依据多个梯度比较值产生多个参数值的步骤包括:判断这些梯度比较值是否大于第一梯度临界值。若梯度比较值大于第一梯度临界值,设定梯度比较值所对应的参数值为第一数值。In an embodiment of the present invention, in the above image processing method, the step of generating a plurality of parameter values according to a plurality of gradient comparison values includes: determining whether the gradient comparison values are greater than a first gradient critical value. If the gradient comparison value is greater than the first gradient critical value, set the parameter value corresponding to the gradient comparison value to the first value.

在本发明的一实施例中,上述的图像处理方法,其中依据这些梯度比较值产生多个参数值的步骤包括:若梯度比较值并无大于第一梯度临界值,判断梯度比较值是否大于第二梯度临界值。若梯度比较值大于第二梯度临界值,设定梯度比较值所对应的参数值为第二数值。若梯度比较值并无大于第二梯度临界值,设定梯度比较值所对应的参数值设定为第三数值,其中,第一梯度临界值大于第二梯度临界值。In an embodiment of the present invention, in the above image processing method, the step of generating a plurality of parameter values according to these gradient comparison values includes: if the gradient comparison value is not greater than the first gradient critical value, judging whether the gradient comparison value is greater than the first gradient critical value Two gradient critical values. If the gradient comparison value is greater than the second gradient critical value, set the parameter value corresponding to the gradient comparison value to the second value. If the gradient comparison value is not greater than the second gradient threshold value, the parameter value corresponding to the gradient comparison value is set to a third value, wherein the first gradient threshold value is greater than the second gradient threshold value.

在本发明的一实施例中,上述的图像处理方法,其中至少依据第一参数地图与第一图像产生合成图像的步骤包括:对第一图像进行模糊化程序,产生模糊图像。根据第一参考地图混合第一图像与模糊图像以产生主体清晰图像。In an embodiment of the present invention, in the above image processing method, at least the step of generating a composite image according to the first parameter map and the first image includes: performing a blurring procedure on the first image to generate a blurred image. Blending the first image and the blurred image according to the first reference map to generate a sharp image of the subject.

在本发明的一实施例中,上述的图像处理方法,其中根据第一参考地图混合第一图像与模糊图像以产生主体清晰图像的步骤包括:判断参数值是否大于第一混合临界值。若参数值大于第一混合临界值,取参数值所对应的模糊图像的像素点作为主体清晰图像的像素点。若参数值并无大于第一混合临界值,判断参数值是否大于第二混合临界值。若参数值大于第二混合临界值,依据参数值计算出对应的主体清晰图像的像素点。若参数值并无大于第二混合临界值,取参数值所对应的第一图像的像素点作为主体清晰图像的像素点,其中,第一混合临界值大于第二混合临界值。In an embodiment of the present invention, in the above image processing method, the step of mixing the first image and the blurred image according to the first reference map to generate a clear image of the subject includes: determining whether the parameter value is greater than a first mixing threshold. If the parameter value is greater than the first mixing critical value, the pixel of the blurred image corresponding to the parameter value is taken as the pixel of the subject clear image. If the parameter value is not greater than the first mixing critical value, it is determined whether the parameter value is greater than the second mixing critical value. If the parameter value is greater than the second mixing critical value, the pixel points of the corresponding subject clear image are calculated according to the parameter value. If the parameter value is not greater than the second mixing critical value, the pixel of the first image corresponding to the parameter value is taken as the pixel of the subject clear image, wherein the first mixing critical value is greater than the second mixing critical value.

在本发明的一实施例中,上述的图像处理方法,其中至少依据第一参数地图与第一图像产生合成图像的步骤包括:依据第一图像与第二图像中各像素点的像素值计算出各像素点所对应的多个绝对差值和(Sum of AbsoluteDifferences),并依据这些绝对差值和调整第一参数地图中的参数值。根据调整后的第一参考地图,混合第一图像与位移校正后的第二图像以产生全景深图像。In an embodiment of the present invention, in the above image processing method, at least the step of generating a composite image based on the first parameter map and the first image includes: calculating Multiple sums of absolute differences (Sum of AbsoluteDifferences) corresponding to each pixel point, and adjust the parameter values in the first parameter map according to these sums of absolute differences. Based on the adjusted first reference map, the first image is blended with the displacement-corrected second image to generate a full depth image.

在本发明的一实施例中,上述的图像处理方法,其中依据第一图像与第二图像中各像素点的像素值计算出各像素点所对应的绝对差值和,并依据绝对差值和调整第一参数地图中的参数值的步骤包括:当绝对差值和大于移动临界值,依据绝对差值和决定各参数值的权重因子,并利用权重因子调整参数值,其中各参数值随着对应的绝对差值和的上升而下降。In an embodiment of the present invention, in the above-mentioned image processing method, the absolute difference sum corresponding to each pixel is calculated according to the pixel values of each pixel in the first image and the second image, and the absolute difference sum is calculated according to the absolute difference sum The step of adjusting the parameter values in the first parameter map includes: when the absolute difference sum is greater than the mobile critical value, determining the weight factor of each parameter value according to the absolute difference sum, and using the weight factor to adjust the parameter value, wherein each parameter value follows the The corresponding absolute difference sum increases and decreases.

在本发明的一实施例中,上述的图像处理方法,其中根据经由权重因子调整后的第一参考地图,混合第一图像与位移校正后的第二图像以产生全景深图像的步骤包括:判断参数值是否大于第一混合临界值。若参数值大于第一混合临界值,取参数值所对应的位移校正后的第二图像的像素点作为全景深图像的像素点。若参数值并无大于第一混合临界值,判断参数值是否大于第二混合临界值。若参数值大于第二混合临界值,依据参数值计算出对应的全景深图像的像素点。若参数值并无大于第二混合临界值,取参数值所对应的第一图像的像素点作为全景深图像的像素点,其中第一混合临界值大于第二混合临界值。In an embodiment of the present invention, in the above image processing method, the step of mixing the first image and the displacement-corrected second image to generate the full depth image according to the first reference map adjusted by the weight factor includes: judging Whether the parameter value is greater than the first blending threshold. If the parameter value is greater than the first mixing critical value, the pixel point of the displacement-corrected second image corresponding to the parameter value is taken as the pixel point of the full depth image. If the parameter value is not greater than the first mixing critical value, it is determined whether the parameter value is greater than the second mixing critical value. If the parameter value is greater than the second mixing threshold, the corresponding pixel points of the full depth image are calculated according to the parameter value. If the parameter value is not greater than the second blending threshold, the pixel of the first image corresponding to the parameter value is taken as the pixel of the full depth image, wherein the first blending threshold is greater than the second blending threshold.

从另一观点来看,本发明提出一种图像获取装置,此图像获取装置包括图像获取模块、位移校正模块、梯度计算模块、地图产生模块以及图像合成模块。图像获取模块以第一焦距获取第一图像,并以第二焦距获取第二图像,其中第一焦距对焦于至少一主体。位移校正模块对第二图像进行几何校正程序,产生位移校正后的第二图像。梯度计算模块对第一图像的每一像素点执行梯度运算以产生多个第一梯度值,以及对位移校正后的第二图像的每一像素点执行度运算以产生多个第二梯度值。地图产生模块比较各第一梯度值与相对应的各第二梯度值以产生多个第一像素比较结果,并根据第一像素比较结果产生第一参数地图。图像合成模块依据第一参数地图与第一图像产生合成图像,并至少根据合成图像产生输出图像。From another point of view, the present invention provides an image acquisition device, which includes an image acquisition module, a displacement correction module, a gradient calculation module, a map generation module, and an image synthesis module. The image acquisition module acquires a first image with a first focal length, and acquires a second image with a second focal length, wherein the first focal length focuses on at least one subject. The displacement correction module performs a geometric correction procedure on the second image to generate a displacement-corrected second image. The gradient calculation module performs a gradient operation on each pixel of the first image to generate a plurality of first gradient values, and performs a degree operation on each pixel of the displacement-corrected second image to generate a plurality of second gradient values. The map generation module compares each first gradient value with each corresponding second gradient value to generate a plurality of first pixel comparison results, and generates a first parameter map according to the first pixel comparison results. The image synthesis module generates a composite image according to the first parameter map and the first image, and at least generates an output image according to the composite image.

基于上述,本发明通过焦距不同会造成图像不同的特性,对同一场景以不同焦距进行拍摄,并且比较图像间各个像素点的梯度差异而产生参数地图。通过参数地图的资讯,可产生清晰的全景深图像或主体清晰背景模糊的散景图像,达到良好的全景深效果或散景效果。Based on the above, the present invention uses the feature that different focal lengths will cause different images, shoots the same scene with different focal lengths, and compares the gradient differences of each pixel point between images to generate a parameter map. Through the information of the parameter map, a clear panoramic depth image or a bokeh image with a clear subject and a blurred background can be generated to achieve a good panoramic depth effect or bokeh effect.

为让本发明的上述特征和优点能更明显易懂,下文特举实施例,并配合附图作详细说明如下。In order to make the above-mentioned features and advantages of the present invention more comprehensible, the following specific embodiments are described in detail with reference to the accompanying drawings.

附图说明Description of drawings

图1是本发明一实施例所示出的图像获取装置的功能方块示意图;Fig. 1 is a schematic functional block diagram of an image acquisition device shown in an embodiment of the present invention;

图2是本发明一实施例所示出的图像处理方法流程图;Fig. 2 is a flowchart of an image processing method shown in an embodiment of the present invention;

图3为本发明另一实施例所示出的图像处理方法的示意图;FIG. 3 is a schematic diagram of an image processing method shown in another embodiment of the present invention;

图4是本发明又一实施例所示出的图像获取装置的方块图;Fig. 4 is a block diagram of an image acquisition device shown in another embodiment of the present invention;

图5是本发明又一实施例所示出的图像处理方法流程图;Fig. 5 is a flowchart of an image processing method shown in another embodiment of the present invention;

图6是本发明又一实施例所示出的图5中步骤S550的详细流程图;FIG. 6 is a detailed flowchart of step S550 in FIG. 5 shown in another embodiment of the present invention;

图7是本发明又一实施例所示出的图5中步骤S560的详细流程图;FIG. 7 is a detailed flowchart of step S560 in FIG. 5 shown in another embodiment of the present invention;

图8是本发明的再一实施例所示出的图像获取装置的方块图;Fig. 8 is a block diagram of an image acquisition device shown in another embodiment of the present invention;

图9A是本发明的再一实施例所示出的像素区块的示意图;FIG. 9A is a schematic diagram of a pixel block shown in yet another embodiment of the present invention;

图9B是本发明再一实施例所示出的绝对差值和与权重因子的关系示意图。FIG. 9B is a schematic diagram of the relationship between the absolute difference sum and the weighting factor shown in another embodiment of the present invention.

附图标记说明:Explanation of reference signs:

100、400、800:图像获取装置;100, 400, 800: image acquisition device;

110、410、810:图像获取模块;110, 410, 810: image acquisition module;

120、420、820:图像校正模块;120, 420, 820: image correction module;

130、430、830:梯度计算模块;130, 430, 830: gradient calculation module;

140、440、840:地图产生模块;140, 440, 840: map generation module;

150、450、850:图像合成模块;150, 450, 850: image synthesis module;

460:图像模糊模块;460: image blur module;

860:地图调整模块;860: map adjustment module;

Img1、Img2、Img3、Img_b、Img_F、Img1_blur、Img2_cal:图像Img1, Img2, Img3, Img_b, Img_F, Img1_blur, Img2_cal: image

G1、G2:梯度值;G1, G2: Gradient value;

bokeh_map:散景地图;bokeh_map: bokeh map;

map、allin_map:参数地图;map, allin_map: parameter map;

S210~S250、S510~S560、S610~S625、S710~S750:步骤。S210~S250, S510~S560, S610~S625, S710~S750: steps.

具体实施方式Detailed ways

本发明提出一种通过利用不同焦距值所拍摄的多张图像来产生散景图像以及全景深图像的方法。先对焦于欲拍摄的至少一主体进行并进行拍摄,接着利用另一焦距对同一场景进行拍摄。通过比较两张图像的像素梯度来产生参数地图,可据以判断出图像中的主体部分,进而产生具有散景效果的图像。另一方面,通过比较至少两张图像的像素梯度而产生作为混合图像的依据的参数地图,进而产生全景深图像。为了使本发明的内容更为明了,以下列举实施例作为本发明确实能够据以实施的范例。The present invention proposes a method for generating a bokeh image and a depth-of-view image by using multiple images taken with different focal length values. First focus on at least one subject to be photographed and shoot, and then use another focal length to shoot the same scene. By comparing the pixel gradients of the two images to generate a parameter map, the main part of the image can be judged, and then an image with a bokeh effect can be generated. On the other hand, by comparing pixel gradients of at least two images, a parameter map serving as a basis for blending images is generated, thereby generating a depth-of-view image. In order to make the content of the present invention clearer, the following examples are listed as examples in which the present invention can actually be implemented.

图1是依照本发明一实施例所绘示的影像图像获取装置的功能方块示意图。请参照图1,本实施例的图像获取装置100例如是数码相机、单反相机、数码摄影机或是其他具有图像获取功能的智能手机、平板电脑、头戴显示器等等,不限于上述。图像获取装置100包括图像获取模块110、图像校正模块120、梯度计算模块130、地图产生模块140以及图像合成模块150。FIG. 1 is a schematic functional block diagram of an image acquisition device according to an embodiment of the present invention. Please refer to FIG. 1 , the image acquisition device 100 of this embodiment is, for example, a digital camera, a SLR camera, a digital video camera, or other smart phones, tablet computers, head-mounted displays, etc. with image acquisition functions, and is not limited to the above. The image acquisition device 100 includes an image acquisition module 110 , an image correction module 120 , a gradient calculation module 130 , a map generation module 140 and an image synthesis module 150 .

图像获取模块110包括变焦镜头以及感光元件。感光元件例如是电荷耦合元件(Charge Coupled Device,CCD)、互补性氧化金属半导体(Complementary Metal-Oxide Semiconductor,CMOS)元件或其他元件,图像获取模块110还可包括光圈等,在此皆不设限。图像获取模块110可依据不同的焦距值来获取不同的图像。The image acquisition module 110 includes a zoom lens and a photosensitive element. The photosensitive element is, for example, a charge coupled device (Charge Coupled Device, CCD), a complementary metal oxide semiconductor (Complementary Metal-Oxide Semiconductor, CMOS) element or other elements, and the image acquisition module 110 can also include an aperture, etc., which are not limited here . The image acquisition module 110 can acquire different images according to different focal length values.

另一方面,图像校正模块120、梯度计算模块130、地图产生模块140以及图像合成模块150可由软件、硬件或其组合实作而得,在此不加以限制。软件例如是原始码、操作系统、应用软件或驱动程序等。硬件例如是中央处理单元(Central Processing Unit,CPU),或是其他可程式化的一般用途或特殊用途的微处理器(Microprocessor)。On the other hand, the image correction module 120 , the gradient calculation module 130 , the map generation module 140 and the image synthesis module 150 can be implemented by software, hardware or a combination thereof, which is not limited here. The software is, for example, source code, an operating system, application software, or a driver. The hardware is, for example, a central processing unit (Central Processing Unit, CPU), or other programmable general-purpose or special-purpose microprocessors (Microprocessor).

图2是依照本发明一实施例所绘示的影像图像处理方法流程图。本实施例的方法适用于图1的图像获取装置100,以下即搭配图像获取装置100中的各模块说明本实施例的详细步骤:FIG. 2 is a flowchart of an image processing method according to an embodiment of the present invention. The method of this embodiment is applicable to the image acquisition device 100 in FIG. 1 , and the detailed steps of this embodiment are described below with each module in the image acquisition device 100:

首先,于步骤S210中,图像获取模块110以第一焦距获取第一图像,并以第二焦距获取第二图像,其中第一焦距对焦于至少一主体。也就是说,图像获取模块110利用两种不同的焦距长度拍摄出两张图像。其中,在相同条件下,以不同焦距所拍摄的画面结果会有所不同。具体来说,就对焦于主体的第一图像而言,其图像中的主体部份是最为清晰的。First, in step S210 , the image acquisition module 110 acquires a first image with a first focal length, and acquires a second image with a second focal length, wherein the first focal length focuses on at least one subject. That is to say, the image acquisition module 110 captures two images with two different focal lengths. Among them, under the same conditions, the results of pictures taken with different focal lengths will be different. Specifically, as far as the first image focusing on the subject is concerned, the subject part in the image is the clearest.

于步骤S220中,图像校正模块120对第二图像进行几何校正程序,产生位移校正后的第二图像。由于第一图像与第二图像系由使用者对同一场景连续拍摄所得,期间由于相机的晃动或移动,可能会拍摄出不同角度的图像,即第一图像与第二图像会有位移的产生。因此图像校正模块120对第二图像进行几何校正程序,换言之,几何校正程序可使位移校正后的第二图像的起始像素点位置相同于第一图像的起始像素点位置。In step S220, the image correction module 120 performs a geometric correction procedure on the second image to generate a displacement-corrected second image. Since the first image and the second image are continuously captured by the user on the same scene, images from different angles may be captured due to camera shaking or movement during the period, that is, displacement of the first image and the second image may occur. Therefore, the image correction module 120 performs a geometric correction procedure on the second image. In other words, the geometric correction procedure can make the position of the starting pixel of the displacement-corrected second image the same as that of the first image.

于步骤S230中,梯度计算模块130对第一图像的每一像素点执行一梯度运算以产生多个第一梯度值,以及对位移校正后的第二图像的每一像素点执行梯度运算以产生多个第二梯度值。也就是说,第一图像中的各个像素点具有其第一梯度值,而位移校正后的第二图像中的各个像素点具有其第二梯度值。In step S230, the gradient calculation module 130 performs a gradient operation on each pixel of the first image to generate a plurality of first gradient values, and performs a gradient operation on each pixel of the displacement-corrected second image to generate A plurality of second gradient values. That is to say, each pixel point in the first image has its first gradient value, and each pixel point in the displacement-corrected second image has its second gradient value.

于步骤S240中,地图产生模块140比较各第一梯度值与相对应的各第二梯度值以产生多个第一像素比较结果,并根据第一像素比较结果产生第一参数地图。简单来说,地图产生模块140会将位置相同的像素点的梯度值进行比较,对于每个像素点位置而言都会有一个像素比较结果。In step S240 , the map generation module 140 compares each first gradient value with each corresponding second gradient value to generate a plurality of first pixel comparison results, and generates a first parameter map according to the first pixel comparison results. In simple terms, the map generation module 140 will compare the gradient values of the pixels at the same position, and there will be a pixel comparison result for each pixel position.

于步骤S250中,图像合成模块150依据第一参数地图与第一图像产生合成图像,并至少根据合成图像产生输出图像。详细来说,在取得参数地图之后,图像获取装置100可以依据参数地图混合第一图像以及本身经过其他图像处理后的图像,据以产生合成图像。此外,图像获取装置100也可以依据参数地图混合第一图像与第二图像,据以产生合成图像。In step S250 , the image synthesis module 150 generates a composite image according to the first parameter map and the first image, and at least generates an output image according to the composite image. In detail, after obtaining the parameter map, the image acquisition device 100 may mix the first image and images processed by other images according to the parameter map, so as to generate a composite image. In addition, the image acquisition device 100 may also mix the first image and the second image according to the parameter map, so as to generate a composite image.

值得一提的是,上述实施方式虽然是以两种焦距所拍摄出来的两张图像为例,但本发明并不限制于此。本发明可视实际应用状况而定,延伸为利用多个焦距所拍摄出来的多张图像来取得最终的输出图像。举例来说,由于焦距不同的图像各分别具有不同的清晰图像部份,因此可通过多张不同焦距的图像而取得清晰的全景深图像。另外,本发明的图像处理方法可通过对焦于主体、背景以及前景的三张图像,进而产生出仅有主体清晰的输出图像。以下将列举另一实施例详细说明之。It is worth mentioning that although the above-mentioned embodiment is an example of two images taken with two focal lengths, the present invention is not limited thereto. Depending on the actual application situation, the present invention can be extended to obtain the final output image by using multiple images captured by multiple focal lengths. For example, since images with different focal lengths have different clear image parts, a clear full depth image can be obtained through multiple images with different focal lengths. In addition, the image processing method of the present invention can generate an output image in which only the subject is clear by focusing on the three images of the subject, the background and the foreground. Another embodiment will be described in detail below.

图3为依照本发明另一实施例所绘示的图像处理方法的示意图。在本实施例中,图像获取模块110利用第一焦距与第二焦距获取第一图像Img1与第二图像Img2。之后,如同上述实施例的说明,通过图像校正模块120、梯度计算模块130、地图产生模块、图像合成模块150的处理,可据以产生合成图像Img_b,于此不再赘述。需注意的是,上述实施例中图像合成模块150可将合成图像Img_b作为最后的输出图像,但在本实施例中,合成图像Img_b将进一步与另一图像进行合成而产生最终的输出图像Img_F。详细来说,如图3所示,图像获取模块110将再以第三焦距获取第三图像Img3。图像校正模块120对第三图像Img3进行几何校正程序,产生位移校正后的第三图像Img3。FIG. 3 is a schematic diagram of an image processing method according to another embodiment of the present invention. In this embodiment, the image acquisition module 110 acquires the first image Img1 and the second image Img2 by using the first focal length and the second focal length. Afterwards, as described in the above-mentioned embodiment, through the processing of the image correction module 120 , the gradient calculation module 130 , the map generation module, and the image synthesis module 150 , the synthesized image Img_b can be generated accordingly, which will not be repeated here. It should be noted that in the above embodiments, the image synthesis module 150 can use the synthesized image Img_b as the final output image, but in this embodiment, the synthesized image Img_b will be further synthesized with another image to generate the final output image Img_F. In detail, as shown in FIG. 3 , the image acquisition module 110 will acquire a third image Img3 at a third focal length. The image correction module 120 performs a geometric correction procedure on the third image Img3 to generate a displacement-corrected third image Img3.

之后,梯度计算模块对合成图像Img_b的每一像素点执行梯度运算以产生多个第三梯度值,以及对位移校正后的第三影Img3像的每一像素点执行该梯度运算以产生多个第四梯度值。地图产生模块140比较各第三梯度值与相对应的各第四梯度值以产生多个第二像素比较结果,并根据第二像素比较结果产生第二参数地图。于此的第二参数地图是通过计算合成图像Img_b与第三图像Img3的梯度值而取得,其内部的参数值将与前述的利用第一图像Img1与第二图像Img2所计算出来的参数地图不同。图像合成模块150依据第二参数地图,混合位移校正后的第三图像Img3与该合成图像Img_b产生输出图像Img_F。基于上述可知,本发明并不限制用以混合出最后输出图像的图像数目,可视实际应用需求而定。Afterwards, the gradient calculation module performs a gradient operation on each pixel of the synthesized image Img_b to generate a plurality of third gradient values, and performs the gradient operation on each pixel of the displacement-corrected third image Img3 to generate a plurality of The fourth gradient value. The map generation module 140 compares each third gradient value with each corresponding fourth gradient value to generate a plurality of second pixel comparison results, and generates a second parameter map according to the second pixel comparison results. The second parameter map here is obtained by calculating the gradient value of the synthesized image Img_b and the third image Img3, and its internal parameter values will be different from the aforementioned parameter map calculated by using the first image Img1 and the second image Img2 . The image synthesis module 150 mixes the displacement-corrected third image Img3 and the synthesized image Img_b according to the second parameter map to generate an output image Img_F. Based on the above, it can be seen that the present invention does not limit the number of images used to mix the final output image, which can be determined according to actual application requirements.

然而,本发明的实现方式不限于上述说明,可以对于实际的需求而酌予变更上述实施例的内容。例如,在本发明的再一实施例中,图像获取装置还可以更包括图像模糊模块,以制作出具有散景效果的主体清晰图像。另外,在本发明的又一实施例中,图像获取装置还可以更包括地图调整模块,以制作出具有良好全景深效果的全景深图像。为了进一步说明本发明的梯度计算模块、地图产生模块以及图像合成模块如何依据不同焦距的图像而合成出散景图像以及全景深图像,以下将分别列举实施例详细说明。However, the implementation manner of the present invention is not limited to the above description, and the content of the above embodiments may be modified according to actual requirements. For example, in yet another embodiment of the present invention, the image acquisition device may further include an image blur module to produce a clear image of the subject with a bokeh effect. In addition, in yet another embodiment of the present invention, the image acquisition device may further include a map adjustment module to produce a full depth image with a good full depth effect. In order to further illustrate how the gradient calculation module, the map generation module, and the image synthesis module of the present invention synthesize bokeh images and depth-of-view images based on images with different focal lengths, examples are given below in detail.

图4是依照本发明的又一实施例所绘示的图像获取装置的方块图。图像获取装置400包括图像获取模块410、图像校正模块420、梯度计算模块430、地图产收模块440、图像合成模块450以及图像模糊模块460。其中,图像获取模块410、图像校正模块420、梯度计算模块430、地图产收模块440以及图像合成模块450相似或类似于图1所示的图像获取模块110、图像校正模块120、梯度计算模块130、地图产收模块140以及图像合成模块150,于此不再赘述。图4所示实施例可以参照图1至图3的相关说明而类推之。FIG. 4 is a block diagram of an image acquisition device according to another embodiment of the present invention. The image acquisition device 400 includes an image acquisition module 410 , an image correction module 420 , a gradient calculation module 430 , a map yield module 440 , an image synthesis module 450 and an image blur module 460 . Wherein, the image acquisition module 410, the image correction module 420, the gradient calculation module 430, the map yield module 440 and the image synthesis module 450 are similar or similar to the image acquisition module 110, the image correction module 120, and the gradient calculation module 130 shown in FIG. , the map production module 140 and the image synthesis module 150 will not be repeated here. The embodiment shown in FIG. 4 can be deduced by referring to the relevant descriptions in FIG. 1 to FIG. 3 .

需特别说明的是,与图1所示的图像获取装置100不同的是,图像获取装置400更包括图像模糊模块460。其中,图像模糊模块460例如是采用高斯滤波器(Gaussian filter)、双向滤波器(Bilateral filter)或平均滤波器(Averagefilter)等,用以对第一图像Img1进行模糊化程序,本发明对此不限制。另外,在本实施例中,假设第二焦距为对焦于背景的焦距。It should be noted that, unlike the image acquisition device 100 shown in FIG. 1 , the image acquisition device 400 further includes an image blur module 460 . Wherein, the image blurring module 460, for example, adopts a Gaussian filter (Gaussian filter), a bidirectional filter (Bilateral filter) or an average filter (Average filter), etc., to perform a blurring process on the first image Img1, which is not discussed in the present invention. limit. In addition, in this embodiment, it is assumed that the second focal length is the focal length focusing on the background.

图5是依照本发明一实施例所绘示的图像处理方法流程图。本实施例的方法适用于图4的图像获取装置400,以下即搭配图像获取装置400中的各模块说明本实施例的详细步骤:FIG. 5 is a flowchart of an image processing method according to an embodiment of the present invention. The method of this embodiment is applicable to the image acquisition device 400 in FIG. 4 , and the detailed steps of this embodiment are described below with each module in the image acquisition device 400:

首先于步骤S510中,图像获取模块410以第一焦距获取第一图像Img1,并以第二焦距获取第二图像Img2,其中第一焦距对焦于至少一主体,第二焦距对焦于背景。对焦于主体所拍摄出来的第一图像Img1中,主体较为清晰,背景较为模糊。相较于第一图像Img1,对焦于背景所拍摄出来的第二图像Img2中,背景较为清晰。接着,如步骤S520所述,图像模糊模块460对第一图像Img1进行模糊化程序,以产生模糊图像Img1_blur。First, in step S510 , the image acquisition module 410 acquires the first image Img1 with the first focal length, and acquires the second image Img2 with the second focal length, wherein the first focal length is focused on at least one subject, and the second focal length is focused on the background. In the first image Img1 captured by focusing on the subject, the subject is relatively clear and the background is relatively blurred. Compared with the first image Img1, in the second image Img2 captured by focusing on the background, the background is clearer. Next, as described in step S520 , the image blur module 460 performs a blur procedure on the first image Img1 to generate a blurred image Img1_blur.

于步骤S530中,图像校正模块420对第二图像Img2进行几何校正程序,产生位移校正后的第二图像Img2_cal。详言之,图像校正模块420可对第一图像Img1与第二图像Img2进行移动量估测,藉以计算出单应性矩阵(homography matrix)。接着,图像校正模块420依据此单应性矩阵对第二图像Img2进行几何仿射转换(affine transformation),以获得转换后的位移校正后的第二图像Img2_cal。据此,第一图像Img1中主体区域的起始像素点位置会与位移校正后的第二图像Img2_cal主体区域的起始像素点位置相同。In step S530 , the image correction module 420 performs a geometric correction procedure on the second image Img2 to generate a displacement-corrected second image Img2_cal. In detail, the image correction module 420 may perform motion estimation on the first image Img1 and the second image Img2, so as to calculate a homography matrix. Next, the image correction module 420 performs geometric affine transformation on the second image Img2 according to the homography matrix to obtain a transformed second image Img2_cal after displacement correction. Accordingly, the starting pixel position of the main body area in the first image Img1 is the same as the starting pixel position of the main body area in the displacement-corrected second image Img2_cal.

然后,于步骤S540中,梯度计算模块430对第一图像Img1的每一像素点执行梯度运算以产生多个第一梯度值G1,以及对位移校正后的第二图像Img2_cal的每一像素点执行梯度运算以产生多个第二梯度值G2。其中,梯度运算可以是水平方向梯度值运算、垂直方向梯度值运算或二对角线方向梯度值运算,本发明对此不限制。也就是说,第一梯度值与第二梯度值对应于其梯度运算的方式可以是水平方向梯度值、垂直方向梯度值或二对角线方向梯度值。其中,水平方向梯度值为此像素点与二相邻水平方向像素点的灰阶差绝对值之和。垂直方向梯度值为此像素点与二相邻垂直方向像素点的灰阶差绝对值之和。对角线方向梯度值包括此像素点与对角线方向像素点的灰阶差绝对值之和。Then, in step S540, the gradient calculation module 430 performs gradient calculation on each pixel of the first image Img1 to generate a plurality of first gradient values G1, and performs gradient calculation on each pixel of the displacement-corrected second image Img2_cal Gradient operation to generate a plurality of second gradient values G2. Wherein, the gradient operation may be a gradient value operation in a horizontal direction, a gradient value operation in a vertical direction, or a gradient value operation in a two-diagonal direction, which is not limited in the present invention. That is to say, the first gradient value and the second gradient value correspond to the gradient calculation method may be a gradient value in the horizontal direction, a gradient value in the vertical direction, or a gradient value in the two diagonal directions. Wherein, the gradient value in the horizontal direction is the sum of the absolute values of grayscale differences between this pixel point and two adjacent horizontal direction pixel points. The gradient value in the vertical direction is the sum of the absolute values of gray scale differences between this pixel and two adjacent pixels in the vertical direction. The gradient value in the diagonal direction includes the sum of the absolute value of the gray scale difference between this pixel point and the pixel point in the diagonal direction.

需说明的是,在本实施例中,由于第一图像Img1是对焦于主体所拍摄的图像,所以相较于位移校正图像Img2_cal而言,第一图像Img1中的主体会较为清晰。也就是说,第一图像Img1的焦距内主体区域的像素点的梯度值会大于位移校正后的第二图像Img2_cal的相同位置的像素点的梯度值。反之,由于位移校正后的第二图像Img2_cal是对焦于背景所产生的图像,所以第一图像Img1的背景区域的像素点的梯度值会小于位移校正图像Img2_cal的相同位置的像素点的梯度值。It should be noted that, in this embodiment, since the first image Img1 is an image focused on the subject, the subject in the first image Img1 will be clearer than the displacement-corrected image Img2_cal. That is to say, the gradient value of the pixel point in the in-focus area of the first image Img1 is greater than the gradient value of the pixel point at the same position in the displacement-corrected second image Img2_cal. Conversely, since the displacement-corrected second image Img2_cal is an image produced by focusing on the background, the gradient values of the pixels in the background area of the first image Img1 will be smaller than the gradient values of the pixels at the same position in the displacement-corrected image Img2_cal.

基此,于步骤S550中,地图产生模块440比较各第一梯度值G1与相对应的各第二梯度值G2以产生多个比较结果,并根据比较结果产生参数地图。需说明的是,在本实施例中,参数地图称之为散景地图bokeh_map。详细来说,地图产生模块440将比较第一图像Img1与位移校正后的第二图像Img2_cal中各个相同位置的像素点的梯度值。再者,基于上述第一图像Img1与位移校正后的第二图像Img2_cal中各像素点的梯度值的关系,可通过比较结果判别出第一图像Img1中各个像素点是位于主体区域或背景区域。地图产生模块440通过第一图像Img1与位移校正后的第二图像Img2_cal中各像素点的梯度值的比较结果,可产生出散景地图bokeh_map。换句话说,散景地图bokeh_map带有第一图像Img1与位移校正后的第二图像Img2_cal中各位置相同的像素点的梯度值的比较结果资讯。Based on this, in step S550 , the map generation module 440 compares each first gradient value G1 with each corresponding second gradient value G2 to generate a plurality of comparison results, and generates a parameter map according to the comparison results. It should be noted that, in this embodiment, the parameter map is called a bokeh map bokeh_map. In detail, the map generating module 440 will compare the gradient values of the pixels at the same positions in the first image Img1 and the displacement-corrected second image Img2_cal. Moreover, based on the relationship between the gradient value of each pixel in the first image Img1 and the displacement-corrected second image Img2_cal, it can be determined whether each pixel in the first image Img1 is located in the subject area or the background area through the comparison result. The map generating module 440 can generate a bokeh map bokeh_map by comparing the gradient values of each pixel in the first image Img1 and the displacement-corrected second image Img2_cal. In other words, the bokeh map bokeh_map carries the comparison result information of the gradient values of the pixels at the same positions in the first image Img1 and the displacement-corrected second image Img2_cal.

最后,于步骤S560中,图像合成模块450根据散景地图bokeh_map混合第一图像Img1与模糊图像Img1_blur以产生主体清晰图像Img1_bokeh。由此可见,第二图像Img2是用以产生散景地图bokeh_map,图像合成模块450是根据散景地图bokeh_map混合第一图像Img1与模糊图像Img1_blur来产生具有散景效果的主体清晰图像Img1_bokeh。如此一来,就可产生保持被摄主体区域的清晰而模糊其他背景区域的散景图像。Finally, in step S560 , the image synthesis module 450 mixes the first image Img1 and the blurred image Img1_blur according to the bokeh map bokeh_map to generate the subject sharp image Img1_bokeh. It can be seen that the second image Img2 is used to generate the bokeh map bokeh_map, and the image synthesis module 450 mixes the first image Img1 and the blurred image Img1_blur according to the bokeh map bokeh_map to generate the subject clear image Img1_bokeh with a bokeh effect. This creates a bokeh image that maintains the sharpness of the subject area while blurring other background areas.

另外,以下将更进一步详细说明地图产生模块440如何根据比较各第一梯度值G1与相对应的各第二梯度值G2的结果来产生散景地图bokeh_map。图6是根据本发明实施例所绘示图5中步骤S550的详细流程图。请同时参照图4与图6,在步骤S610中,地图产生模块440将第二梯度值G2除以相对应的第一梯度值G1,产生梯度比较值。在步骤S620中,地图产生模块440依据梯度比较值产生多个参数值,并将参数值记录为散景地图bokeh_map。举例来说,若第一图像Img1与位移校正图像Img2_cal分别具有1024*768个像素点,在经由图像处理模块140运算后将产生1024*768个梯度比较值,则散景地图bokeh_map将包含1024*768个参数值。在此,步骤S620可以分为步骤S621至步骤S625实施之。In addition, how the map generating module 440 generates the bokeh map bokeh_map according to the result of comparing each first gradient value G1 with each corresponding second gradient value G2 will be further described in detail below. FIG. 6 is a detailed flowchart of step S550 in FIG. 5 according to an embodiment of the present invention. Please refer to FIG. 4 and FIG. 6 at the same time. In step S610 , the map generation module 440 divides the second gradient value G2 by the corresponding first gradient value G1 to generate a gradient comparison value. In step S620, the map generation module 440 generates a plurality of parameter values according to the gradient comparison value, and records the parameter values as a bokeh map bokeh_map. For example, if the first image Img1 and the displacement-corrected image Img2_cal respectively have 1024*768 pixels, after being calculated by the image processing module 140, 1024*768 gradient comparison values will be generated, and the bokeh map bokeh_map will contain 1024* 768 parameter values. Here, step S620 can be divided into steps S621 to S625 for implementation.

地图产生模块440判断各个位置的梯度比较值是否大于第一梯度临界值(步骤S621)。若梯度比较值大于第一梯度临界值,地图产生模块440设定对应于此梯度比较值的参数值为第一数值(步骤S622),于此称第一数值为散景背景值。换言之,若梯度比较值大于第一梯度临界值,代表此位置的像素点位于背景的区域。若梯度比较值并没有大于第一梯度临界值,地图产生模块440判断梯度比较值是否大于第二梯度临界值(步骤S623)。若梯度比较值大于第二梯度临界值,地图产生模块440设定对应于此梯度比较值的参数值为第二数值(步骤S324),在此称第二数值为散景边缘值。简单来说,若梯度比较值介于第二梯度临界值与第一梯度临界值之间,代表此位置的像素点位于主体连接背景之间的边缘区域。若梯度比较值没有大于第二梯度临界值,地图产生模块440设定对应于此梯度比较值的参数值设定为第三数值(步骤S625),在此称第三数值为散景主体值,即此位置的像素点位于主体的区域。需注意的是,散景边缘值将介于散景背景值与散景主体值之间,且第一梯度临界值大于第二梯度临界值,而第一梯度临界值与是第二梯度临界值依据实际情况而适当设定,本发明对此不限制。The map generating module 440 determines whether the gradient comparison value of each position is greater than the first gradient critical value (step S621 ). If the gradient comparison value is greater than the first gradient critical value, the map generation module 440 sets the parameter value corresponding to the gradient comparison value as a first value (step S622 ), which is called the bokeh background value here. In other words, if the gradient comparison value is greater than the first gradient critical value, it means that the pixel at this position is located in the background area. If the gradient comparison value is not greater than the first gradient critical value, the map generation module 440 determines whether the gradient comparison value is greater than the second gradient critical value (step S623 ). If the gradient comparison value is greater than the second gradient critical value, the map generation module 440 sets the parameter value corresponding to the gradient comparison value as a second value (step S324 ), which is called a bokeh edge value here. In simple terms, if the gradient comparison value is between the second gradient critical value and the first gradient critical value, the pixel representing this position is located in the edge area between the subject and the background. If the gradient comparison value is not greater than the second gradient critical value, the map generation module 440 sets the parameter value corresponding to the gradient comparison value as a third value (step S625), and the third value is called the bokeh subject value here, That is, the pixel at this position is located in the area of the subject. Note that the Bokeh Edge value will be between the Bokeh Background value and the Bokeh Body value, and that the first gradient threshold is greater than the second gradient threshold, and the first gradient threshold and the second gradient threshold It is properly set according to the actual situation, and the present invention is not limited thereto.

举例来说,假设地图产生模块440设定参数值介于0与255之间,则图像处理模块140可利用下列程式码(1)来产生散景地图bokeh_map:For example, assuming that the map generation module 440 sets the parameter value between 0 and 255, the image processing module 140 can use the following code (1) to generate the bokeh map bokeh_map:

ifif (( GraGra 22 GraGra 11 >> THTH 11 ))

Map=255Map=255

elseifelse if (( GraGra 22 GraGra 11 >> THTH 22 ))

Mapmap == GraGra 22 GraGra 11 -- THTH 22 THTH 11 -- THTH 22 ×× 255255

elseelse

Map=0Map=0

(1) (1)

其中,在此示范性实施例中,散景背景值为255,散景主体值为0,而散景边缘值可通过第一梯度临界、第二梯度临界值以及第二梯度值与第一梯度值之间的比例计算而得。Gra2为第二梯度值,Gra1为第一梯度值,TH1为第一梯度临界值,TH2为第二梯度临界值,Map为散景地图bokeh_map中的多个参数值。Wherein, in this exemplary embodiment, the bokeh background value is 255, the bokeh main value is 0, and the bokeh edge value can pass through the first gradient threshold, the second gradient threshold, and the second gradient value and the first gradient Calculated as a ratio between values. Gra2 is the second gradient value, Gra1 is the first gradient value, TH1 is the first gradient critical value, TH2 is the second gradient critical value, and Map is multiple parameter values in the bokeh map bokeh_map.

此外,为了详细说明图像合成模块450如何利用散景地图bokeh_map来产生主体清晰图像Img1_bokeh,以下将详细说明之。图7是根据本发明范例实施例所绘示图5中步骤S560的详细流程图,请同时参照图4与图7。需说明的是,第一图像Img1中的各位置的像素点可分别对应至散景地图bokeh_map中的各个参数值。在步骤S710中,图像合成模块450判断各个参数值是否大于第一混合临界值。若参数值大于第一混合临界值,在步骤S720中,图像合成模块450取这些参数值所对应的模糊图像Img1_blur的像素点作为主体清晰图像Img1_bokeh中相同位置的像素点。即此些位置的像素点被判别为背景区域,因此取模糊图像Img1_blur的像素点来产生背景模糊的图像。In addition, in order to describe in detail how the image synthesis module 450 utilizes the bokeh map bokeh_map to generate the sharp subject image Img1_bokeh, it will be described in detail below. FIG. 7 is a detailed flowchart of step S560 in FIG. 5 according to an exemplary embodiment of the present invention. Please refer to FIG. 4 and FIG. 7 at the same time. It should be noted that the pixel points at each position in the first image Img1 may respectively correspond to each parameter value in the bokeh map bokeh_map. In step S710, the image composition module 450 determines whether each parameter value is greater than a first mixing threshold. If the parameter value is greater than the first blending threshold, in step S720 , the image composition module 450 takes the pixels of the blurred image Img1_blur corresponding to these parameter values as the pixels at the same position in the subject clear image Img1_bokeh. That is, the pixels at these positions are identified as the background area, so the pixels of the blurred image Img1_blur are used to generate a blurred background image.

若参数值没有大于第一混合临界值,在步骤S730中,图像混合模块150判断参数值是否大于第二混合临界值。若参数值大于第二混合临界值,在步骤S740中,图像合成模块450依据参数值计算此参数值所对应的主体清晰图像Img1_bokeh的像素点。详言之,这些介于第一混合临界值与第二混合临界值之间的参数值所对应的像素点位置被判别是位于背景区域连接主体区域之间的边缘区域。因此可通过合成第一图像Img1与模糊图像Img1_blur,来取得主体清晰图像Img1_bokeh中背景区域连接主体区域之间的边缘区域的像素点。If the parameter value is not greater than the first blending threshold, in step S730, the image blending module 150 determines whether the parameter value is greater than the second blending threshold. If the parameter value is greater than the second blending threshold, in step S740 , the image composition module 450 calculates the pixel points of the clear subject image Img1_bokeh corresponding to the parameter value according to the parameter value. Specifically, the pixel positions corresponding to the parameter values between the first blending threshold and the second blending threshold are determined to be edge regions between the background region and the subject region. Therefore, the pixels in the edge area between the background area and the main body area in the main body clear image Img1_bokeh can be obtained by synthesizing the first image Img1 and the blurred image Img1_blur.

若参数值没有大于第二混合临界值,在步骤S750中,图像合成模块450取参数值所对应的第一图像Img_1的像素点为主体清晰图像Img1_bokeh的像素点。也就是说,这些参数值所对应的位置被判别位于主体区域中,因此将取清晰的第一图像Img_1中主体区域的像素点作为主体清晰图像Img1_bokeh中的主体区域像素点。其中,第一混合临界值大于第二混合临界值。If the parameter value is not greater than the second blending threshold, in step S750 , the image composition module 450 takes the pixel of the first image Img_1 corresponding to the parameter value as the pixel of the subject clear image Img1_bokeh. That is to say, the positions corresponding to these parameter values are judged to be in the subject area, so the pixels of the subject area in the clear first image Img_1 are taken as the subject area pixels in the clear subject image Img1_bokeh. Wherein, the first mixing critical value is greater than the second mixing critical value.

举例来说,假设图像合成模块450设定参数值介于0与255之间,图像合成模块450可利用下列程式码(2)来产生主体清晰图像Img1_bokeh:For example, assuming that the image synthesis module 450 sets the parameter value between 0 and 255, the image synthesis module 450 can use the following program code (2) to generate the subject clear image Img1_bokeh:

if(Map≥Blend_TH1)//Background areaif(Map≥Blend_TH1)//Background area

Img1_Bokeh=Img1_BlurImg1_Bokeh=Img1_Blur

else if(Map≥Blend_TH2)//Transition areaelse if(Map≥Blend_TH2)//Transition area

wBokeh=LUT[Map](LUT is table and value range is0~255)w Bokeh =LUT[Map](LUT is table and value range is0~255)

ImgImg 11 __ BokehBokeh == ww BokehBokeh ×× ImgImg 11 ++ (( 256256 -- ww BokehBokeh )) ×× ImgImg 11 __ BlurBlurred 256256

else//Subjectelse//Subject

Img1_Bokeh=Img1Img1_Bokeh=Img1

(2) (2)

其中,在此示范性实施例中,Blend_TH1为第一混合临界值,Blend_TH2为第二混合临界值,Map为散景地图bokeh_map中的多个参数值,LUT[]为查表函式。值得一提的是,边缘区域的像素点可通过权重的概念来计算取得。如上述示范性程式码中的公式所示,将参数值作为合成权重wbokeh,并通过合成权重wbokeh来合成出边缘区域的像素点。也就是说,对于边缘区域的像素点而言,将视其位置较靠近主体区域或模糊区域来决定其模糊的程度,如此一来就可以产生主体区域与背景区域连接自然的主体清晰图像Img1_bokeh,使散景图像中主体与背景之间的边缘能较为柔和且自然。Wherein, in this exemplary embodiment, Blend_TH1 is the first blending threshold, Blend_TH2 is the second blending threshold, Map is a plurality of parameter values in the bokeh map bokeh_map, and LUT[] is a look-up table function. It is worth mentioning that the pixels in the edge area can be calculated by the concept of weight. As shown in the formula in the above exemplary program code, the parameter value is used as the synthesis weight w bokeh , and the pixels in the edge area are synthesized by the synthesis weight w bokeh . That is to say, for the pixels in the edge area, the degree of blur will be determined depending on its position closer to the main area or the blurred area, so that a clear main image Img1_bokeh with a natural connection between the main area and the background area can be generated. Makes the edges between the subject and the background soft and natural in bokeh images.

在上述实施例中,以第二焦距值对焦于背景为例,因此可据以产生背景模糊而主体清晰的背景模糊图像。经由图3的说明可知,本发明的图像处理方法可以通过多张图像来获得最后的输出图像。基此,在其他实施例中,倘若图像获取装置以对焦于前景的第三焦距获取另一图像。图像获取装置可以利用先前产生的背景模糊图像与对焦于前景的另一图像,经由与上述产生背景模糊图像相同的处理过程,进一步计算而产生前景与背景皆模糊而主体清晰的图像。In the above embodiments, the second focal length value is used as an example to focus on the background, so a blurred background image with a blurred background and a clear subject can be generated accordingly. It can be seen from the description of FIG. 3 that the image processing method of the present invention can obtain a final output image through multiple images. Based on this, in other embodiments, it is assumed that the image acquisition device acquires another image with a third focal length focusing on the foreground. The image acquisition device can use the previously generated image with blurred background and another image focused on the foreground, and perform further calculations to generate an image with blurred foreground and background and clear subject through the same process as the above-mentioned generation of the blurred background image.

图8是依照本发明的再一实施例所绘示的图像获取装置的方块图。请参照图8,在本实施例中,图像获取装置800用以产生全景深的图像。图像获取装置800包括图像获取模块810、图像校正模块820、梯度计算模块830、地图产生模块840、图像合成模块850以及地图调整模块860。其中,图像获取模块810、图像校正模块820、梯度计算模块830、地图产生模块840以及图像合成模块850相似或类似于图4所示的图像获取模块410、图像校正模块420、梯度计算模块430、地图产生模块440以及图像合成模块450,于此不再赘述。FIG. 8 is a block diagram of an image acquisition device according to yet another embodiment of the present invention. Please refer to FIG. 8 , in this embodiment, an image acquisition device 800 is used to generate a full-depth image. The image acquisition device 800 includes an image acquisition module 810 , an image correction module 820 , a gradient calculation module 830 , a map generation module 840 , an image synthesis module 850 and a map adjustment module 860 . Wherein, the image acquisition module 810, the image correction module 820, the gradient calculation module 830, the map generation module 840 and the image synthesis module 850 are similar or similar to the image acquisition module 410 shown in FIG. 4, the image correction module 420, the gradient calculation module 430, The map generation module 440 and the image synthesis module 450 will not be repeated here.

需特别说明的是,与图4所示的图像获取装置400不同的是,本实施例之与图像获取装置800不具有图像模糊模块但更包括地图调整模块860。其中,地图调整模块860用以调整地图产生模块840所产生的参数地图。在本实施例中,图像获取模块810利用第一焦距获取第一图像Img1,并以第二焦距获取第二图像Img2,其中第一焦距对焦于至少一主体,第二焦距对焦于主体以外的区域。It should be noted that, unlike the image acquisition device 400 shown in FIG. 4 , the image acquisition device 800 in this embodiment does not have an image blur module but further includes a map adjustment module 860 . Wherein, the map adjustment module 860 is used for adjusting the parameter map generated by the map generation module 840 . In this embodiment, the image acquisition module 810 acquires the first image Img1 with the first focal length, and acquires the second image Img2 with the second focal length, wherein the first focal length is focused on at least one subject, and the second focal length is focused on an area other than the subject .

接着,图像校正模块830对第二图像Img2进行几何校正程序,产生位移校正后的第二图像Img2_cal。然后梯度计算模块840对第一图像Img1的每一像素点执行梯度运算以产生多个第一梯度值G1,以及对位移校正后的第二图像Img2_cal的每一像素点执行梯度运算以产生多个第二梯度值G2。接着,地图产生模块840比较各第一梯度值G1与相对应的各第二梯度值G2以产生多个比较结果,并根据比较结果产生参数地图map。关于图像校正模块830产生位移校正后的第二图像Img2_cal的步骤、梯度计算模块830执行梯度运算的步骤,以及地图产生模块840产生参数地图map的步骤与图4所示的图像获取模块400类似,可参照图4与图5的说明而类推之。Next, the image correction module 830 performs a geometric correction procedure on the second image Img2 to generate a displacement-corrected second image Img2_cal. Then the gradient calculation module 840 performs a gradient operation on each pixel of the first image Img1 to generate a plurality of first gradient values G1, and performs a gradient operation on each pixel of the displacement-corrected second image Img2_cal to generate a plurality of The second gradient value G2. Next, the map generating module 840 compares each first gradient value G1 with each corresponding second gradient value G2 to generate a plurality of comparison results, and generates a parameter map according to the comparison results. The steps of the image correction module 830 generating the displacement-corrected second image Img2_cal, the steps of the gradient calculation module 830 performing the gradient calculation, and the steps of the map generation module 840 generating the parameter map map are similar to the image acquisition module 400 shown in FIG. 4 , The description of FIG. 4 and FIG. 5 can be referred to and analogized.

一般来说,同一位置像素点于两张图像上的梯度值会相异,也就是本实施例当中的第一梯度值G1与第二梯度值G2。另一方面,对同一位置的像素点而言,倘若该位置的像素点于第一图像中的梯度值较高(即G1大于G2),通常代表该位置的像素点坐落于第一图像中较为清晰的区域(即第一焦距内的区域)。倘若该位置的像素点于第二图像中的梯度值较高(即G2大于G1),通常代表该位置的像素点坐落于第二图像中较为清晰的区域(即第二焦距内的区域)。也就是说,地图产生模块840也可以通过程式码(1)而取得参数地图map,但本发明并不限制于此。Generally speaking, the gradient values of the pixel at the same position on the two images are different, that is, the first gradient value G1 and the second gradient value G2 in this embodiment. On the other hand, for the pixels at the same position, if the gradient value of the pixel at the position in the first image is relatively high (that is, G1 is greater than G2), it usually means that the pixel at the position is located in the first image more easily. The clear area (i.e. the area within the first focal length). If the pixel at this position has a higher gradient value in the second image (ie, G2 is greater than G1), it usually means that the pixel at this position is located in a clearer area in the second image (ie, the area within the second focal length). That is to say, the map generating module 840 can also obtain the parameter map through the code (1), but the present invention is not limited thereto.

因此,在本实施例中,地图产生模块440通过第一图像Img1与位移校正后的第二图像Img2_cal中各像素点的梯度值的比较结果,可产生出参数地图map。换句话说,参数地图map带有第一图像Img1与位移校正后的第二图像Img2_cal中各位置相同的像素点的梯度值的比较结果资讯。如此一来,图像获取装置800可以依据参数地图map得知,某一位置上的像素点是位于第一图像Img1中第一焦距内的清晰部份或是位于第二图像Img2中第二焦距内的清晰部份。据此,图像合成模块850可据以从两张图像中挑选出较为清晰的部份,以合成出清晰部份更多的输出图像。Therefore, in this embodiment, the map generation module 440 can generate a parameter map by comparing the gradient values of each pixel in the first image Img1 and the displacement-corrected second image Img2_cal. In other words, the parameter map carries the comparison result information of the gradient values of the pixels at the same positions in the first image Img1 and the displacement-corrected second image Img2_cal. In this way, the image acquisition device 800 can know according to the parameter map, whether the pixel at a certain position is located in the clear part within the first focal length in the first image Img1 or within the second focal length in the second image Img2 clear part of . Accordingly, the image synthesis module 850 can select clearer parts from the two images to synthesize an output image with more clear parts.

值得一提的是,在使用者对同一场景进行连续拍摄并获取第一图像与第二图像的过程当中,由于拍摄上的时间差场景中,因此可能导致有个别物体在移动。图像校正模块820是将图像做整体位移(或是相机位移)的校正,并不会对场景中的个别物体做校正,因此图像中若有个别移动的物体,会导致混合后的全景深图像出现鬼影现象。本实施例的地图调整模块860即用以改善上述的鬼影现象。It is worth mentioning that during the process of continuous shooting of the same scene by the user and obtaining the first image and the second image, some objects may be moving due to the time difference in shooting. The image correction module 820 corrects the overall displacement (or camera displacement) of the image, and does not correct individual objects in the scene. Therefore, if there are individual moving objects in the image, the mixed depth-of-view image will appear Ghosting phenomenon. The map adjustment module 860 of this embodiment is used to improve the above-mentioned ghost phenomenon.

于此,地图调整模块860依据第一图像Img1与第二图像Img2中各像素点的像素值计算出各像素点所对应的多个绝对差值和(Sum of AbsoluteDifferences),并依据这些绝对差值和调整参数地图map中的多个参数值。地图调整模块860根据调整后的参考地图map,混合第一图像Img1与位移校正后的第二图像Img2_cal以产生全景深图像。Here, the map adjustment module 860 calculates a plurality of sums of absolute differences (Sum of Absolute Differences) corresponding to each pixel according to the pixel values of each pixel in the first image Img1 and the second image Img2, and based on these absolute differences And adjust multiple parameter values in the parameter map map. The map adjustment module 860 mixes the first image Img1 and the displacement-corrected second image Img2_cal according to the adjusted reference map to generate a full depth image.

详细来说,首先在第一图像Img1中取得n×n像素区块(n为正整数)。假设n为5,本实施例所取得的5×5像素区块则如图9A所示,其包括25个像素位置P00~P44。类似地,在位移校正后的第二图像Img2_cal中取得以像素位置为中心的n×n像素区块。接着,计算第一图像Img1与位移校正后的第二图像Img2_cal个别的n×n像素区块中每一像素的特定色彩空间分量的绝对差值和并找出其最大值作为代表。绝对差值合能反映Img1与位移校正后的第二图像Img2_cal在n×n像素区块这个局部区域内的特性是否接近。在YCbCr色彩空间下,特定色彩空间分量包括亮度分量、蓝色色度分量,以及红色色度分量,然而本发明并不对色彩空间加以限定。基于YCbCr色彩空间下,本实施例例如是假设n=5并以下列公式来计算第一图像Img1与位移校正后的第二图像Img2_cal的像素位置之间的绝对差值和SAD:In detail, firstly, an n×n pixel block (n is a positive integer) is obtained from the first image Img1. Assuming that n is 5, the 5×5 pixel block obtained in this embodiment is as shown in FIG. 9A , which includes 25 pixel positions P 00 ˜P 44 . Similarly, an n×n pixel block centered on the pixel position is obtained in the displacement-corrected second image Img2_cal. Next, calculate the sum of absolute differences of specific color space components of each pixel in each n×n pixel block of the first image Img1 and the displacement-corrected second image Img2_cal and find its maximum value as a representative. The absolute difference can reflect whether the characteristics of the Img1 and the displacement-corrected second image Img2_cal in the local area of n×n pixel blocks are close. In the YCbCr color space, specific color space components include luma components, blue chrominance components, and red chrominance components, but the present invention does not limit the color space. Based on the YCbCr color space, this embodiment assumes that n=5 and uses the following formula to calculate the absolute difference and SAD between the pixel positions of the first image Img1 and the displacement-corrected second image Img2_cal:

SADSAD __ YY == ΣΣ ii == 00 ,, jj == 00 ii == 44 ·· jj == 44 || YY 11 ijij -- YY 22 ijij ||

SADSAD __ CbCb == ΣΣ ii == 00 ,, jj == 00 ii == 44 ·&Center Dot; jj == 44 || CbCb 11 ijij -- CbCb 22 ijij ||

SADSAD __ CrCr == ΣΣ ii == 00 ,, jj == 00 ii == 44 ·&Center Dot; jj == 44 || CrCr 11 ijij -- CrCr 22 ijij ||

SAD=max(max(SAD_Y,SAD_Cb),SAD_Cr)SAD=max(max(SAD_Y,SAD_Cb),SAD_Cr)

其中,i与j代表像素点的位置。如图9A所示的范例,每一像素区块包括25个像素位置P00~P44。而Y1ij即为第一图像中像素点Pij的亮度分量,Y2ij即为第二图像中像素点Pij的亮度分量。Cb1ij即为第一图像中像素点Pij的蓝色色度分量,Cb2ij即为第二图像中像素点Pij的蓝色色度分量。Cr1ij即为第一图像中像素点Pij的红色色度分量,Cr2ij即为第二图像中像素点Pij的红色色度分量。SAD_Y、SAD_Cb以及SAD_Cr则分别为各特定色彩空间分量上的绝对差值和。Among them, i and j represent the position of the pixel. As shown in the example of FIG. 9A , each pixel block includes 25 pixel positions P 00 ˜P 44 . Y1 ij is the luminance component of the pixel P ij in the first image, and Y2 ij is the luminance component of the pixel P ij in the second image. Cb1 ij is the blue chroma component of the pixel P ij in the first image, and Cb2 ij is the blue chroma component of the pixel P ij in the second image. Cr1 ij is the red chroma component of the pixel P ij in the first image, and Cr2 ij is the red chroma component of the pixel P ij in the second image. SAD_Y, SAD_Cb, and SAD_Cr are sums of absolute differences on each specific color space component, respectively.

基此,本发明的地图调整模块860例如是利用上述计算公式而取得绝对差值和SAD。之后,地图调整模块860将判断绝对差值和SAD是否大于移动临界值TH_SAD。若绝对差值和SAD没有大于移动临界值TH_SAD,代表此像素区块没有被摄物体移动的情况发生,并不需要调整此像素区块对应于参数地图中的参数值。倘若绝对差值和SAD大于移动临界值TH_SAD,代表此像素区块具有被摄物体移动现象,因此地图调整模块860将依照绝对差值和SAD的大小来调整此像素区块对应于参数地图中的参数值。举例来说,地图调整模块860可利用下列程式码(3)来产生调整后的参数地图allin_map:Based on this, the map adjustment module 860 of the present invention, for example, obtains the absolute difference and SAD by using the above calculation formula. Afterwards, the map adjustment module 860 will determine whether the sum of absolute differences SAD is greater than the movement threshold TH_SAD. If the absolute difference and SAD are not greater than the movement threshold TH_SAD, it means that the pixel block does not have the subject moving, and there is no need to adjust the parameter value corresponding to the pixel block in the parameter map. If the absolute difference and SAD are greater than the movement threshold TH_SAD, it means that the object has moved in this pixel block. Therefore, the map adjustment module 860 will adjust the corresponding pixel block in the parameter map according to the absolute difference and SAD. parameter value. For example, the map adjustment module 860 can use the following code (3) to generate the adjusted parameter map allin_map:

if(SAD>TH_SAD)if(SAD>TH_SAD)

Fac=LUT[SAD];Fac=LUT[SAD];

allin_map=map×Facallin_map=map×Fac

elseelse

allin_map=mapallin_map=map

(3) (3)

其中,Fac代表地图调整模块8620用以调整参数地图map的权重因子。由此可知,当绝对差值和SAD大于移动临界值TH_SAD,地图调整模块860依据绝对差值和SAD决定各参数值的权重因子Fac,并利用权重因子Fac调整参数地图map中的参数值。其中,权重因子Fac随着绝对差值和SAD的增加而下降。Wherein, Fac represents the weight factor used by the map adjustment module 8620 to adjust the parameter map. It can be seen that when the absolute difference and SAD are greater than the movement threshold TH_SAD, the map adjustment module 860 determines the weighting factor Fac of each parameter value according to the absolute difference and SAD, and adjusts the parameter value in the parameter map by using the weighting factor Fac. Among them, the weight factor Fac decreases with the increase of absolute difference and SAD.

图9B绘示为依照本发明再一实施例的绝对差值和与权重因子的关系示意图。如图9B所示,当绝对差值和SAD大于移动临界值TH_SAD,地图调整模块860依据绝对差值和SAD决定各参数值的权重因子,并利用权重因子调整参数值。权重因子随着绝对差值和SAD的增加而下降,也就是说,各参数值随着对应的绝对差值和SAD的上升而下降。FIG. 9B is a schematic diagram illustrating the relationship between the absolute difference sum and the weighting factor according to yet another embodiment of the present invention. As shown in FIG. 9B , when the absolute difference and SAD are greater than the movement threshold TH_SAD, the map adjustment module 860 determines the weighting factor of each parameter value according to the absolute difference and SAD, and adjusts the parameter value by using the weighting factor. The weighting factor decreases as the absolute difference and SAD increase, that is, each parameter value decreases as the corresponding absolute difference and SAD increase.

之后,图像合成模块850可以依据调整后的参数地图allin_map,混合第一图像Img1以及经过位移校正的第二图像Img2_cal,以产生不具有鬼影现象的全景深图像Img_AIF。其中,图像合成模块860依据调整后的参数地图allin_map来产生全景深图像的步骤,与图像合成模块460依据散景地图bokeh_map来产生散景图像的步骤相似,请参照图7的相关说明类推之,不再赘述。举例来说,图像合成模块860也可通过程式码(4)而取得最终的全景深图像Img_AIF。Afterwards, the image synthesis module 850 can mix the first image Img1 and the displacement-corrected second image Img2_cal according to the adjusted parameter map allin_map, so as to generate the full depth image Img_AIF without ghosting. Wherein, the step of the image synthesis module 860 to generate the panoramic depth image according to the adjusted parameter map allin_map is similar to the step of the image synthesis module 460 to generate the bokeh image according to the bokeh map bokeh_map, please refer to the relevant description in FIG. 7 and so on. No longer. For example, the image synthesis module 860 can also obtain the final full depth image Img_AIF through the program code (4).

if(Map≥Blend_TH1)//In-of-focus area of image2if(Map≥Blend_TH1)//In-of-focus area of image2

Img1_AIF=Img2Img1_AIF=Img2

else if(Map≥Blend_TH2)//Transition areaelse if(Map≥Blend_TH2)//Transition area

wAIF=LUT[Map](LUT is table and value range is0~255)w AIF =LUT[Map](LUT is table and value range is0~255)

ImgImg 11 __ AIFAIF == ww AIFAIF ×× ImgImg 11 ++ (( 256256 -- ww AIFAIF )) ×× ImgImg 22 256256

else//In-of-focus area of image1else//In-of-focus area of image1

Img1_AIF=Img1Img1_AIF=Img1

(4) (4)

其中,在此示范性程式码(4)中,假设参数值介于0与255之间,Blend_TH1为第一混合临界值,Blend_TH2为第二混合临界值,Map为调整后参数地图allin_map中的多个参数值,LUT[]为查表函式。值得一提的是,边缘区域的像素点可通过权重的概念来计算取得。如上述示范性程式码中的公式所示,将参数值作为合成权重wAIF,并通过合成权重wAIF来合成出边缘区域的像素点。Wherein, in this exemplary program code (4), it is assumed that the parameter value is between 0 and 255, Blend_TH1 is the first blending threshold value, Blend_TH2 is the second blending threshold value, and Map is the multiple in the adjusted parameter map allin_map parameter value, LUT[] is the look-up table function. It is worth mentioning that the pixels in the edge area can be calculated by the concept of weight. As shown in the formula in the above exemplary code, the parameter value is used as the synthesis weight w AIF , and the pixels in the edge area are synthesized by the synthesis weight w AIF .

同样的,经由图3的说明可知,本发明的图像处理方法可以通过多张图像来获得最后的输出图像。基此,在本实施例中,图像获取装置800可以利用多种不同的焦距而获取多张图像,并利用多张焦距不同的图像来合成清晰的全景深图像。就实际的应用情况而言,可先针对场景进行分析,以进一步判断出需要多少张不同焦距的图像来合成出整张图像都清晰的全景深图像。Similarly, it can be seen from the description of FIG. 3 that the image processing method of the present invention can obtain a final output image through multiple images. Based on this, in this embodiment, the image acquisition device 800 can acquire multiple images with different focal lengths, and use the multiple images with different focal lengths to synthesize a clear full depth image. As far as the actual application situation is concerned, the scene can be analyzed first to further determine how many images with different focal lengths are needed to synthesize a full depth of view image with clear images.

综上所述,本发明所提供的图像获取装置及其图像处理方法,通过利用至少两张焦距不同的图像来计算出用合成的参数地图,并依据参数地图来合成出主体清晰图像或全景深图像。其中,本发明所提供的图像处理方法可让一个以上的主体目标能够清晰且背景模糊,以凸显图像中一个以上的主体目标。除此之外,通过本发明可使图像中被摄主体与背景之间的连接边缘柔和且自然,达到散景效果良好又自然的图像。另一方面,本发明还可通过利用获取自不同对焦距离的多张图像,来建立图像中每个地方都清楚对焦的全景深图像。另外,而在建立全景深图像时,亦能将图像中的杂讯一并消除,确保所建立的全景深图像不会丧失图像中的细节。To sum up, the image acquisition device and image processing method provided by the present invention calculates a synthesized parameter map by using at least two images with different focal lengths, and synthesizes a clear subject image or panoramic depth based on the parameter map. image. Wherein, the image processing method provided by the present invention can make more than one main object clear and the background blurred, so as to highlight more than one main object in the image. In addition, through the present invention, the connection edge between the subject and the background in the image can be made soft and natural, and an image with good and natural bokeh effect can be achieved. On the other hand, the present invention can also use multiple images obtained from different focusing distances to create a full depth image in which every place in the image is clearly in focus. In addition, when the full depth image is created, the noise in the image can also be eliminated to ensure that the created full depth image will not lose details in the image.

最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present invention, rather than limiting them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: It is still possible to modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the technical solutions of the various embodiments of the present invention. scope.

Claims (16)

1. an image processing method, is applicable to image acquiring device, it is characterized in that, this image processing method comprises:
Obtain the first image with the first focal length, and obtain the second image with the second focal length, wherein this first focal length is focused at least one main body;
This second image is carried out to geometric correction program, produce this second image after displacement correction;
Each pixel of this image is carried out to gradient computing to produce multiple the first Grad, and each pixel of this second image after displacement correction is carried out to this gradient computing to produce multiple the second Grad;
Respectively this first Grad, with corresponding respectively this second Grad to produce multiple the first pixel comparative results, and produces the first parameter map according to those the first pixel comparative results; And
Produce composograph according to this first parameter map and this first image, and at least produce output image according to this composograph.
2. image processing method according to claim 1, is characterized in that, the step that at least produces this output image according to this composograph comprises:
Obtain the 3rd image with the 3rd focal length;
The 3rd image is carried out to this geometric correction program, produce the 3rd image after displacement correction;
Each pixel of this composograph is carried out to this gradient computing to produce multiple the 3rd Grad, and each pixel of the 3rd image after displacement correction is carried out to this gradient computing to produce multiple the 4th Grad;
Respectively the 3rd Grad, with corresponding respectively the 4th Grad to produce multiple the second pixel comparative results, and produces the second parameter map according to those the second pixel comparative results; And
According to this second parameter map, the 3rd image and this composograph that mix after displacement correction produce this output image.
3. image processing method according to claim 1, is characterized in that, this second image is carried out to this geometric correction program, and the step that produces this second image after displacement correction comprises:
This first image and this second image are carried out to amount of movement estimation, use calculating homography matrix; And
According to this homography matrix, this second image is carried out to the affine conversion of geometry, to obtain this second image after displacement correction.
4. image processing method according to claim 1, it is characterized in that, respectively this first Grad is with corresponding respectively this second Grad to produce those the first pixel comparative results, and the step that produces this parameter map according to those the first pixel comparative results comprises:
Those second Grad, divided by those corresponding first Grad, are produced to multiple gradient comparison values; And
Produce multiple parameter values according to those gradient comparison values, and those parameter values are recorded as to this parameter map.
5. image processing method according to claim 4, is characterized in that, the step that produces those parameter values according to those gradient comparison values comprises:
Judge whether those gradient comparison values are greater than the first gradient critical value; And
If those gradient comparison values are greater than this first gradient critical value, setting corresponding those parameter values of those gradient comparison values is the first numerical value.
6. image processing method according to claim 5, is characterized in that, the step that produces those parameter values according to those gradient comparison values comprises:
Be greater than this first gradient critical value if those gradient comparison values there is no, judge whether those gradient comparison values are greater than the second gradient critical value;
If those gradient comparison values are greater than this second gradient critical value, setting corresponding those parameter values of those gradient comparison values is second value; And
Be greater than this second gradient critical value if those gradient comparison values there is no, set corresponding those parameter values of those gradient comparison values and be set as third value,
Wherein, this first gradient critical value is greater than this second gradient critical value.
7. image processing method according to claim 4, is characterized in that, the step that at least produces this composograph according to this first parameter map and this first image comprises:
This first image is carried out to obfuscation program, produce blurred picture; And
Mix this first image and this blurred picture to produce main body picture rich in detail according to this first Reference Map.
8. image processing method according to claim 7, is characterized in that, mixes this first image and this blurred picture comprises with the step that produces this main body picture rich in detail according to this first Reference Map:
Judge whether those parameter values are greater than the first mixing critical value;
If those parameter values are greater than this first mixing critical value, get the pixel of corresponding this blurred picture of those parameter values as the pixel of this main body picture rich in detail;
Be greater than this first mixing critical value if those parameter values there is no, judge whether those parameter values are greater than the second mixing critical value;
If those parameter values are greater than this second mixing critical value, go out the pixel of this corresponding main body picture rich in detail according to those parameter value calculation; And
Be greater than this second mixing critical value if those parameter values there is no, get the pixel of corresponding this first image of those parameter values as the pixel of this main body picture rich in detail, wherein, this first mixing critical value is greater than this second mixing critical value.
9. image processing method according to claim 4, is characterized in that, the step that at least produces this composograph according to this first parameter map and this first image comprises:
According to the calculated for pixel values of each pixel in this first image and this second image go out the corresponding multiple absolute differences of each pixel and, and according to those absolute differences with adjust those parameter values in this first parameter map; And
According to this first Reference Map after adjusting, mix this second image after this first image and displacement correction to produce full depth image.
10. image processing method according to claim 9, it is characterized in that, according to the calculated for pixel values of each pixel in this first image and this second image go out corresponding those absolute differences of each pixel and, and comprise according to those absolute differences and the step of adjusting those parameter values in this first parameter map:
When those absolute differences be greater than mobile critical value, according to those absolute differences with determine the respectively weight factor of this parameter value, and utilize this weight factor to adjust those parameter values, wherein respectively this parameter value along with this absolute difference of correspondence and rising and decline.
11. image processing methods according to claim 9, is characterized in that, according to this first Reference Map after adjusting via those weight factors, this second image mixing after this first image and displacement correction comprises with the step that produces this full depth image:
Judge whether those parameter values are greater than the first mixing critical value;
If those parameter values are greater than this first mixing critical value, get the pixel of this second image after the corresponding displacement correction of those parameter values as the pixel of this full depth image;
Be greater than this first mixing critical value if those parameter values there is no, judge whether those parameter values are greater than the second mixing critical value;
If those parameter values are greater than this second mixing critical value, go out the pixel of this corresponding full depth image according to those parameter value calculation; And
Be greater than this second mixing critical value if those parameter values there is no, get the pixel of corresponding this first image of those parameter values as the pixel of this full depth image, wherein, this first mixing critical value is greater than this second mixing critical value.
12. 1 kinds of image acquiring devices, is characterized in that, comprising:
Image collection module, obtains the first image with the first focal length, and obtains the second image with the second focal length, and wherein this first focal length is focused at least one main body;
Image correction module, carries out geometric correction program to this second image, produces this second image after displacement correction;
Gradient calculation module, carries out a gradient computing to produce multiple the first Grad to each pixel of this first image, and each pixel of this second image after displacement correction is carried out to this gradient computing to produce multiple the second Grad;
Map generation module, respectively this first Grad, with corresponding respectively this second Grad to produce multiple the first pixel comparative results, and produces the first parameter map according to those the first pixel comparative results; And
Image synthesis unit, produces composograph according to this first parameter map and this first image, and at least produces output image according to this composograph.
13. image acquiring devices according to claim 11, it is characterized in that, this image collection module is obtained the 3rd image with the 3rd focal length, this image correction module is carried out this geometric correction program and produces the 3rd image after displacement correction the 3rd image, this gradient calculation module is carried out this gradient computing to produce multiple the 3rd Grad to each pixel of this composograph, each pixel of three image of this gradient calculation module after to displacement correction is carried out this gradient computing to produce multiple the 4th Grad, this map generation module respectively the 3rd Grad with corresponding respectively the 4th Grad to produce multiple the second pixel comparative results, this map generation module also produces the second parameter map according to those the second pixel comparative results, three image of this image synthesis unit after according to this second parameter map mixing displacement correction and this composograph and produce this output image.
14. image acquiring devices according to claim 11, wherein this map generation module by those second Grad divided by those corresponding first Grad, to produce multiple gradient comparison values, and produce multiple parameter values according to those gradient comparison values, and those parameter values are recorded as to this parameter map.
15. image acquiring devices according to claim 11, it is characterized in that, also comprise image blurring module, module that this is image blurring is carried out an obfuscation program and is produced blurred picture this first image, and this image synthesis unit is mixed this first image and this blurred picture to produce main body picture rich in detail according to this first Reference Map.
16. image acquiring devices according to claim 11, it is characterized in that, also comprise map adjusting module, this map adjusting module according to the calculated for pixel values of each pixel in this first image and this second image go out the corresponding multiple absolute differences of each pixel and, this map adjusting module according to those absolute differences with adjust those parameter values in this first parameter map, this image synthesis unit is mixed this second image after this first image and displacement correction to produce full depth image according to this first Reference Map after adjusting.
CN201310260044.3A 2013-02-06 2013-06-26 Image acquisition device and image processing method thereof Active CN103973963B (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
TW102104649 2013-02-06
TW102104649 2013-02-06

Publications (2)

Publication Number Publication Date
CN103973963A true CN103973963A (en) 2014-08-06
CN103973963B CN103973963B (en) 2017-11-21

Family

ID=51242964

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310260044.3A Active CN103973963B (en) 2013-02-06 2013-06-26 Image acquisition device and image processing method thereof

Country Status (1)

Country Link
CN (1) CN103973963B (en)

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104333703A (en) * 2014-11-28 2015-02-04 广东欧珀移动通信有限公司 Method and terminal for taking pictures with dual cameras
CN105933602A (en) * 2016-05-16 2016-09-07 中科创达软件科技(深圳)有限公司 Camera shooting method and device
CN106161997A (en) * 2016-06-30 2016-11-23 上海华力微电子有限公司 Improve the method and system of cmos image sensor pixel
CN106303202A (en) * 2015-06-09 2017-01-04 联想(北京)有限公司 A kind of image information processing method and device
CN108112271A (en) * 2016-01-29 2018-06-01 谷歌有限责任公司 Movement in detection image
CN108377342A (en) * 2018-05-22 2018-08-07 Oppo广东移动通信有限公司 Double-camera shooting method and device, storage medium and terminal
CN105491278B (en) * 2014-10-09 2018-09-25 聚晶半导体股份有限公司 Image acquisition device and digital zoom display method
CN109816619A (en) * 2019-01-28 2019-05-28 努比亚技术有限公司 Image interfusion method, device, terminal and computer readable storage medium
CN111614898A (en) * 2016-10-05 2020-09-01 三星电子株式会社 image processing system
WO2021017589A1 (en) * 2019-07-31 2021-02-04 茂莱(南京)仪器有限公司 Image fusion method based on gradient domain mapping
WO2021120120A1 (en) * 2019-12-19 2021-06-24 Guangdong Oppo Mobile Telecommunications Corp., Ltd. Electric device, method of controlling electric device, and computer readable storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1392724A (en) * 2001-06-19 2003-01-22 卡西欧计算机株式会社 Image pick-up device and method, storage medium for recording image pick-up method program
JP2008278763A (en) * 2007-05-08 2008-11-20 Japan Health Science Foundation Transgenic non-human animals
US7538815B1 (en) * 2002-01-23 2009-05-26 Marena Systems Corporation Autofocus system and method using focus measure gradient
CN101447079A (en) * 2008-12-11 2009-06-03 香港理工大学 Image area target extraction method based on fuzzy topology
CN101852970A (en) * 2010-05-05 2010-10-06 浙江大学 A camera auto-focus method for imaging field of view scanning
CN101968883A (en) * 2010-10-28 2011-02-09 西北工业大学 Method for fusing multi-focus images based on wavelet transform and neighborhood characteristics
CN102682435A (en) * 2012-05-14 2012-09-19 四川大学 Multi-focus image edge detection method based on space relative altitude information
CN102867297A (en) * 2012-08-31 2013-01-09 天津大学 Digital processing method for low-illumination image acquisition

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1392724A (en) * 2001-06-19 2003-01-22 卡西欧计算机株式会社 Image pick-up device and method, storage medium for recording image pick-up method program
US7538815B1 (en) * 2002-01-23 2009-05-26 Marena Systems Corporation Autofocus system and method using focus measure gradient
JP2008278763A (en) * 2007-05-08 2008-11-20 Japan Health Science Foundation Transgenic non-human animals
CN101447079A (en) * 2008-12-11 2009-06-03 香港理工大学 Image area target extraction method based on fuzzy topology
CN101852970A (en) * 2010-05-05 2010-10-06 浙江大学 A camera auto-focus method for imaging field of view scanning
CN101968883A (en) * 2010-10-28 2011-02-09 西北工业大学 Method for fusing multi-focus images based on wavelet transform and neighborhood characteristics
CN102682435A (en) * 2012-05-14 2012-09-19 四川大学 Multi-focus image edge detection method based on space relative altitude information
CN102867297A (en) * 2012-08-31 2013-01-09 天津大学 Digital processing method for low-illumination image acquisition

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105491278B (en) * 2014-10-09 2018-09-25 聚晶半导体股份有限公司 Image acquisition device and digital zoom display method
CN104333703A (en) * 2014-11-28 2015-02-04 广东欧珀移动通信有限公司 Method and terminal for taking pictures with dual cameras
CN106303202A (en) * 2015-06-09 2017-01-04 联想(北京)有限公司 A kind of image information processing method and device
CN108112271A (en) * 2016-01-29 2018-06-01 谷歌有限责任公司 Movement in detection image
US11625840B2 (en) 2016-01-29 2023-04-11 Google Llc Detecting motion in images
CN108112271B (en) * 2016-01-29 2022-06-24 谷歌有限责任公司 Method and computer readable device for detecting motion in an image
CN105933602A (en) * 2016-05-16 2016-09-07 中科创达软件科技(深圳)有限公司 Camera shooting method and device
CN106161997A (en) * 2016-06-30 2016-11-23 上海华力微电子有限公司 Improve the method and system of cmos image sensor pixel
CN111614898A (en) * 2016-10-05 2020-09-01 三星电子株式会社 image processing system
US11962906B2 (en) 2016-10-05 2024-04-16 Samsung Electronics Co., Ltd. Image processing systems for correcting processed images using image sensors
CN108377342A (en) * 2018-05-22 2018-08-07 Oppo广东移动通信有限公司 Double-camera shooting method and device, storage medium and terminal
CN109816619A (en) * 2019-01-28 2019-05-28 努比亚技术有限公司 Image interfusion method, device, terminal and computer readable storage medium
WO2021017589A1 (en) * 2019-07-31 2021-02-04 茂莱(南京)仪器有限公司 Image fusion method based on gradient domain mapping
WO2021120120A1 (en) * 2019-12-19 2021-06-24 Guangdong Oppo Mobile Telecommunications Corp., Ltd. Electric device, method of controlling electric device, and computer readable storage medium
CN114902646A (en) * 2019-12-19 2022-08-12 Oppo广东移动通信有限公司 Electronic device, method of controlling electronic device, and computer-readable storage medium
CN114902646B (en) * 2019-12-19 2024-04-19 Oppo广东移动通信有限公司 Electronic device, method for controlling electronic device, and computer-readable storage medium

Also Published As

Publication number Publication date
CN103973963B (en) 2017-11-21

Similar Documents

Publication Publication Date Title
TWI602152B (en) Image capturing device and image processing method thereof
CN103973963B (en) Image acquisition device and image processing method thereof
US8189960B2 (en) Image processing apparatus, image processing method, program and recording medium
US9558543B2 (en) Image fusion method and image processing apparatus
US11184553B1 (en) Image signal processing in multi-camera system
JP6308748B2 (en) Image processing apparatus, imaging apparatus, and image processing method
JP2008294785A (en) Image processor, imaging apparatus, image file, and image processing method
CN110324532A (en) Image blurring method and device, storage medium and electronic equipment
JP6270413B2 (en) Image processing apparatus, imaging apparatus, and image processing method
CN108154514A (en) Image processing method, device and equipment
JP6797955B2 (en) Image processing device and control method of image processing device, imaging device, program
WO2020029679A1 (en) Control method and apparatus, imaging device, electronic device and readable storage medium
CN106612392A (en) Image shooting method and device based on double cameras
CN108810326B (en) A photographing method, device and mobile terminal
JP2017143354A (en) Image processing apparatus and image processing method
CN109257540A (en) Take the photograph photography bearing calibration and the camera of lens group more
CN103973962B (en) Image processing method and image acquisition device
JP5843599B2 (en) Image processing apparatus, imaging apparatus, and method thereof
CN111698389A (en) Image processing apparatus, image capturing apparatus, image processing method, and storage medium
CN109447925B (en) Image processing method and device, storage medium, electronic device
JP2016167234A (en) Image processing apparatus, image processing method, and program
JP6025555B2 (en) Image processing apparatus, image processing method, and program
JP2015118274A (en) Imaging device, imaging device control method, and program
TWI465108B (en) Image capturing apparatus and image processing method
JP7409604B2 (en) Image processing device, imaging device, image processing method, program and recording medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant