CN113709365B - Image processing method, device, electronic equipment and storage medium - Google Patents
Image processing method, device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN113709365B CN113709365B CN202110962242.9A CN202110962242A CN113709365B CN 113709365 B CN113709365 B CN 113709365B CN 202110962242 A CN202110962242 A CN 202110962242A CN 113709365 B CN113709365 B CN 113709365B
- Authority
- CN
- China
- Prior art keywords
- pixel
- image
- diffusion
- background area
- weight
- 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.)
- Active
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 18
- 238000009792 diffusion process Methods 0.000 claims abstract description 250
- 238000012545 processing Methods 0.000 claims abstract description 70
- 238000000034 method Methods 0.000 claims abstract description 62
- 230000000875 corresponding effect Effects 0.000 claims description 249
- 238000013507 mapping Methods 0.000 claims description 44
- 230000002596 correlated effect Effects 0.000 claims description 18
- 238000004590 computer program Methods 0.000 claims description 14
- 238000004364 calculation method Methods 0.000 claims description 3
- 230000000694 effects Effects 0.000 abstract description 39
- 238000003384 imaging method Methods 0.000 description 16
- 238000010586 diagram Methods 0.000 description 11
- 238000007781 pre-processing Methods 0.000 description 10
- 230000008569 process Effects 0.000 description 7
- 230000003628 erosive effect Effects 0.000 description 6
- 230000009467 reduction Effects 0.000 description 6
- 241000023320 Luma <angiosperm> Species 0.000 description 5
- 230000009286 beneficial effect Effects 0.000 description 5
- OSWPMRLSEDHDFF-UHFFFAOYSA-N methyl salicylate Chemical compound COC(=O)C1=CC=CC=C1O OSWPMRLSEDHDFF-UHFFFAOYSA-N 0.000 description 5
- 230000007704 transition Effects 0.000 description 4
- 239000003086 colorant Substances 0.000 description 3
- 238000013135 deep learning Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- NAWXUBYGYWOOIX-SFHVURJKSA-N (2s)-2-[[4-[2-(2,4-diaminoquinazolin-6-yl)ethyl]benzoyl]amino]-4-methylidenepentanedioic acid Chemical compound C1=CC2=NC(N)=NC(N)=C2C=C1CCC1=CC=C(C(=O)N[C@@H](CC(=C)C(O)=O)C(O)=O)C=C1 NAWXUBYGYWOOIX-SFHVURJKSA-N 0.000 description 2
- 238000003705 background correction Methods 0.000 description 2
- 230000000740 bleeding effect Effects 0.000 description 2
- 238000012937 correction Methods 0.000 description 2
- 238000001514 detection method Methods 0.000 description 2
- 238000013467 fragmentation Methods 0.000 description 2
- 238000006062 fragmentation reaction Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000009877 rendering Methods 0.000 description 2
- 230000035945 sensitivity Effects 0.000 description 2
- 230000001629 suppression Effects 0.000 description 2
- 101000859864 Rattus norvegicus Gamma-crystallin E Proteins 0.000 description 1
- 206010039729 Scotoma Diseases 0.000 description 1
- 238000009825 accumulation Methods 0.000 description 1
- 238000013459 approach Methods 0.000 description 1
- 239000000872 buffer Substances 0.000 description 1
- 230000000994 depressogenic effect Effects 0.000 description 1
- 230000000916 dilatatory effect Effects 0.000 description 1
- 238000006073 displacement reaction Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 125000001475 halogen functional group Chemical group 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 230000001788 irregular Effects 0.000 description 1
- 238000010801 machine learning Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000011218 segmentation Effects 0.000 description 1
- 230000002123 temporal effect Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N23/00—Cameras or camera modules comprising electronic image sensors; Control thereof
- H04N23/95—Computational photography systems, e.g. light-field imaging systems
- H04N23/951—Computational photography systems, e.g. light-field imaging systems by using two or more images to influence resolution, frame rate or aspect ratio
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N5/00—Details of television systems
- H04N5/222—Studio circuitry; Studio devices; Studio equipment
- H04N5/262—Studio circuits, e.g. for mixing, switching-over, change of character of image, other special effects ; Cameras specially adapted for the electronic generation of special effects
- H04N5/2621—Cameras specially adapted for the electronic generation of special effects during image pickup, e.g. digital cameras, camcorders, video cameras having integrated special effects capability
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N5/00—Details of television systems
- H04N5/222—Studio circuitry; Studio devices; Studio equipment
- H04N5/262—Studio circuits, e.g. for mixing, switching-over, change of character of image, other special effects ; Cameras specially adapted for the electronic generation of special effects
- H04N5/272—Means for inserting a foreground image in a background image, i.e. inlay, outlay
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Computing Systems (AREA)
- Theoretical Computer Science (AREA)
- Image Processing (AREA)
Abstract
Description
技术领域technical field
本申请涉及影像技术领域,具体涉及一种图像处理方法、装置、电子设备及存储介质。The present application relates to the field of image technology, and in particular to an image processing method, device, electronic equipment, and storage medium.
背景技术Background technique
目前,大部分的图像虚化效果是基于高斯模糊和光斑贴图实现。其中,光斑贴图可主要对图像中亮度较高的光源进行虚化。然而,在实践中发现,虽然高斯模糊和光斑贴图都可以达到虚化效果,但是两者之间相互割裂,导致图像整体的虚化效果不自然、不真实。Currently, most image blur effects are based on Gaussian blur and spot maps. Among them, the spot map can mainly blur the light source with higher brightness in the image. However, in practice, it is found that although both Gaussian blur and spot map can achieve a blur effect, the two are separated from each other, resulting in an unnatural and unreal overall blur effect of the image.
发明内容Contents of the invention
本申请实施例公开了一种图像处理方法、装置、电子设备及存储介质,能够提供自然真实的图像虚化效果。The embodiment of the present application discloses an image processing method, device, electronic equipment, and storage medium, which can provide a natural and real image blurring effect.
本申请实施例公开一种图像处理方法,所述方法包括:获取光圈形状参数,以及获取第一图像对应的虚化力度图及权重图,所述虚化力度图至少包括所述第一图像的背景区域中各个第一像素点分别对应的虚化半径,所述权重图至少包括所述第一图像的背景区域中各个第一像素点分别对应的扩散权重;根据所述光圈形状参数、所述虚化力度图及权重图,对所述第一图像的背景区域中的各个第一像素点进行点扩散处理,得到各个第一像素点对应的扩散结果;对所述背景区域中各个第一像素点对应的扩散结果进行叠加,并根据叠加结果对所述背景区域进行虚化。The embodiment of the present application discloses an image processing method. The method includes: obtaining the shape parameter of the aperture, and obtaining a blurring intensity map and a weighting map corresponding to the first image, and the blurring intensity map includes at least the blurring intensity map of the first image. Blur radii corresponding to each first pixel in the background area, the weight map at least includes diffusion weights corresponding to each first pixel in the background area of the first image; according to the aperture shape parameter, the Blur intensity map and weight map, performing point diffusion processing on each first pixel in the background area of the first image to obtain a diffusion result corresponding to each first pixel; for each first pixel in the background area The diffusion results corresponding to the points are superimposed, and the background area is blurred according to the superposition results.
本申请实施例公开一种图像处理装置,包括:取模块,用于获取光圈形状参数,以及获取第一图像对应的虚化力度图及权重图,所述虚化力度图至少包括所述第一图像的背景区域中各个第一像素点分别对应的虚化半径,所述权重图至少包括所述第一图像的背景区域中各个第一像素点分别对应的扩散权重;扩散模块,用于根据所述光圈形状参数、所述虚化力度图及权重图,对所述第一图像的背景区域中的各个第一像素点进行点扩散处理,得到各个第一像素点对应的扩散结果;叠加虚化模块,用于对所述背景区域中各个第一像素点对应的扩散结果进行叠加,并根据叠加结果对所述背景区域进行虚化。The embodiment of the present application discloses an image processing device, including: an acquisition module for obtaining aperture shape parameters, and obtaining a blurring strength map and a weight map corresponding to the first image, and the blurring strength map includes at least the first Blur radii corresponding to each first pixel in the background area of the image, the weight map at least includes diffusion weights corresponding to each first pixel in the background area of the first image; the diffusion module is configured to The shape parameters of the aperture, the blurring intensity map and the weight map are used to perform point diffusion processing on each first pixel point in the background area of the first image to obtain a diffusion result corresponding to each first pixel point; superimposing blurring A module, configured to superimpose the diffusion results corresponding to each first pixel in the background area, and blur the background area according to the superposition results.
本申请实施例公开一种电子设备,包括存储器及处理器,所述存储器中存储有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器执行本申请实施例公开的任意一种图像处理方法。The embodiment of the present application discloses an electronic device, including a memory and a processor. The memory stores a computer program. When the computer program is executed by the processor, the processor executes any of the methods disclosed in the embodiment of the present application. An image processing method.
本申请实施例公开一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现本申请实施例公开的任意一种图像处理方法。The embodiment of the present application discloses a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, any image processing method disclosed in the embodiment of the present application is implemented.
与相关技术相比,本申请实施例具有以下有益效果:Compared with related technologies, the embodiments of the present application have the following beneficial effects:
电子设备可获取光圈形状参数,以及获取第一图像对应的虚化力度图及权重图。虚化力度图至少包括所述第一图像的背景区域中各个第一像素点分别对应的虚化半径,所述权重图至少包括所述第一图像的背景区域中各个第一像素点分别对应的扩散权重。The electronic device can obtain the shape parameter of the aperture, and obtain the blur strength map and the weight map corresponding to the first image. The blur strength map at least includes blur radii corresponding to the respective first pixels in the background area of the first image, and the weight map includes at least the blur radii corresponding to the respective first pixels in the background area of the first image. Diffusion weights.
电子设备可进一步根据所述光圈形状参数、所述虚化力度图及权重图,对所述第一图像的背景区域中的各个第一像素点进行点扩散处理,得到各个第一像素点对应的扩散结果,并且对扩散结果进行叠加,以根据叠加结果对所述背景区域进行虚化,从而可以通过点扩散处理模拟真实的镜头模糊,解决了高斯模糊和光斑贴图存在割裂的问题,使得图像整体的虚化效果和谐自然、融为一体,并且更能够模拟单反相机摄影的虚化自然、光斑明亮通透的效果,大大提升了虚化效果的质感。此外,电子设备可对背景区域中的每个第一像素点进行点扩散处理,无需进行光源点位置识别,从而可以避免光源点位置识别不准确而导致虚化效果下降的问题,有利于提供更加真实自然的虚化效果。The electronic device may further perform point diffusion processing on each of the first pixels in the background area of the first image according to the aperture shape parameter, the blurring intensity map, and the weight map, to obtain a pixel corresponding to each first pixel. Diffusion results, and superimpose the diffusion results to blur the background area according to the superposition results, so that the real lens blur can be simulated through point diffusion processing, which solves the problem of Gaussian blur and fragmentation of the spot map, making the image as a whole The bokeh effect is harmonious and natural, and it can simulate the natural bokeh and bright and transparent effect of SLR camera photography, which greatly improves the texture of the bokeh effect. In addition, the electronic device can perform point diffusion processing on each first pixel point in the background area without identifying the position of the light source point, thereby avoiding the problem of inaccurate recognition of the position of the light source point and resulting in a decrease in the blur effect, which is conducive to providing more Realistic and natural bokeh effect.
附图说明Description of drawings
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the accompanying drawings that need to be used in the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For Those of ordinary skill in the art can also obtain other drawings based on these drawings without making creative efforts.
图1是一个实施例公开的一种图像处理电路的结构示意图;Fig. 1 is a schematic structural diagram of an image processing circuit disclosed in an embodiment;
图2是一个实施例公开的一种图像处理方法的方法流程示意图;Fig. 2 is a method flow diagram of an image processing method disclosed in an embodiment;
图3是一个实施例公开的一种对两个相邻的第一像素点对应的扩散结果进行叠加的示例图;Fig. 3 is an example diagram of superimposing diffusion results corresponding to two adjacent first pixel points disclosed by an embodiment;
图4是一个实施例中公开的另一种图像处理方法的流程示意图;Fig. 4 is a schematic flow chart of another image processing method disclosed in an embodiment;
图5是一个实施例公开的一种生成背景掩膜的方法流程示意图;Fig. 5 is a schematic flowchart of a method for generating a background mask disclosed by an embodiment;
图6是一个实施例公开的一种对背景区域进行亮度压暗的方法流程示意图;Fig. 6 is a schematic flowchart of a method for darkening the brightness of the background area disclosed by an embodiment;
图7是一个实施例公开的一种对高光区域进行色彩增强的方法流程示意图;Fig. 7 is a schematic flowchart of a method for color enhancement of a highlight area disclosed by an embodiment;
图8是一个实施例公开的一种获取亮度权重图的方法流程示意图;Fig. 8 is a schematic flowchart of a method for obtaining a brightness weight map disclosed by an embodiment;
图9是一个实施例公开的一种获取色度权重图的方法流程示意图;Fig. 9 is a schematic flowchart of a method for obtaining a chromaticity weight map disclosed by an embodiment;
图10是一个实施例公开的一种第一曲线、第二曲线和权重映射曲线的示例图;Fig. 10 is an example diagram of a first curve, a second curve and a weight mapping curve disclosed by an embodiment;
图11是一个实施例公开的一种图像处理方法的流程示意图;Fig. 11 is a schematic flowchart of an image processing method disclosed in an embodiment;
图12是一个实施例公开的一种图像处理装置的结构示意图;Fig. 12 is a schematic structural diagram of an image processing device disclosed in an embodiment;
图13是本申请实施例公开的一种电子设备的结构示意图。FIG. 13 is a schematic structural diagram of an electronic device disclosed in an embodiment of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the application with reference to the drawings in the embodiments of the application. Apparently, the described embodiments are only some, not all, embodiments of the application. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the scope of protection of this application.
需要说明的是,本申请实施例及附图中的术语“包括”和“具有”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "comprising" and "having" and any variations thereof in the embodiments of the present application and the drawings are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes unlisted steps or units, or optionally further includes For other steps or units inherent in these processes, methods, products or apparatuses.
在相关技术中,图像虚化效果可以基于高斯模糊和光斑贴图实现。其中,高斯模糊一般是基于gather方式的卷积,而光斑贴图是基于spread方式的像素积累。因此,两者之间相互割裂,导致高斯模糊和光斑贴图分别达到的虚化效果很难融一体。此外,高斯模糊是模拟镜头模糊,实际上与真实的镜头模糊之间存在差距。光斑贴图则依赖于光源点识别,需要先在图像中识别出光源点的位置,再对光源点位置进行虚化。然而,若光源点位置识别不准确,则会导致对图像中光斑的虚化效果大打折扣,与真实的镜头模糊之间存在较大差距。综上所述,相关技术中的图像虚化效果存在不自然、不真实的问题。In related technologies, the image blurring effect can be realized based on Gaussian blur and light spot map. Among them, Gaussian blur is generally based on the convolution of the gather method, while the spot map is based on the pixel accumulation of the spread method. Therefore, the two are separated from each other, making it difficult to integrate the virtual effect achieved by Gaussian blur and spot map respectively. Also, Gaussian Blur is simulated lens blur, there is actually a gap between it and real lens blur. The spot map relies on the recognition of the light source point. It is necessary to identify the position of the light source point in the image first, and then blur the position of the light source point. However, if the location of the light source point is not identified accurately, the effect of blurring the light spots in the image will be greatly reduced, and there will be a large gap between it and the real lens blur. To sum up, the image blurring effect in the related art has the problem of being unnatural and unreal.
本申请实施例公开了一种图像处理方法、装置、电子设备及存储介质,能够提供自然真实的图像虚化效果。以下分别进行详细说明。The embodiment of the present application discloses an image processing method, device, electronic equipment, and storage medium, which can provide a natural and real image blurring effect. Each will be described in detail below.
请参阅图1,图1是一个实施例公开的一种图像处理电路的结构示意图。该图像处理电路可应用于智能手机、智能平板、智能手表等电子设备,但不限于此。如图1所示,图像处理电路可包括成像设备(摄像头)110、姿态传感器120、图像存储器130、图像信号处理(Image Signal Processing,ISP)处理器140、逻辑控制器150以及显示器160。Please refer to FIG. 1 . FIG. 1 is a schematic structural diagram of an image processing circuit disclosed by an embodiment. The image processing circuit can be applied to electronic devices such as smart phones, smart tablets, and smart watches, but is not limited thereto. As shown in FIG. 1 , the image processing circuit may include an imaging device (camera) 110, an
图像处理电路包括ISP处理器140和控制逻辑器150。成像设备110捕捉的图像数据首先由ISP处理器140处理,ISP处理器140对图像数据进行分析以捕捉可用于确定成像设备110的一个或多个控制参数的图像统计信息。成像设备110可包括一个或多个透镜112和图像传感器114。图像传感器114可包括色彩滤镜阵列(如Bayer滤镜),图像传感器114可获取每个成像像素捕捉的光强度和波长信息,并提供可由ISP处理器140处理的一组原始图像数据(RAW图像数据)。姿态传感器120(如三轴陀螺仪、霍尔传感器、加速度计等)可基于姿态传感器120接口类型把采集的图像处理的参数(如防抖参数)提供给ISP处理器140。姿态传感器120接口可以采用SMIA(Standard Mobile Imaging Architecture,标准移动成像架构)接口、其它串行或并行摄像头接口或上述接口的组合。The image processing circuit includes an
此外,图像传感器114也可将原始图像数据发送给姿态传感器120,姿态传感器120可基于姿态传感器120接口类型把原始图像数据提供给ISP处理器140,或者姿态传感器120将原始图像数据存储到图像存储器130中。In addition, the
ISP处理器140按多种格式逐个像素地处理原始图像数据。例如,每个图像像素可具有8、10、12或14比特的位深度,ISP处理器140可对原始图像数据进行一个或多个图像处理操作、收集关于图像数据的统计信息。其中,图像处理操作可按相同或不同的位深度精度进行。The
ISP处理器140还可从图像存储器130接收图像数据。例如,姿态传感器120接口将原始图像数据发送给图像存储器130,图像存储器130中的原始图像数据再提供给ISP处理器140以供处理。图像存储器130可为存储器装置的一部分、存储设备、或电子设备内的独立的专用存储器,并可包括DMA(Direct Memory Access,直接直接存储器存取)特征。
当接收到来自图像传感器114接口或来自姿态传感器120接口或来自图像存储器130的原始图像数据时,ISP处理器140可进行一个或多个图像处理操作,如时域滤波。处理后的图像数据可发送给图像存储器130,以便在被显示之前进行另外的处理。ISP处理器140从图像存储器130接收处理数据,并对该处理数据进行原始域中以及YUV、RGB、YCbCr等一种或多种颜色空间中的图像数据处理。ISP处理器140处理后的图像数据可输出给显示器160,以供用户观看和/或由图形引擎或GPU(Graphics Processing Unit,图形处理器)进一步处理。此外,ISP处理器140的输出还可发送给图像存储器130,且显示器160可从图像存储器130读取图像数据。在一个实施例中,图像存储器130可被配置为实现一个或多个帧缓冲器。When receiving raw image data from the
ISP处理器140确定的统计数据可发送给控制逻辑器150。例如,统计数据可包括陀螺仪的振动频率、自动曝光、自动白平衡、自动聚焦、闪烁检测、黑电平补偿、透镜112阴影校正等图像传感器114统计信息。控制逻辑器150可包括执行一个或多个例程(如固件)的处理器和/或微控制器,一个或多个例程可根据接收的统计数据,确定成像设备110的控制参数及ISP处理器140的控制参数。例如,成像设备110的控制参数可包括姿态传感器120控制参数(例如增益、曝光控制的积分时间、防抖参数等)、照相机闪光控制参数、照相机防抖位移参数、透镜112控制参数(例如聚焦或变焦用焦距)或这些参数的组合。ISP控制参数可包括用于自动白平衡和颜色调整(例如,在YUV处理期间)的增益水平和色彩校正矩阵,以及透镜112阴影校正参数。Statistics determined by
在一个实施例中,成像设备110可拍摄第一图像,并将第一图像发送至ISP处理器140中,或者将第一图像存储到图像存储器130中。ISP处理器可获取第一图像,光圈形状以及第一图像对应的虚化力度图及权重图,虚化力度图可至少包括第一图像的背景区域中各个第一像素点分别对应的虚化半径,权重图可至少包括第一图像的背景区域中各个第一像素点分别对应的扩散权重。In one embodiment, the
ISP处理器140可根据获取到的光圈形状参数、虚化力度图及权重图,对第一图像的背景区域中的各个第一像素点进行点扩散处理,得到各个第一像素点对应的扩散结果。以及,ISP处理器140还可对背景区域中各个第一像素点对应的扩散结果进行叠加,并根据叠加结果对第一图像的背景区域进行虚化。The
在一些实施例中,ISP处理器140还可将对第一图像的背景区域进行虚化后得到的第二图像发送至显示器160,以通过显示器160显示第二图像。In some embodiments, the
请参阅图2,图2是一个实施例公开的一种图像处理方法的方法流程示意图,该方法可应用于前述的电子设备。如图2所示,该方法可包括以下步骤:Please refer to FIG. 2 . FIG. 2 is a schematic flowchart of an image processing method disclosed in an embodiment, and the method can be applied to the aforementioned electronic device. As shown in Figure 2, the method may include the following steps:
210、获取光圈形状参数、以及获取第一图像对应的虚化力度图及权重图。210. Acquire the shape parameters of the aperture, and acquire the blur strength map and weight map corresponding to the first image.
光圈形状参数可以由用户输入,可用于模拟不同镜头的光圈形状。例如,光圈形状参数模拟的光圈形状可包括:圆形、圆环、心形、星形、不规则图形等,但不限于此。The aperture shape parameter can be input by the user and can be used to simulate the aperture shape of different lenses. For example, the shape of the aperture simulated by the aperture shape parameter may include: circle, ring, heart, star, irregular figure, etc., but not limited thereto.
第一图像可以是电子设备的成像设备拍摄到的图像,也可以是电子设备从其它终端或者服务设备中获取到的图像,具体不做限定。第一图像可包括前景区域和背景区域,前景区域可指人像等拍摄主体在图像中占据的区域,背景区域可指第一图像中除前景区域以外的其它图像区域。以前景区域为人像区域为例,电子设备可通过人像抠图或者人像分割等图像识别方法对第一图像的人像区域和背景区域进行区分。The first image may be an image captured by an imaging device of the electronic device, or an image obtained by the electronic device from another terminal or service device, which is not specifically limited. The first image may include a foreground area and a background area. The foreground area may refer to an area occupied by a subject such as a portrait in the image, and the background area may refer to other image areas in the first image except the foreground area. Taking the portrait area as an example in the foreground area, the electronic device may distinguish the portrait area and the background area of the first image through image recognition methods such as portrait cutout or portrait segmentation.
第一图像对应的虚化力度图,可至少包括第一图像的背景区域中各个第一像素点分别对应的虚化半径。其中,第一像素点可为第一图像的背景区域中的任意一个像素点。虚化半径,可用于指示虚化程度,虚化半径越大,虚化处理后的图像越模糊。在第一图像对应的虚化力度图中,不同的第一像素点对应的虚化半径可能相同,也可能不同。The blur strength map corresponding to the first image may at least include blur radii corresponding to respective first pixels in the background area of the first image. Wherein, the first pixel point may be any pixel point in the background area of the first image. The blur radius can be used to indicate the degree of blur. The larger the blur radius, the blurrier the blurred image. In the blur strength map corresponding to the first image, the blur radii corresponding to different first pixels may be the same or different.
第一图像对应的虚化力度图,可根据第一图像的背景区域中各个第一像素点的深度信息生成,深度信息可用于指示背景区域中的物体与成像设备之间的物理距离。例如,第一像素点的深度信息可与第一像素点对应的虚化半径呈正相关关系。电子设备可电子设备可通过结构光、飞行时间(Time of Flight,TOF)、双目立体成像、单目相位检测、基于深度学习或者机器学习的单目深度估计等方法对第一图像进行深度估计,以至少得到第一图像背景区域中各个第一像素点的景深信息,但不限于此。The blur intensity map corresponding to the first image may be generated according to the depth information of each first pixel in the background area of the first image, and the depth information may be used to indicate the physical distance between the object in the background area and the imaging device. For example, the depth information of the first pixel may be positively correlated with the blur radius corresponding to the first pixel. The electronic device can estimate the depth of the first image through methods such as structured light, Time of Flight (TOF), binocular stereo imaging, monocular phase detection, and monocular depth estimation based on deep learning or machine learning. , so as to at least obtain the depth of field information of each first pixel in the background area of the first image, but not limited thereto.
第一图像对应的权重图,可至少包括第一图像的背景区域中各个第一像素点分别对应的扩散权重。第一图像对应的权重图,可用于指导第一像素点的点扩散处理。在第一图像对应的权重图中,不同的第一像素点对应的扩散权重可能相同,也可能不同。第一图像对应的权重图,可根据第一图像的背景区域中各个第一像素点的像素值生成。其中,像素值可包括亮度分量值和色度分量值。The weight map corresponding to the first image may at least include diffusion weights respectively corresponding to each first pixel in the background area of the first image. The weight map corresponding to the first image can be used to guide the point diffusion processing of the first pixel. In the weight map corresponding to the first image, the diffusion weights corresponding to different first pixel points may be the same or different. The weight map corresponding to the first image may be generated according to the pixel values of each first pixel in the background area of the first image. Wherein, the pixel value may include a luma component value and a chrominance component value.
示例性的,电子设备可通过ISP处理器将第一图像在YUV颜色空间中进行图像数据处理。第一像素点的亮度分量值可为第一像素点在Y通道上的Y分量值,第一像素点的色度分量值可包括第一像素点在U通道上的U分量值和第一像素点在V通道上的V分量值。Exemplarily, the electronic device may perform image data processing on the first image in the YUV color space through the ISP processor. The luminance component value of the first pixel can be the Y component value of the first pixel on the Y channel, and the chrominance component value of the first pixel can include the U component value of the first pixel on the U channel and the first pixel The V component value of the point on the V channel.
根据光圈形状参数、第一图像对应的虚化力度图及权重图,对第一图像的背景区域中的各个第一像素点进行点扩散处理,得到各个第一像素点对应的扩散结果。According to the aperture shape parameter, the blurring strength map and the weight map corresponding to the first image, perform point diffusion processing on each first pixel point in the background area of the first image, and obtain a diffusion result corresponding to each first pixel point.
电子设备可遍历第一图像背景区域中的每个第一像素点。针对当前访问的第一像素点,电子设备可从第一图像对应的虚化力度图中获取与当前访问的第一像素点对应的虚化半径,以及从第一图像对应的权重图中获取与当前访问的第一像素点对应的扩散权重,并根据光圈形状参数、当前访问的第一像素点分别对应的虚化半径和扩散权重,对当前访问的第一像素点进行点扩散处理,以得到当前访问的第一像素点对应的扩散结果。The electronic device may traverse each first pixel in the background area of the first image. For the currently accessed first pixel point, the electronic device may obtain the blur radius corresponding to the currently accessed first pixel point from the blur strength map corresponding to the first image, and obtain the blur radius corresponding to the first pixel point from the weight map corresponding to the first image. The diffusion weight corresponding to the first pixel currently accessed, and according to the aperture shape parameter, the blur radius and the diffusion weight corresponding to the first pixel currently accessed, perform point diffusion processing on the first pixel currently accessed to obtain Diffusion result corresponding to the first pixel currently accessed.
点扩散处理,可指通过点扩散函数(Point Spread Function,PSF)模拟真实的镜头模糊,将第一像素点在第一图像中的像素值,按照与第一像素点对应的扩散权重以及虚化半径扩散成特定的光圈形状。Point spread processing can refer to simulating real lens blur through Point Spread Function (PSF), the pixel value of the first pixel in the first image, according to the diffusion weight corresponding to the first pixel and blurring The radius spreads out to a specific aperture shape.
即,第一像素点对应的扩散结果,可包括第一像素点对应的扩散范围、处于第一像素点对应的扩散范围内的各个第二像素点的目标像素值,以及处于第一像素点对应的扩散范围内的各个第二像素点的扩散次数。其中,第一像素点对应的扩散范围以第一像素点为中心,扩散范围的外接圆的半径为第一像素点对应的虚化半径,扩散范围的外轮廓可为光圈形状参数指示的光圈形状。上述的第二像素点可为第一像素点对应的扩散范围内的任意一个像素点,因此,第一像素点对应的扩散范围内的各个第二像素点包括位于扩散范围中心的第一像素点。That is, the diffusion result corresponding to the first pixel may include the diffusion range corresponding to the first pixel, the target pixel value of each second pixel within the diffusion range corresponding to the first pixel, and the target pixel value of each second pixel corresponding to the first pixel. Diffusion times of each second pixel within the diffusion range of . Wherein, the diffusion range corresponding to the first pixel point is centered on the first pixel point, the radius of the circumscribed circle of the diffusion range is the blur radius corresponding to the first pixel point, and the outer contour of the diffusion range can be the aperture shape indicated by the aperture shape parameter . The above-mentioned second pixel point can be any pixel point within the diffusion range corresponding to the first pixel point, therefore, each second pixel point within the diffusion range corresponding to the first pixel point includes the first pixel point located in the center of the diffusion range .
对背景区域中各个第一像素点对应的扩散结果进行叠加,并根据叠加结果对背景区域进行虚化。The diffusion results corresponding to the first pixel points in the background area are superimposed, and the background area is blurred according to the superposition results.
电子设备对背景区域中各个第一像素点对应的扩散结果进行叠加,可包括:对背景区域中各个第一像素点对应的扩散范围内的各个第二像素点的目标像素值进行叠加,以及对各个第一像素点对应的扩散范围内的各个第二像素点的扩散次数进行叠加。Superimposing the diffusion results corresponding to each first pixel in the background area by the electronic device may include: superimposing the target pixel values of each second pixel within the diffusion range corresponding to each first pixel in the background area, and The diffusion times of each second pixel point within the diffusion range corresponding to each first pixel point are superimposed.
因此,叠加结果可包括背景区域中各个第一像素点叠加后的像素值,以及背景区域中各个第一像素点叠加后的扩散总数。Therefore, the superimposition result may include the superimposed pixel value of each first pixel point in the background area, and the total number of diffusions of each first pixel point in the background area after superimposition.
示例性的,请参阅图3,图3是一个实施例公开的一种对两个相邻的第一像素点对应的扩散结果进行叠加的示例图。如图3所示,第一像素点310对应的扩散范围可包括9个第二像素点,9个第二像素点的目标像素值可分别为A1-A9。第一像素点320对应的扩散范围可包括9个第二像素点,9个第二像素点的目标像素值可分别为B1-B9。For example, please refer to FIG. 3 . FIG. 3 is an example diagram of superimposing diffusion results corresponding to two adjacent first pixel points disclosed by an embodiment. As shown in FIG. 3 , the diffusion range corresponding to the
第一像素点310叠加后的像素值可为A1+B6;第一像素点320叠加后的像素值可为B1+A2。The superimposed pixel value of the
电子设备对各个第一像素点对应的扩散范围内的各个第二像素点的扩散次数进行叠加的方式与对各个第二像素点的目标像素值进行叠加的方式类似,以下内容不再赘述。The manner in which the electronic device superimposes the diffusion times of each second pixel within the diffusion range corresponding to each first pixel is similar to the manner in which the target pixel value of each second pixel is superimposed, and will not be described in detail below.
电子设备在对背景区域中各个第一像素点对应的扩散结果进行叠加,得到叠加结果后,可根据叠加结果对背景区域进行虚化。其中,电子设备根据叠加结果对背景区域进行虚化对背景区域进行虚化可包括:针对背景区域中的每个第一像素点,根据第一像素点叠加后的像素值和叠加后的扩散总数计算第一像素点的虚化像素值。例如,可将第一像素点叠加后的像素值除以叠加后的扩散总数,得到第一像素点的虚化像素值作为虚化渲染的结果。After the electronic device superimposes the diffusion results corresponding to each first pixel point in the background area and obtains the superposition results, the background area may be blurred according to the superposition results. Wherein, the electronic device blurring the background area according to the superposition result and blurring the background area may include: for each first pixel in the background area, according to the superimposed pixel value of the first pixel and the superimposed diffusion total number Calculate the blurred pixel value of the first pixel. For example, the superimposed pixel value of the first pixel may be divided by the total number of superimposed diffusions to obtain the blurred pixel value of the first pixel as a result of blurred rendering.
电子设备对背景区域中的每个第一像素点以相对应的权重进行点扩散处理,相互交叠之下,第一图像中亮度较高的亮点形成高亮的光斑,而第一图像中亮度较低的暗点形成朦胧的弥散圆。The electronic device performs point diffusion processing on each first pixel in the background area with a corresponding weight. Under mutual overlap, the bright spots in the first image form bright spots, while the brightness in the first image The lower scotoma forms a hazy, diffuse circle.
可见,在前述实施例中,电子设备可以通过点扩散处理模拟真实的镜头模糊,解决了高斯模糊和光斑贴图存在割裂的问题,使得图像整体的虚化效果和谐自然、融为一体,并且更能够模拟单反相机摄影的虚化自然、光斑明亮通透的效果,大大提升了虚化效果的质感。此外,电子设备可对背景区域中的每个第一像素点进行点扩散处理,无需进行光源点位置识别,从而可以避免光源点位置识别不准确而导致虚化效果下降的问题,有利于提供更加真实自然的虚化效果。It can be seen that, in the above-mentioned embodiments, the electronic device can simulate the real lens blur through point diffusion processing, which solves the problem of Gaussian blur and the fragmentation of the light spot map, so that the overall blur effect of the image is harmonious and natural, integrated, and more capable It simulates the natural bokeh and bright and transparent effect of SLR camera photography, which greatly improves the texture of the bokeh effect. In addition, the electronic device can perform point diffusion processing on each first pixel point in the background area without identifying the position of the light source point, thereby avoiding the problem of inaccurate recognition of the position of the light source point and resulting in a decrease in the blur effect, which is conducive to providing more Realistic and natural bokeh effect.
为了更清楚地说明点扩散处理,请参阅图4,图4是一个实施例中公开的另一种图像处理方法的流程示意图,该方法可应用于前述的任意一种电子设备。如图4所示,该方法可包括以下步骤:In order to illustrate the point diffusion processing more clearly, please refer to FIG. 4 . FIG. 4 is a schematic flowchart of another image processing method disclosed in an embodiment, and the method can be applied to any of the aforementioned electronic devices. As shown in Figure 4, the method may include the following steps:
获取光圈形状参数、以及获取第一图像对应的虚化力度图及权重图。Obtain the shape parameters of the aperture, and obtain the blur strength map and weight map corresponding to the first image.
在一些实施例中,第一图像对应的虚化力度图,除了可包括第一图像的背景区域中各个第一像素点分别对应的虚化半径以外,还可包括第一图像的前景区域中各个第三像素点分别对应的虚化半径。即,第一图像对应的虚化力度图可包括第一图像全图每个像素点对应的虚化半径。电子设备在生成第一图像对应的虚化力度图时,可以根据第一图像包含的各个像素点的景深信息生成各个像素点对应的虚化半径。In some embodiments, the blur strength map corresponding to the first image may include not only the blur radii corresponding to each first pixel in the background area of the first image, but also each pixel in the foreground area of the first image. The blur radius corresponding to the third pixel. That is, the blur strength map corresponding to the first image may include a blur radius corresponding to each pixel in the full image of the first image. When the electronic device generates the blur strength map corresponding to the first image, it may generate the blur radius corresponding to each pixel according to the field depth information of each pixel included in the first image.
第一图像对应的权重图,除了可包括第一图像的背景区域中各个第一像素点分别对应的扩散权重以外,还可包括第一图像的前景区域中各个第三像素点分别对应的扩散权重。即,第一图像对应的权重图可包括第一图像全图每个像素点对应的扩散权重。电子设备在生成第一图像对应的权重图时,可以根据第一图像包含的各个像素点的像素值生成各个像素点对应的扩散权重。The weight map corresponding to the first image, in addition to the diffusion weights corresponding to each first pixel in the background area of the first image, may also include the diffusion weights corresponding to each third pixel in the foreground area of the first image . That is, the weight map corresponding to the first image may include a diffusion weight corresponding to each pixel in the full image of the first image. When generating the weight map corresponding to the first image, the electronic device may generate the diffusion weight corresponding to each pixel according to the pixel value of each pixel included in the first image.
针对第一图像的背景区域中的每个第一像素点,从虚化力度图中获取与第一像素点对应的虚化半径,以及从权重图中获取与第一像素点对应的扩散权重。For each first pixel in the background area of the first image, the blur radius corresponding to the first pixel is obtained from the blur strength map, and the diffusion weight corresponding to the first pixel is obtained from the weight map.
电子设备可生成用于指示第一图像背景区域的背景掩膜,以标识第一图像背景区域包含的各个第一像素点。The electronic device may generate a background mask used to indicate the background area of the first image, so as to identify each first pixel contained in the background area of the first image.
电子设备可以遍历背景掩膜中的每个第一像素点,从虚化力度图中从虚化力度图中获取与当前访问的第一像素点对应的虚化半径,以及从权重图中获取与当前访问的第一像素点对应的扩散权重。The electronic device may traverse each first pixel in the background mask, obtain the blur radius corresponding to the currently accessed first pixel from the blur strength map, and obtain the corresponding value from the weight map. Diffusion weight corresponding to the first pixel currently accessed.
根据第一像素点的虚化半径以及光圈形状参数确定与第一像素点对应的第一光圈核。A first aperture kernel corresponding to the first pixel is determined according to the blur radius of the first pixel and the aperture shape parameter.
电子设备可预先生成、存储或者从服务设备等其它设备中获取多个光圈核,不同的光圈核可用于指示不同的扩散范围。不同的光圈核可对应于不同的虚化半径,每个光圈核可与一个光圈形状对应,同一个光圈形状可对应有多个虚化半径不同的光圈核。The electronic device may pre-generate, store, or obtain multiple aperture kernels from other devices such as a service device, and different aperture kernels may be used to indicate different diffusion ranges. Different aperture cores may correspond to different blurring radii, each aperture core may correspond to an aperture shape, and the same aperture shape may correspond to multiple aperture cores with different blurring radii.
当电子设备获取到光圈形状参数以及第一像素点的虚化半径时,可从多个光圈核中确定出与第一像素点的虚化半径对应,并且与光圈形状参数指示的光圈形状对应的第一光圈核,第一光圈核可用于指示第一像素点的扩散范围。When the electronic device obtains the aperture shape parameter and the blur radius of the first pixel point, it can determine from the plurality of aperture kernels which corresponds to the blur radius of the first pixel point and corresponds to the aperture shape indicated by the aperture shape parameter. The first aperture kernel, the first aperture kernel may be used to indicate the diffusion range of the first pixel.
可选的,电子设备可根据光圈图像预先生成多个光圈核。其中,电子设备可获取光圈形状不同的多个光圈图像,上述的光圈形状可以个性化定制的图形、心形、星形、圆形或者圆环等,但不限于此。Optionally, the electronic device may pre-generate multiple aperture kernels according to the aperture image. Wherein, the electronic device can acquire multiple aperture images with different aperture shapes, and the above aperture shapes can be personalized graphics, heart shapes, star shapes, circles or rings, etc., but are not limited thereto.
电子设备可将多个光圈图像中的每个光圈图像进行多次缩放,每缩放一次,可得到与一个虚化半径对应的光圈核。因此,在电子设备对每个光圈图像进行多次缩放后,可得到与每个光圈形状对应的多个光圈核,每个光圈核可对应于一个虚化半径。例如,电子设备可将光圈图像依次缩放到3×3、4×4……N×N的大小。The electronic device can zoom each aperture image in the plurality of aperture images multiple times, and each zoom can obtain an aperture kernel corresponding to a blur radius. Therefore, after the electronic device scales each aperture image multiple times, multiple aperture kernels corresponding to each aperture shape can be obtained, and each aperture kernel can correspond to a blurring radius. For example, the electronic device can sequentially scale the aperture image to a size of 3×3, 4×4...N×N.
440、根据第一像素点在第一图像中的像素值、第一像素点对应的扩散权重以及第一光圈核计算第一像素点对应的扩散范围内各个第二像素点的目标像素值。440. Calculate the target pixel value of each second pixel within the diffusion range corresponding to the first pixel according to the pixel value of the first pixel in the first image, the diffusion weight corresponding to the first pixel, and the first aperture kernel.
电子设备可将第一像素点在第一图像中的像素值乘以第一像素点对应的扩散权重,再乘以第一光圈核,从而可以得到第一像素点对应的扩散范围内各个第二像素点的目标像素值。即,将第一像素点的像素值扩散到以第一像素点为中心的扩散范围内。The electronic device can multiply the pixel value of the first pixel in the first image by the diffusion weight corresponding to the first pixel, and then multiply it by the first aperture kernel, so as to obtain each second pixel within the diffusion range corresponding to the first pixel. The target pixel value of the pixel. That is, the pixel value of the first pixel is diffused into a diffusion range centered on the first pixel.
在一些实施例中,第一像素点的像素值可包括亮度分量值和色度分量值。相应地,权重图也可包括亮度权重图和色度权重图,扩散权重可包括亮度权重和色度权重,亮度权重图可至少包括背景区域中各个第一像素点的亮度权重,色度权重图可至少包括背景区域中各个第一像素点的色度权重。In some embodiments, the pixel value of the first pixel point may include a luma component value and a chrominance component value. Correspondingly, the weight map may also include a luminance weight map and a chromaticity weight map, the diffusion weight may include a luminance weight and a chromaticity weight, the luminance weight map may at least include the luminance weights of each first pixel in the background area, and the chromaticity weight map may include It may at least include the chromaticity weights of each first pixel in the background area.
在对第一像素点进行点扩散处理时,电子设备可以根据对应的扩散权重,分别对第一像素点的亮度分量值和色度分量值进行点扩散处理,在叠加时再融合。When performing point diffusion processing on the first pixel, the electronic device may perform point diffusion processing on the luminance component value and the chrominance component value of the first pixel according to the corresponding diffusion weight, and fuse them again during superimposition.
示例性的,第一像素点的亮度分量值可为Y通道的Y分量值,色度分量值可包括U通道的U分量值和V通道的V分量值。Exemplarily, the luminance component value of the first pixel point may be the Y component value of the Y channel, and the chrominance component value may include a U component value of the U channel and a V component value of the V channel.
针对每个第一像素点,电子设备可将第一像素点的Y分量值乘以第一像素点的亮度权重,再乘以第一光圈核,得到第一像素点对应的扩散范围内各个第二像素点在Y通道的目标Y分量值。For each first pixel point, the electronic device can multiply the Y component value of the first pixel point by the brightness weight of the first pixel point, and then multiply by the first aperture kernel to obtain the first pixel point corresponding to the first pixel point in the diffusion range. The target Y component value of the two pixels in the Y channel.
电子设备可将第一像素点的U分量值乘以第一像素点的色度权重,再乘以第一光圈核,得到第一像素点对应的扩散范围内各个第二像素点在U通道的目标U分量值。The electronic device can multiply the U component value of the first pixel by the chromaticity weight of the first pixel, and then multiply by the first aperture kernel to obtain the U channel value of each second pixel in the diffusion range corresponding to the first pixel. Target U component value.
电子设备可将第一像素点的V分量值乘以第一像素点的色度权重,再乘以第一光圈核,得到第一像素点对应的扩散范围内各个第二像素点在V通道的目标V分量值。The electronic device can multiply the V component value of the first pixel by the chromaticity weight of the first pixel, and then multiply it by the first aperture kernel to obtain the V channel value of each second pixel in the diffusion range corresponding to the first pixel. Target V component value.
根据第一像素点对应的扩散权重以及第一光圈核计算第一像素点对应的扩散范围内各个第二像素点的扩散次数。According to the diffusion weight corresponding to the first pixel and the first aperture kernel, the number of diffusions of each second pixel within the diffusion range corresponding to the first pixel is calculated.
电子设备可将第一像素点对应的扩散权重乘以第一光圈核,从而可以得到第一像素点对应的扩散范围内各个第二像素点的扩散次数。The electronic device may multiply the diffusion weight corresponding to the first pixel by the first aperture kernel, so as to obtain the diffusion times of each second pixel within the diffusion range corresponding to the first pixel.
电子设备在执行步骤440-步骤450之后,可以得到第一像素点对应的扩散结果,并对背景区域中各个第一像素点对应的扩散结果进行叠加,以对背景区域进行虚化。After executing
在一些实施例中,电子设备可通过执行下述步骤对背景区域中的各个第一像素点对应的扩散结果进行叠加。In some embodiments, the electronic device may perform the following steps to superimpose the diffusion results corresponding to each first pixel in the background area.
460、将背景区域中各个第一像素点对应的扩散范围包含的各个第二像素点的目标像素值叠加至像素值叠加图,并将背景区域中各个第一像素点对应的扩散范围包含的各个第二像素点的扩散次数叠加至次数统计图。460. Superimpose the target pixel values of each second pixel contained in the diffusion range corresponding to each first pixel in the background area to the pixel value overlay map, and add each target pixel value contained in the diffusion range corresponding to each first pixel in the background area The number of diffusion times of the second pixel is superimposed on the number statistics graph.
像素值叠加图可用于记录像素值的点扩散叠加结果,像素值叠加图的尺寸可大于或等于第一图像,像素值叠加图的初始值可为0。像素叠加图的颜色通道数量可与第一图像的颜色通道数量一致,每个通道可用于记录相同通道的分量值的点扩散叠加结果。The pixel value superposition map can be used to record the point diffusion superposition result of pixel values, the size of the pixel value superposition map can be greater than or equal to the first image, and the initial value of the pixel value superposition map can be 0. The number of color channels of the pixel overlay image may be consistent with the number of color channels of the first image, and each channel may be used to record a point diffusion overlay result of component values of the same channel.
次数统计图可用于记录扩散次数的点扩散叠加结果,次数统计图的尺寸可大于或等于第一图像,次数统计图的初始值可为0。The number statistics map can be used to record the point diffusion superposition result of the diffusion times, the size of the times statistics map can be greater than or equal to the first image, and the initial value of the times statistics map can be 0.
可选的,为了保留第一图像边缘像素点的点扩散效果,可根据虚化力度图中最大的虚化半径扩充像素值叠加图和次数统计图的边缘范围,使得像素值叠加图的图像尺寸大于第一图像。Optionally, in order to preserve the point diffusion effect of the edge pixels of the first image, the edge range of the pixel value overlay map and the count statistics map can be expanded according to the maximum blur radius in the blur intensity map, so that the image size of the pixel value overlay map larger than the first image.
电子设备可以在每计算出一个第一像素点对应的扩散结果之后,可以将扩散结果包含的各个第二像素点的目标像素值叠加至像素值叠加图,以及将扩散结果包含的各个第二像素点的扩散次数叠加至次数统计图。依次类推,直至背景区域包含的各个第一像素点对应的扩散结果均叠加至像素叠加图和次数统计图。After each calculation of the diffusion result corresponding to the first pixel, the electronic device can superimpose the target pixel value of each second pixel contained in the diffusion result to the pixel value overlay map, and the target pixel value of each second pixel contained in the diffusion result The number of spreads of points is superimposed on the count graph. By analogy, until the diffusion results corresponding to each first pixel contained in the background area are superimposed on the pixel overlay map and the count statistics map.
根据背景区域中各个第一像素点在叠加后的像素值叠加图中的像素值,以及背景区域中各个第一像素点在叠加后的次数统计图中的扩散总数,对背景区域中各个第一像素点进行虚化。According to the pixel value of each first pixel point in the background area in the superimposed pixel value superimposition map, and the total number of diffusions of each first pixel point in the background area in the superimposed number of times statistics map, for each first pixel point in the background area Pixels are blurred.
背景区域包括的每个第一像素点在叠加后的像素值叠加图中的像素值,可能是由一个或多个第一像素点的像素值扩散叠加后得到的,每个第一像素点在叠加后的次数统计图中的扩散总数,也可能是由一个或多个第一像素点的扩散次数叠加后得到的。The pixel value of each first pixel included in the background area in the superimposed pixel value superposition map may be obtained by diffusion and superposition of the pixel values of one or more first pixels, and each first pixel is in The total number of diffusions in the statistical graph of the number of times after superposition may also be obtained by superimposing the number of diffusions of one or more first pixel points.
因此,针对每个第一像素点,电子设备可将第一像素点叠加后得到的像素值除以第一像素点的扩散总数,得到对第一像素点进行虚化的虚化渲染结果。Therefore, for each first pixel, the electronic device may divide the pixel value obtained by superimposing the first pixel by the total number of diffusions of the first pixel to obtain a blurred rendering result of blurring the first pixel.
示例性的,对第一像素点进行虚化可通过以下公式进行计算:Exemplarily, blurring the first pixel can be calculated by the following formula:
其中,Bokeh可表示第一像素点虚化后的像素值,kernel可表示第一光圈核,weight可表示第一像素点对应的扩散权重,input可表示第一像素点在第一图像中的像素值,即虚化前的像素值。Among them, Bokeh can represent the blurred pixel value of the first pixel, kernel can represent the first aperture kernel, weight can represent the diffusion weight corresponding to the first pixel, and input can represent the pixel of the first pixel in the first image Value, that is, the pixel value before blurring.
可见,在前述的实施例中,背景掩膜可用于指示第一图像的背景区域,使得电子设备可以对背景区域包括的各个第一像素点进行点扩散处理,使得背景区域的亮点形成光斑,暗点形成弥散圆,更真实自然地模拟真实镜头的模糊效果。此外,还可通过不同的光圈核模拟不同的光圈形状,使得虚化后的光斑可以呈现不同的形状。It can be seen that, in the foregoing embodiments, the background mask can be used to indicate the background area of the first image, so that the electronic device can perform point diffusion processing on each first pixel included in the background area, so that the bright spots in the background area form light spots, and the dark spots The dots form a blurring circle, which more realistically and naturally simulates the blur effect of a real lens. In addition, different aperture shapes can be simulated through different aperture kernels, so that blurred light spots can take on different shapes.
在前述实施例中,背景掩膜可用于指示第一图像的背景区域,可用于指示需要进行点扩散处理的像素点的范围,以免错误地对第一图像的前景区域进行虚化。In the foregoing embodiments, the background mask can be used to indicate the background area of the first image, and can be used to indicate the range of pixels that need to be subjected to dot diffusion processing, so as to avoid blurring the foreground area of the first image by mistake.
在一些实施例中,电子设备可利用第一图像的虚化力度图生成背景掩膜。In some embodiments, the electronic device may use the defocusing intensity map of the first image to generate the background mask.
请参阅图5,图5是一个实施例公开的一种生成背景掩膜的方法流程示意图,该方法可应用于前述的电子设备。如图5所示,该方法可包括以下步骤:Please refer to FIG. 5 . FIG. 5 is a schematic flowchart of a method for generating a background mask disclosed by an embodiment, and the method can be applied to the aforementioned electronic device. As shown in Figure 5, the method may include the following steps:
510、根据第一图像的虚化力度图在第一图像中移除人像区域。510. Remove the portrait region in the first image according to the blur strength map of the first image.
第一图像的前景区域可包括人像区域,人像区域一般不进行虚化处理,因此虚化力度图中虚化半径为0的像素点所在的区域对应于人像区域。电子设备在第一图像中移除在虚化半径为0的像素点,从而可以在第一图像中移除人像区域。The foreground area of the first image may include a portrait area, and the portrait area generally does not undergo blurring processing, so the area where the pixels with a blurring radius of 0 in the blurring strength map are located corresponds to the portrait area. The electronic device removes pixels with a blur radius of 0 in the first image, so that the portrait area can be removed in the first image.
虚化力度图可以是根据第一图像全图的各个像素点的深度信息生成的。深度较小的像素点可以被认为属于人像区域,因此可将深度较小的像素点对应的虚化半径设置为0。因此,第一图像的虚化力度图在一定程度上可以帮助识别人像区域,电子设备可以在第一图像中移除虚化半径为0的像素点,以移除人像区域。The blur strength map may be generated according to the depth information of each pixel in the full image of the first image. Pixels with smaller depths can be considered to belong to the portrait area, so the blur radius corresponding to pixels with smaller depths can be set to 0. Therefore, the blur intensity map of the first image can help identify the portrait area to a certain extent, and the electronic device can remove pixels with a blur radius of 0 in the first image to remove the portrait area.
可选的,电子设备在第一图像中移除人像区域之前,可以先对第一图像的虚化力度图中的人像区域进行扩张,包括:腐蚀虚化力度图,以扩张人像区域的范围。其中,虚化力度图中每个像素点对应的腐蚀半径可与每个像素点对应的虚化半径呈正相关关系。即,若虚化力度图中的某个像素点对应的虚化半径越大,该像素点对应的腐蚀半径越大。Optionally, before removing the portrait area in the first image, the electronic device may first expand the portrait area in the blur intensity map of the first image, including: eroding the blur intensity map to expand the range of the portrait area. Wherein, the erosion radius corresponding to each pixel in the blur strength map may be positively correlated with the blur radius corresponding to each pixel. That is, if the blur radius corresponding to a pixel in the blur intensity map is larger, the erosion radius corresponding to the pixel is larger.
相较于腐蚀前的虚化力度图,在腐蚀后的虚化力度图中,虚化半径为0的像素点的数量可能增多。电子设备可以根据人像区域扩张后的虚化力度图在第一图像中移除人像区域,例如可以在第一图像中移除在腐蚀后的虚化力度图中半径为0的像素点,以在第一图像中移除人像区域。Compared with the blur intensity map before erosion, the number of pixels with a blur radius of 0 may increase in the blur intensity map after erosion. The electronic device may remove the portrait region in the first image according to the expanded blur strength map of the portrait region. The portrait area is removed from the first image.
520、根据头发掩膜在移除了人像区域的第一图像中移除头发区域,以得到第一图像的背景掩膜。520. Remove the hair region in the first image from which the portrait region has been removed according to the hair mask, so as to obtain a background mask of the first image.
第一图像的前景区域还可包括头发区域。电子设备可对第一图像进行发丝识别,例如通过深度学习方法识别第一图像中的各个像素点属于头发的置信度,从而生成发丝掩膜。The foreground region of the first image may also include a hair region. The electronic device may perform hair recognition on the first image, for example, by using a deep learning method to identify the confidence level that each pixel in the first image belongs to hair, so as to generate a hair mask.
头发掩膜可用于指示第一图像中的头发区域,头发掩膜可包括第一图像中各个像素点被识别为头发的置信度,置信度高于置信度阈值的像素点可用于指示第一图像中的头发区域。电子设备可以在移除了人像区域的第一图像中减去头发掩膜指示的头发区域,从而移除头发区域,得到第一图像的背景掩膜。The hair mask can be used to indicate the hair region in the first image, the hair mask can include the confidence that each pixel in the first image is recognized as hair, and the pixels with the confidence higher than the confidence threshold can be used to indicate the first image in the hair area. The electronic device may subtract the hair region indicated by the hair mask from the first image from which the portrait region has been removed, so as to remove the hair region and obtain the background mask of the first image.
可选的,虽然深度学习等方法可识别第一图像中的头发区域,但可能存在一定的误差。为了减少头发识别误差带来的影响,电子设备在移除头发区域之前,可以先对第一图像的头发掩膜进行扩张。电子设备可以先统计头发掩膜中头发外轮廓的面积,根据头发外轮廓的面积比例计算膨胀半径,再根据头发外轮廓像素点的虚化半径增大膨胀半径。其中,头发区域外轮廓的面积可指头发区域外轮廓包含的像素点数量,虚化半径和膨胀半径的增加量可呈正相关关系。即,若头发掩膜中某个像素点对应的虚化半径越大,该像素点对应的膨胀半径增大的越多。Optionally, although methods such as deep learning can identify the hair region in the first image, certain errors may exist. In order to reduce the impact of hair recognition errors, the electronic device may first expand the hair mask of the first image before removing the hair region. The electronic device can first count the area of the outer contour of the hair in the hair mask, calculate the expansion radius according to the area ratio of the outer contour of the hair, and then increase the expansion radius according to the blurring radius of the pixel points of the outer hair outline. Wherein, the area of the outer contour of the hair region may refer to the number of pixels included in the outer contour of the hair region, and the increase of the blur radius and the expansion radius may be positively correlated. That is, if the virtualization radius corresponding to a pixel in the hair mask is larger, the expansion radius corresponding to the pixel is increased more.
电子设备可根据像素点的膨胀半径对头发掩膜进行膨胀,以扩张头发区域。此外,电子设备还可进一步增加头发掩膜中像素点的置信度,以增加被识别为头发的像素点数量,可以进一步扩张头发区域。The electronic device can expand the hair mask according to the expansion radius of the pixels to expand the hair area. In addition, the electronic device can further increase the confidence of the pixels in the hair mask, so as to increase the number of pixels identified as hair, which can further expand the hair area.
电子设备可以在移除了人像区域的第一图像中,减去头发掩膜扩张后的头发区域,以得到第一图像的背景掩膜,从而可以减少由于头发发丝被错误地虚化扩散成光晕形成色带而导致颜色泄露(Color Bleeding)的问题。The electronic device can subtract the hair region expanded by the hair mask from the first image from which the portrait region has been removed, so as to obtain the background mask of the first image, so as to reduce the false blur caused by the hair strands. The problem of color bleeding (Color Bleeding) caused by halos forming color bands.
在一些实施例中,在生成第一图像的虚化力度图之前,电子设备还可对第一图像的人像区域和头发外轮廓区域进行去瑕疵(Inpaint)填充。即,可以利用与人像区域和头发外轮廓区域相邻的背景区域的像素点填充人像区域和头发外轮廓区域,以删除在人像和头发边缘的光斑。在对第一图像进行Inpaint填充之后再生成虚化力度图,并根据虚化力度图生成背景掩膜,既能优化颜色泄露的问题,还可以使得对第一图像的处理符合原图的梯度走向、纹理特征和颜色特征等,有利于使得对第一图像的虚化效果更加真实自然。In some embodiments, before generating the deblurring strength map of the first image, the electronic device may also perform blemish removal (Inpaint) filling on the portrait area and hair outline area of the first image. That is, the pixels of the background area adjacent to the portrait area and the hair outline area can be used to fill the portrait area and the hair outline area, so as to delete the light spots on the edges of the portrait and hair. After filling the first image with Inpaint, generate a blur intensity map, and generate a background mask according to the blur intensity map, which can not only optimize the problem of color leakage, but also make the processing of the first image conform to the gradient direction of the original image , texture features, color features, etc., which are beneficial to make the blurring effect on the first image more realistic and natural.
可见,在前述实施例中,电子设备可以对第一图像的人像区域和头发区域进行处理,以更准确地识别第一图像的背景区域,从而可以减少将人像边缘和头发边缘的像素点错误地虚化而导致颜色泄露的问题,使得将第一图像的虚化效果更加真实自然。It can be seen that, in the foregoing embodiments, the electronic device can process the portrait area and the hair area of the first image to more accurately identify the background area of the first image, thereby reducing false positives of pixels on the edge of the portrait and the hair edge. The problem of color leakage caused by blurring makes the blurring effect of the first image more realistic and natural.
此外,在前述实施例中的说明中,点扩散处理可以将第一图像中亮度较高的亮点扩散虚化成光斑。若第一图像背景区域整体亮度较高,则可能导致虚化效果中的光斑扩散太多,反而导致虚化效果不自然、不真实。In addition, in the description of the foregoing embodiments, the dot diffusion processing can diffuse and blur brighter bright spots in the first image into light spots. If the overall brightness of the background area of the first image is high, it may cause the light spots in the blur effect to spread too much, and instead cause the blur effect to be unnatural and unreal.
因此,在一些实施例中,电子设备可对第一图像进行预处理,包括:电子设备可降低第一图像背景区域中各个第一像素点的亮度分量值。其中,第一像素点的亮度分量值的降低量,可与第一图像拍摄场景的亮度呈正相关关系。即,第一图像的拍摄场景越亮,第一像素点的亮度分量值压低得越多。Therefore, in some embodiments, the electronic device may perform preprocessing on the first image, including: the electronic device may reduce brightness component values of each first pixel in the background area of the first image. Wherein, the reduction amount of the brightness component value of the first pixel point may have a positive correlation with the brightness of the shooting scene of the first image. That is, the brighter the shooting scene of the first image is, the more the brightness component value of the first pixel is depressed.
示例性的,请参阅图6,图6是一个实施例公开的一种对背景区域进行亮度压暗的方法流程示意图,该方法可应用于前述的电子设备。如图6所示,可包括以下步骤:For example, please refer to FIG. 6 . FIG. 6 is a schematic flowchart of a method for darkening the brightness of a background area disclosed by an embodiment, and the method can be applied to the aforementioned electronic device. As shown in Figure 6, the following steps may be included:
610、计算用于亮度压暗的伽马(Gamma)参数。610. Calculate a gamma (Gamma) parameter used for brightness suppression.
Gamma参数可用于进行Gamma矫正,Gamma参数可通过以下公式进行计算:The Gamma parameter can be used for Gamma correction, and the Gamma parameter can be calculated by the following formula:
其中,Gamma_1可为用于亮度压暗的Gamma参数,Contrast可为输入的对比度参数,iso可为拍摄到第一图像的成像设备的感光度参数。Wherein, Gamma_1 may be a Gamma parameter for brightness suppression, Contrast may be an input contrast parameter, and iso may be a sensitivity parameter of an imaging device that captures the first image.
620、基于计算出的Gamma参数对各个第一像素点的亮度分量值进行曲线映射拉伸,以降低第一像素点的亮度分量值。其中,第一图像背景区域的各个第一像素点的拉伸后的亮度分量值可参考以下公式进行计算:620. Perform curve mapping and stretching on the luminance component values of each first pixel point based on the calculated Gamma parameter, so as to reduce the luminance component values of the first pixel points. Wherein, the stretched luminance component values of each first pixel in the background area of the first image can be calculated with reference to the following formula:
其中,y1可表示拉伸后的亮度分量值,x1可表示拉伸前的亮度分量值,拉伸前的亮度分量值可指第一像素点在第一图像中的亮度分量值。Wherein, y1 may represent the brightness component value after stretching, x1 may represent the brightness component value before stretching, and the brightness component value before stretching may refer to the brightness component value of the first pixel in the first image.
通过前述的公式的(2)和公式(3),电子设备可将第一图像背景区域中各个第一像素点的亮度分量值进行降低,并且拍摄场景越亮,亮度分量值压低得越多,从而可以压暗背景并凸显光源,可以提升对比度。Through the aforementioned formula (2) and formula (3), the electronic device can reduce the brightness component value of each first pixel in the background area of the first image, and the brighter the shooting scene is, the more the brightness component value is reduced. In this way, the background can be suppressed and the light source can be highlighted, which can improve the contrast.
在一些实施例中,电子设备对第一图像进行预处理,还可以包括:电子设备可提高第一图像背景区域中高光区域包含的各个第一像素点的色度分量值,以对高光区域进行色彩增强,提高光源中心的色彩。其中,高光区域包含的各个第一像素点的亮度分量值均高于亮度阈值,亮度阈值可根据实际的业务需求设置,具体不做限定。即,高光区域可以是背景区域中相对较亮的图像区域。此外,高光区域包含的第一像素点的色度分量的增加量,可与第一图像拍摄场景的亮度呈负相关关系。即,第一图像的拍摄场景越暗,高光区域包含的第一像素点的色度分量值增加得越多。In some embodiments, the electronic device preprocessing the first image may further include: the electronic device may increase the chrominance component values of each first pixel contained in the highlight area in the background area of the first image, so as to process the highlight area Color Enhancement, which enhances the color in the center of the light source. Wherein, the luminance component values of each first pixel contained in the highlight area are all higher than a luminance threshold, and the luminance threshold can be set according to actual service requirements, and is not specifically limited. That is, the highlight area may be a relatively bright image area in the background area. In addition, the increase amount of the chrominance component of the first pixel contained in the highlight area may have a negative correlation with the brightness of the shooting scene of the first image. That is, the darker the shooting scene of the first image is, the more the chrominance component value of the first pixel contained in the highlight area increases.
示例性的,请参阅图7,图7是一个实施例公开的一种对高光区域进行色彩增强的方法流程示意图,该方法可应用于前述的电子设备。如图7所示,可包括以下步骤:For example, please refer to FIG. 7 . FIG. 7 is a schematic flowchart of a method for color enhancement of a highlight area disclosed by an embodiment, and the method can be applied to the aforementioned electronic device. As shown in Figure 7, the following steps may be included:
710、对第一图像的色度分量值进行模糊。710. Blur the chrominance component values of the first image.
第一图像的色度分量值可包括U分量值和V分量值,电子设备可分别对第一图像全图的U分量值进行图像模糊,以及对第一图像全图的V分量值进行图像模糊。其中,图像模糊的方式可包括但不限于:N×N Block均值模糊、中值模糊等。The chrominance component value of the first image may include a U component value and a V component value, and the electronic device may respectively perform image blurring on the U component value of the entire first image, and perform image blurring on the V component value of the entire first image . Wherein, the way of image blurring may include but not limited to: N×N Block mean blurring, median blurring, etc.
一般而言,由于光源中心的能量较大,可能超过成像设备的感光元件(sensor)的承载上限,导致光源中心在拍摄到的第一图像中的色彩比较寡淡。而对第一图像的色度分量值进行图像模糊,则可以利用邻域的色度分量值补强色彩寡淡区域的色度分量值,以弥补sensor的承载能力导致的问题。Generally speaking, because the energy of the center of the light source is relatively large, it may exceed the upper limit of the load capacity of the sensor of the imaging device, resulting in the center of the light source having a weaker color in the captured first image. For blurring the chrominance component values of the first image, the chrominance component values in the neighborhood can be used to reinforce the chrominance component values in the weakly colored areas, so as to compensate for the problem caused by the sensor's carrying capacity.
720、根据饱和度参数计算用于进行色彩增强的Gamma参数,并利用计算出的Gamma参数参数对第一图像全图进行色彩增强,得到色彩增强后的第一图像。720. Calculate a Gamma parameter for color enhancement according to the saturation parameter, and use the calculated Gamma parameter to perform color enhancement on the entire image of the first image to obtain a color-enhanced first image.
电子设备可以利用用于进行色彩增强的Gamma参数对第一图像全图的色度分量值进行曲线映射拉伸,以对第一图像整体进行色彩增强。The electronic device may use the Gamma parameter for color enhancement to perform curve mapping and stretching on the chrominance component values of the full image of the first image, so as to perform color enhancement on the entire first image.
用于进行色彩增强的Gamma参数可通过以下公式进行计算:The Gamma parameter for color enhancement can be calculated by the following formula:
其中,Gamma_2可为用于进行色彩增强的Gamma参数,Saturation可为输入的饱和度参数,iso可为拍摄到第一图像的成像设备的感光度参数。Wherein, Gamma_2 may be a Gamma parameter for color enhancement, Saturation may be an input saturation parameter, and iso may be a sensitivity parameter of an imaging device that captures the first image.
第一图像全图的色度分量值进行曲线映射拉伸可通过以下公式进行计算:The curve mapping and stretching of the chrominance component values of the full image of the first image can be calculated by the following formula:
其中,i可为色度分量值,LUT可为拉伸后的色度分量值,拉伸前的色度分量值可指第一像素点在第一图像中的色度分量值。Wherein, i may be the chroma component value, the LUT may be the chroma component value after stretching, and the chroma component value before stretching may refer to the chroma component value of the first pixel in the first image.
此外,电子设备在对第一图像全图的色度分量值进行曲线映射拉伸之后,对于拉伸前的色度分量值=128的无颜色区域需要原样回填。即,对于拉伸前的色度分量=128的无颜色区域的色度分量在拉伸前后可保持一致。In addition, after the electronic device performs curve mapping and stretching on the chrominance component values of the full image of the first image, it needs to backfill the uncolored area with the chroma component value=128 before stretching. That is, the chromaticity components of the colorless region with the chromaticity component before stretching = 128 can be kept consistent before and after stretching.
730、计算第一图像的高光掩膜。730. Calculate a highlight mask of the first image.
第一图像的高光掩膜可用于指示第一图像中的高光区域,可包括背景区域中的高光区域。电子设备可通过对第一图像全图的亮度分量值进行拉伸映射,以得到第一图像的高光掩膜,高光掩膜可包括第一图像中各个像素点拉伸后的亮度分量。对亮度分量值进行拉伸映射可通过以下公式进行计算:The highlight mask of the first image may be used to indicate highlight areas in the first image, which may include highlight areas in background areas. The electronic device may stretch and map the brightness component values of the full image of the first image to obtain a highlight mask of the first image, and the highlight mask may include stretched brightness components of each pixel in the first image. Stretch mapping of luma component values can be calculated by the following formula:
其中,y2可表示拉伸后的亮度分量值,x2可表示拉伸前的亮度分量值,拉伸前的亮度分量值可指第一像素点在第一图像中的亮度分量值。Wherein, y2 may represent the brightness component value after stretching, x2 may represent the brightness component value before stretching, and the brightness component value before stretching may refer to the brightness component value of the first pixel in the first image.
需要说明的是,从上述的公式(6)中可以看出,若拉伸前的亮度分量值较低,拉伸后的亮度分量值可能为0,而拉伸前的亮度分量值越高,则拉伸后的亮度分量值越高。因此,通过对亮度分量值进行拉伸得到的高光掩膜可用于指示第一图像中像素点的亮度分量值高于亮度阈值的高光区域。It should be noted that, from the above formula (6), it can be seen that if the value of the brightness component before stretching is low, the value of the brightness component after stretching may be 0, and the value of the brightness component before stretching is higher, Then the value of the brightness component after stretching is higher. Therefore, the highlight mask obtained by stretching the brightness component value can be used to indicate the highlight region where the brightness component value of the pixel point in the first image is higher than the brightness threshold.
740、根据色彩增强后的第一图像以及第一图像的高光掩膜,对第一图像的高光区域进行色彩增强。740. Perform color enhancement on the highlight area of the first image according to the color-enhanced first image and the highlight mask of the first image.
电子设备可以融合高光掩膜和色彩增强后的第一图像,至少可以提高背景区域中高光区域包含的各个第一像素点的色度分量值,从而可以对高光区域进行色彩增强,提高光源中心的色彩。The electronic device can fuse the highlight mask and the color-enhanced first image, at least to increase the chromaticity component value of each first pixel contained in the highlight area in the background area, so that the color of the highlight area can be enhanced, and the center of the light source can be improved. color.
可见,在前述实施例中,电子设备可对第一图像进行预处理,对第一图像的亮度分量值进行校正以提高图像整体的对比度,对第一图像的色度分量值进行校正以提高光源处的饱和度,在对第一图像进行虚化的同时,可以尽可能避免光斑扩散太多,并提升光源中心的色彩,使得虚化效果更加自然真实。It can be seen that, in the foregoing embodiments, the electronic device can perform preprocessing on the first image, correct the brightness component value of the first image to improve the overall contrast of the image, and correct the chrominance component value of the first image to improve the light source. Saturation at this point, while blurring the first image, it can avoid too much spread of the light spot as much as possible, and enhance the color of the center of the light source, making the blur effect more natural and real.
在前述实施例中,电子设备可将第一图像的背景区域按照光圈形状,以及不同的扩散权重以及虚化半径进行点扩散处理,使得对第一图像的虚化效果可以模拟真实的镜头模糊。扩散权重是点扩散处理的重要影响因素之一,以下内容对电子设备获取权重图的实施方式进行介绍。In the foregoing embodiments, the electronic device may perform point diffusion processing on the background area of the first image according to the shape of the aperture, and different diffusion weights and blur radii, so that the blur effect on the first image can simulate real lens blur. The diffusion weight is one of the important influencing factors of the point diffusion processing, and the following content introduces the implementation manner of obtaining the weight map by the electronic device.
在一个实施例中,电子设备可以根据第一图像的背景区域中各个第一像素点的亮度分量值计算背景区域的各个第一像素点对应的亮度权重,以得到亮度权重图。In an embodiment, the electronic device may calculate brightness weights corresponding to each first pixel in the background area according to brightness component values of each first pixel in the background area of the first image, so as to obtain a brightness weight map.
亮度权重图可包括背景区域中各个第一像素点对应的亮度权重,各个第一像素点对应的亮度权重可与各个第一像素点的亮度分量值呈正相关关系。即,第一像素点的亮度分量值越大,第一像素点对应的亮度权重越大。The brightness weight map may include brightness weights corresponding to each first pixel in the background area, and the brightness weight corresponding to each first pixel may be positively correlated with the brightness component value of each first pixel. That is, the greater the brightness component value of the first pixel, the greater the brightness weight corresponding to the first pixel.
电子设备可对背景区域中各个第一像素点的亮度分量值进行一种或多种处理,并将处理后的亮度分量值作为各个第一像素点对应的亮度权重。The electronic device may perform one or more types of processing on the brightness component values of each first pixel in the background area, and use the processed brightness component values as brightness weights corresponding to each first pixel.
在一个实施例中,电子设备可以根据第一图像的背景区域中各个第一像素点的亮度分量值和色度分量值计算背景区域的各个第一像素点对应的色度权重。In an embodiment, the electronic device may calculate the chromaticity weight corresponding to each first pixel in the background area according to the luminance component value and the chromaticity component value of each first pixel in the background area of the first image.
色度权重图可包括背景区域中各个第一像素点对应的色度权重,各个第一像素点对应的色度权重可与各个第一像素点的亮度分量值呈正相关关系,以及各个第一像素点对应的色度权重也可对各个第一像素点的色度分量值呈正相关关系。即,第一像素点的亮度分量值和色度分量值越大,第一像素点对应的色度权重越大。The chromaticity weight map may include chromaticity weights corresponding to each first pixel in the background area, the chromaticity weights corresponding to each first pixel may be positively correlated with the luminance component values of each first pixel, and each first pixel The chrominance weights corresponding to the points may also have a positive correlation with the chrominance component values of each first pixel point. That is, the larger the luminance component value and the chrominance component value of the first pixel point are, the larger the chrominance weight corresponding to the first pixel point is.
在一些实施例中,电子设备可直接将背景区域中各个第一像素点的色度分量值与亮度分量值进行叠加,将叠加分量值作为各个第一像素点对应的色度权重。或者,电子设备也先对各个第一像素点的色度分量值和亮度分量值进行一种或多种处理,并对处理后的色度分量值和/或亮度分量值进行叠加,将叠加得到的叠加分量值作为各个第一像素点对应的色度权重。In some embodiments, the electronic device may directly superimpose the chroma component value and the luminance component value of each first pixel point in the background area, and use the superimposed component value as a chroma weight corresponding to each first pixel point. Alternatively, the electronic device firstly performs one or more processes on the chroma component values and luminance component values of each first pixel, and superimposes the processed chrominance component values and/or luminance component values to obtain The value of the superimposed component of is used as the chromaticity weight corresponding to each first pixel point.
示例性的,若第一图像包括Y、U、V三个颜色通道,则电子设备可根据背景区域中各个第一像素点在Y通道的Y分量值计算各个第一像素点对应的亮度权重;以及,电子设备还可根据背景区域中各个第一像素点的Y分量值,以及各个第一像素点在U通道的U分量值和在V通道的V分量值计算各个第一像素点对应的色度权重。Exemplarily, if the first image includes three color channels of Y, U, and V, the electronic device may calculate the brightness weight corresponding to each first pixel according to the Y component value of each first pixel in the Y channel in the background area; And, the electronic device can also calculate the color corresponding to each first pixel according to the Y component value of each first pixel in the background area, and the U component value of each first pixel in the U channel and the V component value in the V channel. degree weight.
示例性的,电子设备也可以获取拍摄内容与第一图像相同的第二图像,第二图像对应的曝光值低于第一图像。即,第二图像可为第一图像的暗帧。电子设备可获取第一像素点在第二图像中的像素值作为第一像素点的亮度分量值。第二图像的整体能量较低,可以直接反映拍摄场景中的能量分布规律,以第二图像中的像素值作为亮度分量值,以生成扩散权重,有利于优化点扩散处理的扩散结果,使得虚化效果更加自然真实。Exemplarily, the electronic device may also acquire a second image whose shooting content is the same as that of the first image, and the exposure value corresponding to the second image is lower than that of the first image. That is, the second image may be a dark frame of the first image. The electronic device may acquire the pixel value of the first pixel in the second image as the brightness component value of the first pixel. The overall energy of the second image is low, which can directly reflect the energy distribution law in the shooting scene. The pixel value in the second image is used as the brightness component value to generate the diffusion weight, which is beneficial to optimize the diffusion result of point diffusion processing, making the virtual The effect is more natural and realistic.
下面对亮度权重图和色度权重图进行分别介绍。The luminance weight map and the chrominance weight map are introduced separately below.
请参阅图8,图8是一个实施例公开的一种获取亮度权重图的方法流程示意图,该方法可应用于前述的电子设备。如图8所示,该方法可包括以下步骤:Please refer to FIG. 8 . FIG. 8 is a schematic flowchart of a method for obtaining a brightness weight map disclosed by an embodiment, and the method can be applied to the aforementioned electronic device. As shown in Figure 8, the method may include the following steps:
810、将第一图像的背景区域中亮度分量值小于亮度阈值的第一像素点对应的亮度权重设置为零。810. Set, in the background area of the first image, the brightness weight corresponding to the first pixel whose brightness component value is smaller than the brightness threshold to zero.
820、根据第一图像的背景区域包含的高光区域面积,计算高光区域包含的第一像素点对应的亮度权重。820. Calculate brightness weights corresponding to the first pixels included in the highlight area according to the area of the highlight area included in the background area of the first image.
其中,高光区域包含的第一像素点的亮度分量值均大于或等于亮度阈值,亮度阈值可根据实际的业务需求设置,具体不做限定。高光区域的面积可通过高光区域包含的第一像素点的数量进行表示。Wherein, the luminance component values of the first pixels included in the highlight area are all greater than or equal to the luminance threshold, and the luminance threshold can be set according to actual service requirements, and is not specifically limited. The area of the highlight area may be represented by the number of first pixels included in the highlight area.
可选的,若高光区域的面积小于面积阈值,则电子设备可以将高光区域包含的各个第一像素点对应的亮度权重设置为零。Optionally, if the area of the highlight area is smaller than the area threshold, the electronic device may set the brightness weights corresponding to each first pixel contained in the highlight area to zero.
可选的,若高光区域的面积大于或等于面积阈值,则电子设备可以根据高光区域的面积,降低高光区域包含的各个第一像素点的亮度分量值,并将降低后的亮度分量值作为高光区域包含的各个第一像素点分别对应的亮度权重。Optionally, if the area of the highlight area is greater than or equal to the area threshold, the electronic device may reduce the brightness component value of each first pixel contained in the highlight area according to the area of the highlight area, and use the reduced brightness component value as the highlight Brightness weights corresponding to the respective first pixels included in the area.
其中,面积阈值可根据实际的业务需求设置,具体不做限定。高光区域包含的各个第一像素点的亮度分量值的降低量,与高光区域的面积呈正相关关系。即,高光区域的面积越大,高光区域中第一像素点的亮度分量值被删减(降低)得越多。通过降低大面积高光区域的亮度分量值,可以删减第一图像中密集光源区域的能量,以避免点扩散叠加后光斑堆叠导致过曝的问题。Wherein, the area threshold can be set according to actual business requirements, and is not specifically limited. The reduction amount of the luminance component value of each first pixel contained in the highlight area is positively correlated with the area of the highlight area. That is, the larger the area of the highlight area, the more the luminance component value of the first pixel in the highlight area is deleted (reduced). By reducing the brightness component value of the large-area highlight area, the energy of the dense light source area in the first image can be deleted, so as to avoid the problem of overexposure caused by spot stacking after point diffusion superposition.
在一些实施例中,第一图像的背景区域可能包括两个或以上互不连通的高光区域。由于亮度分量值的降低量与高光区域面积相关联,电子设备在执行前述的步骤920之前,可以先对各个高光区域进行膨胀,以连通相邻两个高光区域,使得距离较近的两个高光区域可以连通为一个高光区域。在对各个高光区域进行膨胀之后,电子设备可统计各个高光区域的面积,并执行前述的步骤820,以计算高光区域包含的各个第一像素点对应的亮度权重。In some embodiments, the background area of the first image may include two or more highlight areas that are not connected to each other. Since the reduction of the luminance component value is associated with the area of the highlight area, the electronic device can first expand each highlight area before performing the
可见,在前述实施例中,电子设备可删减密集光源区域的能量,避免光斑堆叠过曝。It can be seen that, in the above-mentioned embodiments, the electronic device can reduce the energy of the dense light source area to avoid stacking and overexposure of the light spots.
请参阅图9,图9是一个实施例公开的一种获取色度权重图的方法流程示意图,该方法可应用于前述的电子设备。如图9所示,该方法可包括以下步骤:Please refer to FIG. 9 . FIG. 9 is a schematic flowchart of a method for obtaining a chromaticity weight map disclosed by an embodiment, and the method can be applied to the aforementioned electronic device. As shown in Figure 9, the method may include the following steps:
910、根据背景区域中各个第一像素点的色度分量值计算各个第一像素点的色度值。910. Calculate the chroma value of each first pixel point according to the chroma component value of each first pixel point in the background area.
若色度分量值包括U通道的U分量值以及V通道的V分量值,则电子设备在叠加第一像素点的亮度分量值与色度分量值时,可先计算根据U分量值和V分量值计算色度值。If the chrominance component value includes the U component value of the U channel and the V component value of the V channel, when the electronic device superimposes the luminance component value and the chrominance component value of the first pixel, it can first calculate the The value computes the chroma value.
示例性的,色度值可通过以下公式进行计算:Exemplarily, the chromaticity value can be calculated by the following formula:
其中,chroma可为色度值,u可为U分量值,v可为V分量值。Wherein, chroma may be a chroma value, u may be a U component value, and v may be a V component value.
920、对背景区域中各个第一像素点的亮度分量值与背景区域中各个第一像素点的色度分量值进行叠加,以得到背景区域中各个第一像素点的分量叠加值。920. Superimpose the luminance component value of each first pixel point in the background area and the chrominance component value of each first pixel point in the background area to obtain component superposition values of each first pixel point in the background area.
电子设备可将背景区域中各个第一像素点的色度值与亮度分量值进行叠加,从而得到各个第一像素点的分量叠加值。The electronic device may superimpose the chrominance value and the brightness component value of each first pixel point in the background area, so as to obtain component superposition values of each first pixel point.
可选的,电子设备在对背景区域中各个第一像素点的亮度分量值与背景区域中各个第一像素点的色度值进行叠加之前,还可先对各个第一像素点的色度值进行色度拉伸。在进行色度拉伸之后,电子设备可以将背景区域中各个第一像素点的亮度分量值与拉伸后的色度值进行叠加,以得到背景区域中各个第一像素点的分量叠加值。其中,任一第一像素点的色度值的色度拉伸变化量与第一像素点的亮度分量值可呈正相关关系。即,第一像素点越亮,色度拉伸得越多。Optionally, before the electronic device superimposes the luminance component value of each first pixel in the background area and the chroma value of each first pixel in the background area, it may also first calculate the chroma value Do Chroma Stretch. After performing chromaticity stretching, the electronic device may superimpose the luminance component value of each first pixel point in the background area with the stretched chromaticity value, so as to obtain component superposition values of each first pixel point in the background area. Wherein, the chromaticity stretch variation amount of the chromaticity value of any first pixel may be positively correlated with the luminance component value of the first pixel. That is, the brighter the first pixel is, the more the chromaticity is stretched.
示例性的,可电子设备将背景区域中各个第一像素点的亮度分量值与拉伸后的色度值进行叠加,可通过以下公式进行计算:Exemplarily, the electronic device can superimpose the luminance component value of each first pixel point in the background area with the stretched chromaticity value, which can be calculated by the following formula:
其中,y3可表示叠加了亮度分量值于拉伸后得色度值之后的分量叠加值,x3可表示亮度分量值,可表示拉伸后的色度值。Among them, y3 can represent the component superposition value after superimposing the luminance component value and stretching the chroma value, and x3 can represent the luminance component value, It can represent the chromaticity value after stretching.
930、根据背景区域中各个第一像素点的分量叠加值确定背景区域中各个第一像素点对应的色度权重。930. Determine the chromaticity weight corresponding to each first pixel in the background area according to the component superposition value of each first pixel in the background area.
可选的,电子设备可直接将背景区域中各个第一像素点的分量叠加值确定为背景区域中各个第一像素点对应的色度权重。Optionally, the electronic device may directly determine the component superposition value of each first pixel point in the background area as the chromaticity weight corresponding to each first pixel point in the background area.
可选的,电子设备执行步骤920还可包括以下步骤:Optionally, the electronic
电子设备对背景区域中各个第一像素点的亮度分量值进行亮度拉伸,得到背景区域中各个第一像素点拉伸后的亮度分量值。The electronic device performs brightness stretching on the brightness component values of each first pixel point in the background area to obtain the stretched brightness component value of each first pixel point in the background area.
其中,背景区域中各个第一像素点的亮度拉伸变化量与背景区域中各个第一像素点拉伸前的亮度分量值呈正相关关系。也就是说,背景区域中的第一像素点拉伸前的Wherein, the brightness stretching variation of each first pixel in the background area is positively correlated with the brightness component value of each first pixel in the background area before stretching. That is to say, the first pixel in the background area before stretching
示例性的,电子设备可通过前述的公式(6)对背景区域中各个第一像素点的亮度分量值进行亮度拉伸。也就是说,电子设备在对各个第一像素点进行亮度拉伸之后,可以得到第一图像的高光掩膜,高光掩膜至少可包括背景区域中各个第一像素点拉伸后的亮度分量值,可用于指示背景区域中的高光区域。Exemplarily, the electronic device may perform luminance stretching on the luminance component values of each first pixel in the background area by using the aforementioned formula (6). That is to say, after stretching the brightness of each first pixel, the electronic device can obtain a highlight mask of the first image, and the highlight mask can at least include the stretched brightness component value of each first pixel in the background area , which can be used to indicate highlight areas in background areas.
针对背景区域中的每个第一像素点,电子设备可将第一像素点的分量叠加值与第一像素点拉伸后的亮度分量值进行比对,将比对出的最大值确定为第一像素点对应的色度权重。For each first pixel in the background area, the electronic device can compare the component superposition value of the first pixel with the stretched luminance component value of the first pixel, and determine the maximum value obtained from the comparison as the first pixel. The chroma weight corresponding to a pixel.
电子设备将比对出的最大值确定为第一像素点对应的色度权重,可以增强色度较高和/或亮度较高的第一像素点对应的色度权重,是的光斑可以扩散更多色彩,增强了虚化效果中的光斑色彩。The electronic device determines the maximum value of the comparison as the chromaticity weight corresponding to the first pixel point, which can enhance the chromaticity weight corresponding to the first pixel point with higher chromaticity and/or higher brightness, and yes, the light spot can spread more. Multi-color, enhances the spot color in the bokeh effect.
可见,在前述实施例中,色度分量值较高的第一像素点对应的色度权重较高,高光区域中的第一像素点对应的色度权重也较高,从而可以使得亮度较高的光斑扩散更多色彩,有利于增强虚化效果中的光斑色彩。It can be seen that in the foregoing embodiments, the first pixel with a higher chroma component value corresponds to a higher chroma weight, and the chroma weight corresponding to the first pixel in the highlight area is also higher, so that the brightness can be made higher The light spots diffuse more colors, which is beneficial to enhance the color of the light spots in the blur effect.
在一些实施例中,电子设备在从权重图中获取出背景区域的各个第一像像素点对应的扩散权重之后,以及在利用对应的扩散权重对第一像素点进行点扩散处理之前,还可以先对根据权重映射曲线对第一像素点对应的扩散权重进行映射,得到第一像素点映射后的扩散权重。In some embodiments, after the electronic device obtains the diffusion weights corresponding to each first image pixel point in the background area from the weight map, and before performing point diffusion processing on the first pixel points using the corresponding diffusion weights, the electronic device may also Firstly, the diffusion weight corresponding to the first pixel point is mapped according to the weight mapping curve to obtain the diffusion weight after the mapping of the first pixel point.
电子设备可利用第一像素点映射后的扩散权重对第一像素点进行点扩散处理。也就是说,电子设备可以根据第一像素点在第一图像中的像素值、第一像素点映射后的扩散权重以及第一光圈核计算第一像素点对应的扩散范围内各个第二像素点的目标像素值。以及,电子设备可以根据第一像素点映射后的扩散权重以及第一光圈核计算第一像素点对应的扩散范围内各个像素点的扩散次数。The electronic device may perform point diffusion processing on the first pixel by using the diffusion weight after the mapping of the first pixel. That is to say, the electronic device can calculate the value of each second pixel within the diffusion range corresponding to the first pixel according to the pixel value of the first pixel in the first image, the diffusion weight after the mapping of the first pixel, and the first aperture kernel. The target pixel value of . And, the electronic device may calculate the diffusion times of each pixel within the diffusion range corresponding to the first pixel according to the diffusion weight after the mapping of the first pixel and the first aperture kernel.
若扩散权重包括亮度权重和色度权重,则电子设备可根据权重映射曲线分别对亮度权重和色度权重进行映射。If the diffusion weights include luminance weights and chrominance weights, the electronic device may map the luminance weights and chrominance weights respectively according to the weight mapping curve.
上述的权重映射曲线可融合第一曲线及第二曲线得到。其中,第一曲线可为全局平滑曲线,第二曲线可为以第一亮度等级为中心进行拉伸的局部平滑曲线。第一亮度等级可根据实际的业务需求设置,例如可为90%-100%的亮度等级中的任意一个数值。The above weight mapping curve can be obtained by fusing the first curve and the second curve. Wherein, the first curve may be a global smooth curve, and the second curve may be a local smooth curve stretched around the first brightness level. The first brightness level can be set according to actual service requirements, for example, it can be any value among the brightness levels of 90%-100%.
示例性的,第一曲线可通过以下公式进行表示:Exemplarily, the first curve can be represented by the following formula:
其中,y4可表示映射后的扩散权重,x4可表示映射前的扩散权重。Wherein, y4 may represent the diffusion weight after mapping, and x4 may represent the diffusion weight before mapping.
从公式(9)中可以看出,第一曲线是在0-255之间全局平滑过渡的曲线。It can be seen from formula (9) that the first curve is a curve with a global smooth transition between 0-255.
示例性的,第二曲线可通过以下公式进行表示:Exemplarily, the second curve can be represented by the following formula:
其中,y5可表示映射后的扩散权重,x5可表示映射前的扩散权重。Wherein, y5 may represent the diffusion weight after mapping, and x5 may represent the diffusion weight before mapping.
从公式(10)中可以看出,第二曲线是以95%为中心的局部平滑sigmoid曲线。It can be seen from formula (10) that the second curve is a locally smooth sigmoid curve centered at 95%.
电子设备可融合第一曲线和第二曲线以得到权重映射曲线。The electronic device may fuse the first curve and the second curve to obtain a weight mapping curve.
示例性的,权重映射曲线可以通过以下公式进行表示:Exemplarily, the weight mapping curve can be expressed by the following formula:
y6=α·y4+(1-α)·y5,α∈[0.2,0.4]; 公式(11)y6=α·y4+(1-α)·y5,α∈[0.2,0.4]; Formula (11)
其中,y6可表示权重映射曲线,y4可表示公式(9)所示的第一曲线,y5可表示公式(10)所示的第二曲线。Wherein, y6 may represent the weight mapping curve, y4 may represent the first curve shown in formula (9), and y5 may represent the second curve shown in formula (10).
请参阅图10,图10是一个实施例公开的一种第一曲线、第二曲线和权重映射曲线的示例图。如图10所示,第一曲线1010全局平滑,第二曲线1020局部平滑,权重映射曲线1030融合第一曲线1010和第二曲线1020的特点,既符合光源能量分布又过渡自然,并且在不同的亮度层级可以错开形成亮度阶梯,使得亮度分量值处于不同亮度等级的第一像素点分别对应的扩散权重存在较为明显的差异,有利于优化虚化效果中光斑整体的层次通透感。Please refer to FIG. 10 . FIG. 10 is an example diagram of a first curve, a second curve and a weight mapping curve disclosed by an embodiment. As shown in Figure 10, the
在一些实施例中,虚化效果需要进一步提亮光斑,可能需要进一步提高高亮像素点对应的扩散权重。电子设备可对权重映射曲线进行优化,提升权重映射曲线后半段的权重。In some embodiments, the blurring effect needs to further brighten the light spots, and it may be necessary to further increase the diffusion weight corresponding to the highlighted pixels. The electronic device can optimize the weight mapping curve, and increase the weight of the second half of the weight mapping curve.
示例性的,优化后的权重映射曲线可以通过以下公式进行表示:Exemplarily, the optimized weight mapping curve can be expressed by the following formula:
y7=y7·(L-(255-x)),x∈(255-L,255]; 公式(13)y7=y7·(L-(255-x)), x∈(255-L, 255]; formula (13)
其中,y7可表示优化后的权重映射曲线,Brightness可表示输入的亮度参数,可根据实际业务需求设置,ApertureSize可表示第一像素点的虚化半径。Among them, y7 can represent the optimized weight mapping curve, Brightness can represent the input brightness parameter, which can be set according to actual business requirements, and ApertureSize can represent the blur radius of the first pixel.
利用优化后的权重映射曲线进行扩散权重映射,有利于在虚化效果中进一步提亮光斑,提高光斑整体的层次通透感。Using the optimized weight mapping curve for diffusion weight mapping is beneficial to further brighten the light spots in the blur effect and improve the overall layered transparency of the light spots.
请参阅图11,图11是一个实施例公开的一种图像处理方法的流程示意图,该方法可应用于前述的电子设备。如图11所示,该方法可包括以下步骤:Please refer to FIG. 11 . FIG. 11 is a schematic flowchart of an image processing method disclosed by an embodiment, which can be applied to the aforementioned electronic device. As shown in Figure 11, the method may include the following steps:
1110、生成第一图像对应的虚化力度图,并根据虚化力度图生成第一图像的背景掩膜。1110. Generate a blur intensity map corresponding to the first image, and generate a background mask of the first image according to the blur intensity map.
电子设备可根据第一图像全图的深度信息生成第一图像对应的虚化力度图,并可利用第一图像对应的虚化力度图生成背景掩膜。The electronic device can generate a blur intensity map corresponding to the first image according to the depth information of the full image of the first image, and can generate a background mask by using the blur intensity map corresponding to the first image.
1120、对第一图像进行预处理。1120. Perform preprocessing on the first image.
电子设备对第一图像进行预处理,可包括:降低第一图像背景区域中各个第一像素点的亮度分量值;以及,提高第一图像背景区域中高光区域包含的各个第一像素点的色度分量值,以对高光区域进行色彩增强。The electronic device preprocessing the first image may include: reducing the brightness component value of each first pixel in the background area of the first image; and increasing the color of each first pixel contained in the highlight area in the background area of the first image. Degrees component value to apply color enhancement to highlight areas.
生成第一图像对应的权重图。A weight map corresponding to the first image is generated.
电子设备可根据第一图像全图各个像素点的亮度分量值和色度分量值计算各个像素点的扩散权重,从而生成第一图像对应的权重图。The electronic device may calculate the diffusion weight of each pixel according to the luminance component value and the chrominance component value of each pixel in the full image of the first image, so as to generate a weight map corresponding to the first image.
其中,权重图可包括亮度权重图和色度权重图。亮度权重图可根据第一图像全图各个像素点的亮度分量值进行计算得到,色度权重图可根据第一图像全图各个像素点的亮度分量值和色度分量值进行计算得到。Wherein, the weight map may include a luma weight map and a chroma weight map. The luminance weight map can be calculated based on the luminance component values of each pixel in the full first image, and the chrominance weight map can be calculated based on the luminance component values and chrominance component values of each pixel in the full first image.
在生成亮度权重图时,电子设备可以删减大面积高光区域的能量,从而降低大面积高光区域内的第一像素点的亮度权重。When generating the brightness weight map, the electronic device may delete the energy of the large-area high-light area, thereby reducing the brightness weight of the first pixel in the large-area high-light area.
在生成色度权重图时,电子设备可以增加亮度分量值和/或色度分量值较高的第一像素点对应的色度权重。When generating the chromaticity weight map, the electronic device may increase the chromaticity weight corresponding to the first pixel with higher luminance component value and/or chrominance component value.
遍历背景掩膜指示的第一图像背景区域中的每个第一像素点,从第一图像对应的权重图和虚化力度图中获取与第一像素点对应的扩散权重以及虚化半径。Each first pixel in the background area of the first image indicated by the background mask is traversed, and the diffusion weight and blur radius corresponding to the first pixel are obtained from the weight map and the blur strength map corresponding to the first image.
1150、根据权重映射曲线对第一像素点对应的扩散权重进行映射,得到第一像素点映射后的扩散权重。1150. Map the diffusion weight corresponding to the first pixel point according to the weight mapping curve to obtain the diffusion weight after the mapping of the first pixel point.
1160、根据光圈形状参数、第一图像对应的虚化力度图和权重图,对背景掩膜指示的第一图像的的背景区域中的各个第一像素点进行点扩散处理,得到背景区域中各个第一像素点对应的扩散结果。1160. According to the aperture shape parameter, the blur intensity map and the weight map corresponding to the first image, perform point diffusion processing on each first pixel point in the background area of the first image indicated by the background mask, and obtain each pixel in the background area. Diffusion result corresponding to the first pixel.
1170、对背景区域中各个第一像素点对应的扩散结果进行叠加,并根据叠加结果对背景区域进行虚化。1170. Superimpose the diffusion results corresponding to each first pixel in the background area, and blur the background area according to the superposition results.
可见,在前述实施例中,电子设备可生成背景掩膜,以指示需要进行点扩散处理的背景区域的范围,从而可以对背景区域包含的各个第一像素点均进行点扩散处理,使得亮点形成高亮的光斑,暗点形成朦胧的弥散圆。电子设备还可以在点扩散处理之前对第一图像进行预处理,压低背景区域的亮度以提升第一图像整体的对比度,同时对高光区域进行色彩增强,提升光源处的饱和度。扩散权重是影响点扩散处理的重要因素,在生成亮度权重图时,电子设备删减大面积高光区域的能量,降低大面积高光区域内的第一像素点的亮度权重,可以避免光斑堆叠过曝;在生成色度权重图时,电子设备可以增加亮度分量值和/或色度分量值较高的第一像素点对应的色度权重,使得光斑可以扩散更多色彩。电子设备还可进一步通过符合光源能量分布且过渡自然的权重映射曲线,对从权重图中获取到的扩散权重进行映射,从而可以优化虚化效果中光斑整体的层次通透感。电子设备还可根据不同的光圈形状参数模拟不同镜头的光圈形状,使得虚化效果中光斑的形状更加多变。It can be seen that, in the foregoing embodiments, the electronic device can generate a background mask to indicate the range of the background area that needs to be subjected to dot diffusion processing, so that the dot diffusion processing can be performed on each first pixel contained in the background area, so that the bright spots are formed Highlighted light spots, dark spots form hazy diffuse circles. The electronic device can also preprocess the first image before dot diffusion processing, reduce the brightness of the background area to improve the overall contrast of the first image, and at the same time enhance the color of the highlight area to increase the saturation of the light source. Diffusion weight is an important factor affecting point diffusion processing. When generating the brightness weight map, the electronic device deletes the energy of the large-area highlight area and reduces the brightness weight of the first pixel in the large-area highlight area, which can avoid the overexposure of the spot stack. ; When generating the chromaticity weight map, the electronic device may increase the chromaticity weight corresponding to the first pixel with higher luminance component value and/or chrominance component value, so that the light spot can spread more colors. The electronic device can further map the diffusion weight obtained from the weight map through a weight mapping curve that conforms to the energy distribution of the light source and has a natural transition, so as to optimize the overall layered transparency of the light spot in the blur effect. The electronic device can also simulate the aperture shape of different lenses according to different aperture shape parameters, so that the shape of the light spot in the blur effect is more variable.
请参阅图12,图12是一个实施例公开的一种图像处理装置的结构示意图。图12所示的图像处理装置可应用于前述的任一电子设备,如图12所示,图像处理装置1200可包括:获取模块1210、扩散模块1220、虚化模块1230。Please refer to FIG. 12 . FIG. 12 is a schematic structural diagram of an image processing device disclosed in an embodiment. The image processing apparatus shown in FIG. 12 may be applied to any of the aforementioned electronic devices. As shown in FIG. 12 , the
获取模块1210,用于获取光圈形状参数,以及获取第一图像对应的虚化力度图及权重图,虚化力度图至少包括第一图像的背景区域中各个第一像素点分别对应的虚化半径,权重图至少包括第一图像的背景区域中各个第一像素点分别对应的扩散权重;The acquiring
扩散模块1220,用于根据光圈形状参数、虚化力度图及权重图,对第一图像的背景区域中的各个第一像素点进行点扩散处理,得到各个第一像素点对应的扩散结果;The
叠加虚化模块1230,用于对背景区域中各个第一像素点对应的扩散结果进行叠加,并根据叠加结果对背景区域进行虚化。The
在一个实施例中,背景区域中的每个第一像素点对应的扩散结果包括:第一像素点对应的扩散范围、处于扩散范围内的各个第二像素点的目标像素值,以及处于扩散范围内的各个第二像素点的扩散次数;其中,第一像素点对应的扩散范围以第一像素点为中心,扩散范围的外接圆的半径为第一像素点对应的虚化半径,扩散范围的外轮廓为光圈形状参数指示的光圈形状。In one embodiment, the diffusion result corresponding to each first pixel point in the background area includes: the diffusion range corresponding to the first pixel point, the target pixel value of each second pixel point within the diffusion range, and the target pixel value of each second pixel point within the diffusion range Diffusion times of each second pixel within ; Wherein, the diffusion range corresponding to the first pixel is centered on the first pixel, the radius of the circumscribed circle of the diffusion range is the blur radius corresponding to the first pixel, and the diffusion range The outer contour is the shape of the aperture indicated by the aperture shape parameter.
在一个实施例中,扩散模块1220,可包括:第一获取单元、第一扩散单元和第二扩散单元。In one embodiment, the
第一获取单元,可用于针对第一图像的背景区域中的每个第一像素点,从虚化力度图中获取与第一像素点对应的虚化半径,以及从权重图中获取与第一像素点对应的扩散权重;以及,根据第一像素点对应的虚化半径以及光圈形状参数确定与第一像素点对应的第一光圈核,第一光圈核用于指示第一像素点的扩散范围;The first obtaining unit is configured to obtain, for each first pixel in the background area of the first image, the blur radius corresponding to the first pixel from the blur strength map, and obtain the blur radius corresponding to the first pixel from the weight map. The diffusion weight corresponding to the pixel point; and, according to the blur radius corresponding to the first pixel point and the aperture shape parameter, determine the first aperture kernel corresponding to the first pixel point, and the first aperture kernel is used to indicate the diffusion range of the first pixel point ;
第一扩散单元,可用于根据第一像素点在第一图像中的像素值、第一像素点对应的扩散权重以及第一光圈核计算第一像素点对应的扩散范围内各个第二像素点的目标像素值;The first diffusion unit can be used to calculate the value of each second pixel in the diffusion range corresponding to the first pixel according to the pixel value of the first pixel in the first image, the diffusion weight corresponding to the first pixel, and the first aperture kernel. target pixel value;
第二扩散单元,可用于根据第一像素点对应的扩散权重以及第一光圈核计算第一像素点对应的扩散范围内各个第二像素点的扩散次数。The second diffusion unit is configured to calculate the number of diffusion times of each second pixel within the diffusion range corresponding to the first pixel according to the diffusion weight corresponding to the first pixel and the first aperture kernel.
在一个实施例中,叠加虚化模块1230,可包括:叠加单元、虚化单元。In one embodiment, the
叠加单元,可用于将背景区域中各个第一像素点对应的扩散范围包含的各个第二像素点的目标像素值叠加至像素值叠加图,并将背景区域中各个第一像素点对应的扩散范围包含的各个第二像素点的扩散次数叠加至次数统计图;The superposition unit can be used to superimpose the target pixel value of each second pixel contained in the diffusion range corresponding to each first pixel in the background area to the pixel value superimposition map, and the diffusion range corresponding to each first pixel in the background area The number of diffusions of each included second pixel point is superimposed on the number statistics graph;
虚化单元,可用于根据背景区域中各个第一像素点在叠加后的像素值叠加图中的像素值,以及各个第一像素点在叠加后的次数统计图中的扩散总数,对各个第一像素点进行虚化。The blurring unit can be used to calculate each first pixel according to the pixel value of each first pixel in the superimposed pixel value superposition map in the background area, and the total number of diffusions of each first pixel in the superimposed times statistics map. Pixels are blurred.
在一个实施例中,图像处理装置1200还可包括:背景确定模块。In one embodiment, the
背景确定模块,可用于根据第一图像的虚化力度图在第一图像中移除人像区域;以及,根据头发掩膜在移除了人像区域的第一图像中移除头发区域,以得到第一图像的背景掩膜。The background determination module can be used to remove the portrait area in the first image according to the blur intensity map of the first image; and remove the hair area in the first image from which the portrait area has been removed according to the hair mask, so as to obtain the first A background mask for an image.
可选的,背景确定模块,还可用于在第一图像中移除人像区域之前,先腐蚀虚化力度图,以扩张人像区域的范围。其中,虚化力度图中每个像素点对应的腐蚀半径可与每个像素点对应的虚化半径呈正相关关系。以及,还可用于根据人像区域扩张后的虚化力度图在第一图像中移除人像区域。Optionally, the background determination module may be further configured to erode the blur intensity map before removing the portrait area in the first image, so as to expand the range of the portrait area. Wherein, the erosion radius corresponding to each pixel in the blur strength map may be positively correlated with the blur radius corresponding to each pixel. And, it can also be used to remove the portrait area in the first image according to the blur strength map after the expansion of the portrait area.
可选的,背景确定模块,还可用于在移除头发区域之前,可以先统计头发掩膜中头发外轮廓的面积,根据头发外轮廓的面积比例计算膨胀半径,再根据头发外轮廓像素点的虚化半径增大膨胀半径;以及,还可用于根据膨胀半径对头发掩膜进行膨胀,以扩张头发区域;以及,还可用于增加头发掩膜中像素点的置信度,以增加被识别为头发的像素点数量,从而进一步扩张头发区域。其中,头发区域外轮廓的面积可指头发区域外轮廓包含的像素点数量,虚化半径和膨胀半径的增加量可呈正相关关系。Optionally, the background determination module can also be used to count the area of the hair outer contour in the hair mask before removing the hair region, calculate the expansion radius according to the area ratio of the hair outer contour, and then calculate the expansion radius according to the pixel points of the hair outer contour The blur radius increases the expansion radius; and, it can also be used to expand the hair mask according to the expansion radius to expand the hair area; and, it can also be used to increase the confidence of the pixels in the hair mask to increase the recognition as hair The number of pixels to further expand the hair area. Wherein, the area of the outer contour of the hair region may refer to the number of pixels included in the outer contour of the hair region, and the increase of the blur radius and the expansion radius may be positively correlated.
背景确定模块,还可用在移除了人像区域的第一图像中,减去头发掩膜扩张后的头发区域,以得到第一图像的背景掩膜。The background determination module can also be used in the first image from which the portrait area is removed, to subtract the expanded hair area of the hair mask to obtain the background mask of the first image.
在一个实施例中,图像处理装置1200还可包括:预处理模块。In one embodiment, the
预处理模块,可用于降低第一图像背景区域中各个第一像素点的亮度分量值。其中,第一像素点的亮度分量值的降低量,可与第一图像拍摄场景的亮度呈正相关关系。The preprocessing module can be used to reduce the brightness component value of each first pixel in the background area of the first image. Wherein, the reduction amount of the brightness component value of the first pixel point may have a positive correlation with the brightness of the shooting scene of the first image.
示例性的,预处理模块可用于计算用于亮度压暗的Gamma参数,并基于计算出的Gamma参数对各个第一像素点的亮度分量值进行曲线映射拉伸,以降低第一像素点的亮度分量值。Exemplarily, the preprocessing module can be used to calculate the Gamma parameter for brightness reduction, and perform curve mapping and stretching on the brightness component value of each first pixel point based on the calculated Gamma parameter, so as to reduce the brightness of the first pixel point component value.
预处理模块,还可用于提高第一图像背景区域中高光区域包含的各个第一像素点的色度分量值,以对高光区域进行色彩增强,提高光源中心的色彩。其中,高光区域包含的第一像素点的色度分量的增加量,可与第一图像拍摄场景的亮度呈负相关关系。The preprocessing module can also be used to increase the chromaticity component value of each first pixel contained in the highlight area in the background area of the first image, so as to enhance the color of the highlight area and improve the color of the center of the light source. Wherein, the increase amount of the chrominance component of the first pixel contained in the highlight area may have a negative correlation with the brightness of the first image shooting scene.
示例性的,预处理模块可用于对第一图像的色度分量值进行模糊;以及,根据饱和度参数计算用于进行色彩增强的Gamma参数,并利用计算出的Gamma参数参数对第一图像全图进行色彩增强,得到色彩增强后的第一图像;以及,计算第一图像的高光掩膜;以及,根据色彩增强后的第一图像以及第一图像的高光掩膜,对第一图像的高光区域进行色彩增强。Exemplarily, the preprocessing module may be used to blur the chrominance component value of the first image; and, calculate a Gamma parameter for color enhancement according to the saturation parameter, and use the calculated Gamma parameter parameter to fully optimize the first image The image is color enhanced to obtain the first image after color enhancement; and, calculate the highlight mask of the first image; and, according to the first image after color enhancement and the highlight mask of the first image, the highlight of the first image is calculated Areas are color enhanced.
在一个实施例中,获取模块1210,可包括:亮度权重生成单元、色度权重生成单元。In one embodiment, the acquiring
亮度权重生成单元,可用于根据第一图像的背景区域中各个第一像素点的亮度分量值计算背景区域的各个第一像素点对应的亮度权重,以得到亮度权重图。其中,亮度权重图可包括背景区域中各个第一像素点对应的亮度权重,各个第一像素点对应的亮度权重可与各个第一像素点的亮度分量值呈正相关关系。The luminance weight generation unit is configured to calculate the luminance weight corresponding to each first pixel in the background area of the first image according to the luminance component value of each first pixel in the background area of the first image, so as to obtain a luminance weight map. Wherein, the brightness weight map may include brightness weights corresponding to each first pixel point in the background area, and the brightness weight corresponding to each first pixel point may be positively correlated with the brightness component value of each first pixel point.
色度权重生成单元,可用于根据第一图像的背景区域中各个第一像素点的亮度分量值和色度分量值计算背景区域的各个第一像素点对应的色度权重。其中,色度权重图可包括背景区域中各个第一像素点对应的色度权重,各个第一像素点对应的色度权重可与各个第一像素点的亮度分量值呈正相关关系,以及各个第一像素点对应的色度权重也可对各个第一像素点的色度分量值呈正相关关系。The chromaticity weight generating unit may be configured to calculate the chromaticity weight corresponding to each first pixel in the background area of the first image according to the luminance component value and the chrominance component value of each first pixel in the background area of the first image. Wherein, the chromaticity weight map may include chromaticity weights corresponding to each first pixel point in the background area, the chromaticity weights corresponding to each first pixel point may have a positive correlation with the luminance component value of each first pixel point, and each first pixel point The chroma weight corresponding to a pixel may also be positively correlated with the chroma component values of each first pixel.
在一个实施例中,亮度权重生成单元,还可用于将第一图像的背景区域中亮度分量值小于亮度阈值的第一像素点对应的亮度权重设置为零;以及,根据第一图像的背景区域包含的高光区域面积,计算高光区域包含的第一像素点对应的亮度权重。In one embodiment, the luminance weight generation unit is further configured to set the luminance weight corresponding to the first pixel point whose luminance component value is smaller than the luminance threshold in the background area of the first image to zero; and, according to the background area of the first image The included highlight area area, calculate the brightness weight corresponding to the first pixel contained in the highlight area.
可选的,亮度权重生成单元,还可用于在高光区域的面积小于面积阈值时,将高光区域包含的各个第一像素点对应的亮度权重设置为零;和/或,在高光区域的面积大于或等于面积阈值时,根据高光区域的面积,降低高光区域包含的各个第一像素点的亮度分量值,并将降低后的亮度分量值作为高光区域包含的各个第一像素点分别对应的亮度权重。其中,高光区域包含的各个第一像素点的亮度分量值的降低量,与高光区域的面积呈正相关关系。Optionally, the brightness weight generating unit can also be used to set the brightness weight corresponding to each first pixel contained in the highlight region to zero when the area of the highlight region is smaller than the area threshold; and/or, when the area of the highlight region is larger than or equal to the area threshold, according to the area of the highlight area, reduce the brightness component value of each first pixel contained in the highlight area, and use the reduced brightness component value as the brightness weight corresponding to each first pixel contained in the highlight area . Wherein, the reduction amount of the luminance component value of each first pixel contained in the highlight area is positively correlated with the area of the highlight area.
在一个实施例中,亮度权重生成单元,还可用于在背景区域可包括两个或以上互不连通的高光区域时,先对各个高光区域进行膨胀,以连通邻近的高光区域。In one embodiment, the luminance weight generating unit is further configured to firstly expand each highlight region to connect adjacent highlight regions when the background region may include two or more highlight regions that are not connected to each other.
在一个实施例中,色度权重生成单元,还可用于根据背景区域中各个第一像素点的色度分量值计算各个第一像素点的色度值;以及,对背景区域中各个第一像素点的亮度分量值与背景区域中各个第一像素点的色度分量值进行叠加,以得到背景区域中各个第一像素点的分量叠加值;以及,根据背景区域中各个第一像素点的分量叠加值确定背景区域中各个第一像素点对应的色度权重。In one embodiment, the chromaticity weight generating unit is further configured to calculate the chromaticity value of each first pixel point in the background area according to the chromaticity component value of each first pixel point in the background area; and, for each first pixel in the background area The brightness component value of the point is superimposed with the chrominance component value of each first pixel point in the background area to obtain the component superposition value of each first pixel point in the background area; and, according to the component of each first pixel point in the background area The superposition value determines the chromaticity weight corresponding to each first pixel point in the background area.
可选的,色度权重生成单元,还可用于在对背景区域中各个第一像素点的亮度分量值与背景区域中各个第一像素点的色度值进行叠加之前,先对各个第一像素点的色度值进行色度拉伸;以及,在进行色度拉伸之后,将背景区域中各个第一像素点的亮度分量值与拉伸后的色度值进行叠加,以得到背景区域中各个第一像素点的分量叠加值。Optionally, the chromaticity weight generating unit may also be used to firstly calculate The chromaticity value of the point is stretched; and, after the chromaticity stretching, the luminance component value of each first pixel point in the background area is superimposed with the stretched chromaticity value to obtain the chromaticity value in the background area The component superposition value of each first pixel point.
其中,任一第一像素点的色度值的色度拉伸变化量与第一像素点的亮度分量值可呈正相关关系。Wherein, the chromaticity stretch variation amount of the chromaticity value of any first pixel may be positively correlated with the luminance component value of the first pixel.
可选的,色度权重生成单元,还可用于对背景区域中各个第一像素点的亮度分量值进行亮度拉伸,得到背景区域中各个第一像素点拉伸后的亮度分量值;以及,将第一像素点的分量叠加值与第一像素点拉伸后的亮度分量值进行比对,将比对出的最大值确定为第一像素点对应的色度权重。Optionally, the chromaticity weight generating unit may also be used to perform brightness stretching on the brightness component values of each first pixel point in the background area to obtain the stretched brightness component values of each first pixel point in the background area; and, The component superposition value of the first pixel is compared with the stretched luminance component value of the first pixel, and the maximum value obtained from the comparison is determined as the chromaticity weight corresponding to the first pixel.
其中,背景区域中各个第一像素点的亮度拉伸变化量与背景区域中各个第一像素点拉伸前的亮度分量值呈正相关关系。Wherein, the brightness stretching variation of each first pixel in the background area is positively correlated with the brightness component value of each first pixel in the background area before stretching.
在一个实施例中,图像处理装置1200还可包括:权重映射模块。In one embodiment, the
权重映射模块,可用于根据权重映射曲线对第一像素点对应的扩散权重进行映射,得到第一像素点映射后的扩散权重。其中,权重映射曲线可融合第一曲线及第二曲线得到,第一曲线可为全局平滑曲线,第二曲线可为以第一亮度等级为中心进行拉伸的局部平滑曲线。The weight mapping module may be configured to map the diffusion weight corresponding to the first pixel point according to the weight mapping curve to obtain the diffusion weight after the mapping of the first pixel point. Wherein, the weight mapping curve can be obtained by fusing the first curve and the second curve, the first curve can be a global smooth curve, and the second curve can be a local smooth curve stretched around the first brightness level.
相应地,扩散模块1220包括的第一扩散单元,还可用于根据第一像素点在第一图像中的像素值、第一像素点映射后的扩散权重以及第一光圈核计算第一像素点对应的扩散范围内各个第二像素点的目标像素值。Correspondingly, the first diffusion unit included in the
扩散模块1220包括的第二扩散单元,还可用于根据第一像素点映射后的扩散权重以及第一光圈核计算第一像素点对应的扩散范围内各个像素点的扩散次数。The second diffusion unit included in the
可见,实施前述实施例中的图像处理装置,可以对背景区域包含的各个第一像素点均进行点扩散处理,使得亮点形成高亮的光斑,暗点形成朦胧的弥散圆。以及,在点扩散处理之前对第一图像进行预处理,压低背景区域的亮度以提升第一图像整体的对比度,同时对高光区域进行色彩增强,提升光源处的饱和度。以及,还可删减大面积高光区域的能量,降低大面积高光区域内的第一像素点的亮度权重,可以避免光斑堆叠过曝,增加亮度分量值和/或色度分量值较高的第一像素点对应的色度权重,使得光斑可以扩散更多色彩。以及,还可利用符合光源能量分布且过渡自然的权重映射曲线,对从权重图中获取到的扩散权重进行映射,从而可以优化虚化效果中光斑整体的层次通透感。以及,可根据不同的光圈形状参数模拟不同镜头的光圈形状,使得虚化效果中光斑的形状更加多变。综上,图像处理装置可以使得虚化效果更加真实自然。It can be seen that, implementing the image processing device in the foregoing embodiments, the dot diffusion process can be performed on each first pixel in the background area, so that the bright spots form bright spots and the dark spots form hazy circles of confusion. And, the first image is preprocessed before the point diffusion processing, the brightness of the background area is reduced to improve the overall contrast of the first image, and the color of the highlight area is enhanced to increase the saturation of the light source. And, the energy of the large-area highlight area can also be deleted, and the brightness weight of the first pixel in the large-area highlight area can be reduced, which can avoid stacking and overexposure of the spots, and increase the value of the first pixel with a higher brightness component value and/or chrominance component value. The chromaticity weight corresponding to a pixel makes the light spot diffuse more colors. Moreover, the diffusion weight obtained from the weight map can also be mapped by using a weight mapping curve that conforms to the energy distribution of the light source and has a natural transition, so that the overall layered transparency of the light spot in the blur effect can be optimized. And, the aperture shape of different lenses can be simulated according to different aperture shape parameters, making the shape of the spot in the blur effect more variable. In summary, the image processing device can make the blurring effect more realistic and natural.
请参阅图13,图13是本申请实施例公开的一种电子设备的结构示意图。如图13所示,该电子设备1300可以包括:Please refer to FIG. 13 . FIG. 13 is a schematic structural diagram of an electronic device disclosed in an embodiment of the present application. As shown in Figure 13, the
存储有可执行程序代码的存储器1310;a
与存储器1310耦合的处理器1320;
其中,处理器1320调用存储器1310中存储的可执行程序代码,执行本申请实施例公开的任意一种图像处理方法。Wherein, the
需要说明的是,图13所示的移动终端还可以包括电源、输入按键、摄像头、扬声器、屏幕、RF电路、Wi-Fi模块、蓝牙模块、传感器等未显示的组件,本实施例不作赘述。It should be noted that the mobile terminal shown in FIG. 13 may also include components not shown, such as power supply, input buttons, camera, speaker, screen, RF circuit, Wi-Fi module, Bluetooth module, sensor, etc., which will not be described in detail in this embodiment.
本申请实施例公开一种计算机可读存储介质,其存储计算机程序,其中,该计算机程序被处理器执行时实现本申请实施例公开的任意一种图像处理方法。The embodiment of the present application discloses a computer-readable storage medium, which stores a computer program, wherein, when the computer program is executed by a processor, any image processing method disclosed in the embodiment of the present application is implemented.
本申请实施例公开一种计算机程序产品,该计算机程序产品包括存储了计算机程序的非瞬时性计算机可读存储介质,且该计算机程序可操作来使计算机执行本申请实施例公开的任意一种图像处理方法。The embodiment of the present application discloses a computer program product, the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause the computer to execute any image disclosed in the embodiment of the present application Approach.
应理解,说明书通篇中提到的“一个实施例”或“一实施例”意味着与实施例有关的特定特征、结构或特性包括在本申请的至少一个实施例中。因此,在整个说明书各处出现的“在一个实施例中”或“在一实施例中”未必一定指相同的实施例。此外,这些特定特征、结构或特性可以以任意适合的方式结合在一个或多个实施例中。本领域技术人员也应该知悉,说明书中所描述的实施例均属于可选实施例,所涉及的动作和模块并不一定是本申请所必须的。It should be understood that reference throughout the specification to "one embodiment" or "an embodiment" means that a particular feature, structure, or characteristic related to the embodiment is included in at least one embodiment of the present application. Thus, appearances of "in one embodiment" or "in an embodiment" in various places throughout the specification are not necessarily referring to the same embodiment. Furthermore, the particular features, structures or characteristics may be combined in any suitable manner in one or more embodiments. Those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by this application.
在本申请的各种实施例中,应理解,上述各过程的序号的大小并不意味着执行顺序的必然先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。In various embodiments of the present application, it should be understood that the sequence numbers of the above-mentioned processes do not necessarily mean the order of execution. The implementation of the examples constitutes no limitation.
上述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物单元,即可位于一个地方,或者也可以分布到多个网络单元上。可根据实际的需要选择其中的部分或全部单元来实现本实施例方案的目的。The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, located in one place, or distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本申请各实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
上述集成的单元若以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可获取的存储器中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或者部分,可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储器中,包括若干请求用以使得一台计算机设备(可以为个人计算机、服务器或者网络设备等,具体可以是计算机设备中的处理器)执行本申请的各个实施例上述方法的部分或全部步骤。If the above-mentioned integrated units are realized in the form of software function units and sold or used as independent products, they can be stored in a computer-accessible memory. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a memory , including several requests to make a computer device (which may be a personal computer, server, or network device, etc., specifically, a processor in the computer device) execute some or all of the steps of the above-mentioned methods in various embodiments of the present application.
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序可以存储于一计算机可读存储介质中,存储介质包括只读存储器(Read-Only Memory,ROM)、随机存储器(Random Access Memory,RAM)、可编程只读存储器(Programmable Read-only Memory,PROM)、可擦除可编程只读存储器(Erasable Programmable Read Only Memory,EPROM)、一次可编程只读存储器(One-time Programmable Read-Only Memory,OTPROM)、电子抹除式可复写只读存储器(Electrically-Erasable Programmable Read-Only Memory,EEPROM)、只读光盘(CompactDisc Read-Only Memory,CD-ROM)或其他光盘存储器、磁盘存储器、磁带存储器、或者能够用于携带或存储数据的计算机可读的任何其他介质。Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above-mentioned embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, and the storage medium includes read-only Memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), programmable read-only memory (Programmable Read-only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read Only Memory, EPROM), One-time Programmable Read-Only Memory (OTPROM), Electronically Erasable Programmable Read-Only Memory (EEPROM), Compact Disc Read-Only Memory -Only Memory, CD-ROM) or other optical disk storage, magnetic disk storage, tape storage, or any other computer-readable medium that can be used to carry or store data.
以上对本申请实施例公开的一种图像处理方法、装置、电子设备及存储介质进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想。同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。An image processing method, device, electronic device, and storage medium disclosed in the embodiments of the present application have been described above in detail. In this paper, specific examples are used to illustrate the principles and implementation methods of the present application. The descriptions of the above embodiments are only used To help understand the method and core idea of the present application. At the same time, for those skilled in the art, based on the idea of this application, there will be changes in the specific implementation and application scope. In summary, the content of this specification should not be construed as limiting the application.
Claims (14)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110962242.9A CN113709365B (en) | 2021-08-20 | 2021-08-20 | Image processing method, device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110962242.9A CN113709365B (en) | 2021-08-20 | 2021-08-20 | Image processing method, device, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113709365A CN113709365A (en) | 2021-11-26 |
CN113709365B true CN113709365B (en) | 2023-05-02 |
Family
ID=78653932
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110962242.9A Active CN113709365B (en) | 2021-08-20 | 2021-08-20 | Image processing method, device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113709365B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114372931B (en) * | 2021-12-31 | 2025-03-11 | 原力图新(重庆)科技有限公司 | A method, device, storage medium and electronic device for blurring a target object |
CN115018951A (en) * | 2022-07-22 | 2022-09-06 | 平安国际融资租赁有限公司 | Image processing apparatus, apparatus, equipment and medium utilizing area color uplifting |
CN115861115A (en) * | 2022-12-16 | 2023-03-28 | 西安闻泰电子科技有限公司 | Image virtualization method, device, electronic device and storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108156378A (en) * | 2017-12-27 | 2018-06-12 | 努比亚技术有限公司 | Photographic method, mobile terminal and computer readable storage medium |
CN108230234A (en) * | 2017-05-19 | 2018-06-29 | 深圳市商汤科技有限公司 | Image virtualization processing method, device, storage medium and electronic equipment |
-
2021
- 2021-08-20 CN CN202110962242.9A patent/CN113709365B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108230234A (en) * | 2017-05-19 | 2018-06-29 | 深圳市商汤科技有限公司 | Image virtualization processing method, device, storage medium and electronic equipment |
CN108156378A (en) * | 2017-12-27 | 2018-06-12 | 努比亚技术有限公司 | Photographic method, mobile terminal and computer readable storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN113709365A (en) | 2021-11-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113888437B (en) | Image processing method, device, electronic device and computer readable storage medium | |
EP3609177B1 (en) | Control method, control apparatus, imaging device, and electronic device | |
CN113709365B (en) | Image processing method, device, electronic equipment and storage medium | |
CN110602467B (en) | Image noise reduction method, device, storage medium and electronic device | |
KR102474715B1 (en) | Parallax Mask Fusion of Color and Mono Images for Macrophotography | |
WO2019105154A1 (en) | Image processing method, apparatus and device | |
US10410327B2 (en) | Shallow depth of field rendering | |
US20240127403A1 (en) | Multi-frame image fusion method and system, electronic device, and storage medium | |
CN113313661A (en) | Image fusion method and device, electronic equipment and computer readable storage medium | |
CN110706162B (en) | Image processing method, device and computer storage medium | |
CN112822413B (en) | Shooting preview method, shooting preview device, terminal and computer readable storage medium | |
CN113674303B (en) | Image processing method, device, electronic device and storage medium | |
WO2022261828A1 (en) | Image processing method and apparatus, electronic device, and computer-readable storage medium | |
CN112258417B (en) | Image generation method, device and equipment | |
CN113298829A (en) | Image processing method, image processing device, electronic equipment and computer readable storage medium | |
CN113673474A (en) | Image processing method, image processing device, electronic equipment and computer readable storage medium | |
CN113793257A (en) | Image processing method and apparatus, electronic device, and computer-readable storage medium | |
CN116962890B (en) | Processing method, device, equipment and storage medium of point cloud image | |
CN108629329B (en) | Image processing method and apparatus, electronic device, computer-readable storage medium | |
CN109300186B (en) | Image processing method and device, storage medium and electronic equipment | |
CN109345602A (en) | Image processing method and device, storage medium and electronic equipment | |
CN118071658A (en) | Image processing method, apparatus, electronic device, and computer-readable storage medium | |
CN109447925B (en) | Image processing method and device, storage medium, electronic device | |
CN116168050A (en) | Image processing method, device, electronic device and storage medium | |
CN113436106A (en) | Underwater image enhancement method and device and computer storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |