[go: up one dir, main page]

CN107871303B - An image processing method and device - Google Patents

An image processing method and device Download PDF

Info

Publication number
CN107871303B
CN107871303B CN201610853241.XA CN201610853241A CN107871303B CN 107871303 B CN107871303 B CN 107871303B CN 201610853241 A CN201610853241 A CN 201610853241A CN 107871303 B CN107871303 B CN 107871303B
Authority
CN
China
Prior art keywords
image
brightness
original
filtering
pixel point
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
Application number
CN201610853241.XA
Other languages
Chinese (zh)
Other versions
CN107871303A (en
Inventor
陈宇
王明琛
梅元刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Kingsoft Cloud Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Kingsoft Cloud Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Cloud Network Technology Co Ltd, Beijing Kingsoft Cloud Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN201610853241.XA priority Critical patent/CN107871303B/en
Publication of CN107871303A publication Critical patent/CN107871303A/en
Application granted granted Critical
Publication of CN107871303B publication Critical patent/CN107871303B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/04Context-preserving transformations, e.g. by using an importance map
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/50Image enhancement or restoration using two or more images, e.g. averaging or subtraction
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/77Retouching; Inpainting; Scratch removal
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20212Image combination
    • G06T2207/20221Image fusion; Image merging

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)

Abstract

本发明实施例公开了一种图像处理方法及装置。该方法包括:分离出原始图像的亮度分量以及色度分量,得到原始亮度图像以及原始色度图像;基于快速滤波算法,对该原始亮度图像进行滤波处理,得到第一亮度图像;对该原始亮度图像进行曲线调整,得到第二亮度图像;基于阿尔法融合算法和第一亮度图像,对该原始亮度图像和该第二亮度图像进行图像融合,获得目标亮度图像;基于该目标亮度图像和该原始色度图像,获得目标图像。应用本发明实施例提供的方案进行图像处理时,在保证处理效果的同时,还能保证图像处理算法占用的系统资源少,相对于现有技术,提升了图像处理的速度。

Figure 201610853241

Embodiments of the present invention disclose an image processing method and device. The method includes: separating luminance components and chrominance components of an original image to obtain an original luminance image and an original chrominance image; filtering the original luminance image based on a fast filtering algorithm to obtain a first luminance image; Curve adjustment is performed on the image to obtain a second brightness image; based on the alpha fusion algorithm and the first brightness image, image fusion is performed on the original brightness image and the second brightness image to obtain a target brightness image; based on the target brightness image and the original color image degree image to obtain the target image. When applying the solution provided by the embodiment of the present invention for image processing, while ensuring the processing effect, it can also ensure that the image processing algorithm occupies less system resources, and the speed of image processing is improved compared with the prior art.

Figure 201610853241

Description

一种图像处理方法及装置An image processing method and device

技术领域technical field

本发明涉及计算机技术领域,特别涉及一种图像处理方法及装置。The present invention relates to the field of computer technology, and in particular, to an image processing method and device.

背景技术Background technique

图像处理(image processing),是指用计算机对图像进行分析,以达到所需结果的技术。图像美化处理属于常见的一种图像处理方式,是指利用计算机对图像信息进行加工以满足人的视觉心理或者应用需求的图像处理方式,例如,人脸美化等。随着计算机技术的迅速发展,图像美化处理也在不断地发展,以满足人们的需求。Image processing refers to the technique of analyzing images with a computer to achieve the desired results. Image beautification processing is a common image processing method, which refers to an image processing method that uses a computer to process image information to meet human visual psychology or application needs, such as face beautification. With the rapid development of computer technology, image beautification processing is also constantly developing to meet people's needs.

在现有技术中,基于曲线调整的图像美化算法是一种常用的图像美化处理方法,通过该算法可以适当地调整图像中较暗的瑕疵区域的亮度,同时还可以保留原图像的对比度,例如,对于图像中的人脸区域进行美化时,首先通过该算法找出图像人脸区域中的斑点区域,然后对整幅图像进行高斯模糊处理,实现对图像中人脸区域的美化,该算法对于头发等特别暗的区域保留比较好的对比度,处理后得到的结果图较为清晰,该算法可以增加图像中斑点区域的亮度,使斑点的亮度接近人体肤色,从而达到人脸美化的效果。In the prior art, an image beautification algorithm based on curve adjustment is a commonly used image beautification processing method. Through this algorithm, the brightness of the darker defect areas in the image can be appropriately adjusted, while the contrast of the original image can also be preserved, such as , when beautifying the face area in the image, first find the spot area in the face area of the image through this algorithm, and then perform Gaussian blurring on the entire image to realize the beautification of the face area in the image. Especially dark areas such as hair retain better contrast, and the result image obtained after processing is clearer. This algorithm can increase the brightness of the spot area in the image, so that the brightness of the spot is close to the skin color of the human body, so as to achieve the effect of face beautification.

但是,现有的基于曲线调整的图像美化算法中,进行高斯模糊处理时所采用的模糊半径较大,导致整个算法运行时系统资源占用量大,因而对于设备的性能要求高,以致移动设备等性能较差的设备,无法完成对图像的实时处理。However, in the existing image beautification algorithms based on curve adjustment, the blur radius used in Gaussian blur processing is large, which results in a large amount of system resources when the entire algorithm is running, and therefore requires high performance of the device, so that mobile devices, etc. Devices with poor performance cannot complete real-time processing of images.

发明内容SUMMARY OF THE INVENTION

本发明实施例公开了一种图像处理方法及装置,用于在对图像进行美化处理的过程中,降低图像处理算法占用的系统资源。技术方案如下:The embodiment of the present invention discloses an image processing method and device, which are used for reducing the system resources occupied by the image processing algorithm in the process of beautifying the image. The technical solution is as follows:

为达上述目的,第一方面,本发明实施例提供了一种图像处理方法,所述方法包括:In order to achieve the above purpose, in a first aspect, an embodiment of the present invention provides an image processing method, and the method includes:

分离出原始图像的亮度分量以及色度分量,得到原始亮度图像以及原始色度图像;Separate the luminance component and the chrominance component of the original image to obtain the original luminance image and the original chrominance image;

基于快速滤波算法,对所述原始亮度图像进行滤波处理,得到第一亮度图像;Based on a fast filtering algorithm, filtering processing is performed on the original luminance image to obtain a first luminance image;

对所述原始亮度图像进行曲线调整,得到第二亮度图像;performing curve adjustment on the original brightness image to obtain a second brightness image;

基于阿尔法融合算法以及所述第一亮度图像,对所述原始亮度图像和所述第二亮度图像进行图像融合,获得目标亮度图像;Based on the alpha fusion algorithm and the first brightness image, image fusion is performed on the original brightness image and the second brightness image to obtain a target brightness image;

基于所述目标亮度图像和所述原始色度图像,获得目标图像。Based on the target luminance image and the original chrominance image, a target image is obtained.

优选的,所述快速滤波算法为导向图滤波法、快速高斯滤波法以及盒子滤波法中的任意一种。Preferably, the fast filtering algorithm is any one of a guided graph filtering method, a fast Gaussian filtering method and a box filtering method.

优选的,所述基于阿尔法融合算法以及所述第一亮度图像,对所述原始亮度图像和所述第二亮度图像进行图像融合,获得目标亮度图像,包括:Preferably, performing image fusion on the original brightness image and the second brightness image based on an alpha fusion algorithm and the first brightness image to obtain a target brightness image, including:

按照像素点位置,分别计算所述原始亮度图像与所述第一亮度图像中各个像素点的亮度分量之差,获得各个像素点的亮度差异值;According to the pixel position, the difference between the brightness components of each pixel in the original brightness image and the first brightness image is calculated respectively, and the brightness difference value of each pixel is obtained;

基于各个像素点的亮度差异值,确定各个像素点对应的阿尔法分量;Determine the alpha component corresponding to each pixel point based on the brightness difference value of each pixel point;

基于各个像素点对应的阿尔法分量,对所述原始亮度图像和所述第二亮度图像进行图像融合,获得目标亮度图像。Based on the alpha component corresponding to each pixel point, image fusion is performed on the original luminance image and the second luminance image to obtain a target luminance image.

优选的,所述基于快速滤波算法,对所述原始亮度图像进行滤波处理,得到第一亮度图像,包括:Preferably, based on the fast filtering algorithm, the original brightness image is filtered to obtain the first brightness image, including:

对所述原始亮度图像进行缩小处理,获得第三亮度图像;performing reduction processing on the original brightness image to obtain a third brightness image;

基于快速滤波算法以及所述第三亮度图像,获得对所述原始亮度图像进行滤波处理后得到的第一亮度图像。Based on the fast filtering algorithm and the third luminance image, a first luminance image obtained by filtering the original luminance image is obtained.

优选的,当所述快速滤波算法为导向图滤波法时,所述基于快速滤波算法,对所述原始亮度图像进行滤波处理,得到第一亮度图像,包括:Preferably, when the fast filtering algorithm is a guide map filtering method, the filtering process is performed on the original brightness image based on the fast filtering algorithm to obtain a first brightness image, including:

按照以下方式,对所述原始亮度图像中每一像素点进行滤波处理,并根据滤波结果获得第一亮度图像:Perform filtering processing on each pixel in the original luminance image in the following manner, and obtain a first luminance image according to the filtering result:

确定以第一像素点为中心的第一类预设窗口内的像素点,其中,所述第一像素点为所述原始亮度图像内的任一像素点;determining a pixel point in a first type of preset window centered on a first pixel point, wherein the first pixel point is any pixel point in the original brightness image;

计算所确定像素点的亮度分量对应的第一方差和第一平均值;Calculate the first variance and the first average value corresponding to the brightness component of the determined pixel point;

根据所述第一方差和所述第一平均值,对所述第一像素点进行滤波处理。Filter processing is performed on the first pixel point according to the first variance and the first average value.

优选的,所述计算所确定像素点的亮度分量对应的第一方差和第一平均值,包括:Preferably, the calculating the first variance and the first average value corresponding to the luminance component of the determined pixel point includes:

获得第四亮度图像,其中,所述第四亮度图像为:根据所述原始亮度图像中每个像素点Y分量的平方值确定的图像;obtaining a fourth brightness image, wherein the fourth brightness image is: an image determined according to the square value of the Y component of each pixel in the original brightness image;

获得分别对应所述原始亮度图像以及所述第四亮度图像的第一积分图像以及第二积分图像;obtaining a first integral image and a second integral image respectively corresponding to the original luminance image and the fourth luminance image;

基于所述第一积分图像以及所述第二积分图像,计算所确定像素点的亮度分量对应的第一方差和第一平均值。Based on the first integral image and the second integral image, a first variance and a first average value corresponding to the luminance components of the determined pixel points are calculated.

优选的,所述根据所述第一方差和所述第一平均值,对所述第一像素点进行滤波处理,包括:Preferably, performing filtering processing on the first pixel point according to the first variance and the first average value includes:

按照如下公式,对所述第一像素点进行滤波处理:According to the following formula, filter processing is performed on the first pixel point:

Figure BDA0001120683910000031
Figure BDA0001120683910000031

式中,Yb为所述第一像素点滤波后的亮度分量;σ1为所述第一方差;ε1为预设的第一平滑参数;Y为所述第一像素点的亮度分量;

Figure BDA0001120683910000032
为所述第一平均值。In the formula, Y b is the filtered luminance component of the first pixel; σ 1 is the first variance; ε 1 is the preset first smoothing parameter; Y is the luminance component of the first pixel ;
Figure BDA0001120683910000032
is the first average value.

优选的,所述对所述原始亮度图像进行曲线调整,得到第二亮度图像,包括:Preferably, the curve adjustment is performed on the original brightness image to obtain a second brightness image, including:

按照如下公式,调整所述原始亮度图像中每个像素点的亮度分量,获得第二亮度图像:According to the following formula, adjust the luminance component of each pixel in the original luminance image to obtain a second luminance image:

Figure BDA0001120683910000033
Figure BDA0001120683910000033

式中,k为比例系数,Yh(i,j)表示所述原始亮度图像中像素坐标为(i,j)的像素点对应的调整后的亮度分量,Y(i,j)表示所述原始亮度图像中像素坐标为(i,j)的像素点的亮度分量。In the formula, k is the scale coefficient, Y h (i, j) represents the adjusted brightness component corresponding to the pixel point whose pixel coordinate is (i, j) in the original brightness image, and Y(i, j) represents the The luminance component of the pixel whose pixel coordinate is (i, j) in the original luminance image.

优选的,所述基于所述目标亮度图像和所述原始色度图像,得到目标图像,包括:Preferably, the obtaining the target image based on the target luminance image and the original chrominance image includes:

对所述原始色度图像进行导向图滤波处理,获得目标色度图像;Perform guide map filtering processing on the original chromaticity image to obtain a target chromaticity image;

合并所述目标亮度图像和所述目标色度图像,得到目标图像。The target image is obtained by combining the target luminance image and the target chrominance image.

优选的,所述原始色度图像包括U分量对应的第一色度图像以及V分量对应的第二色度图像,Preferably, the original chrominance image includes a first chrominance image corresponding to the U component and a second chrominance image corresponding to the V component,

所述对所述原始色度图像进行导向图滤波处理,获得目标色度图像,包括:The performing guide map filtering processing on the original chromaticity image to obtain a target chromaticity image, including:

按照以下方式,对所述第一色度图像中每一像素点进行滤波处理,并根据滤波结果获得第一目标色度图像,对所述第二色度图像中每一像素点进行滤波处理,并根据滤波结果获得第二目标色度图像:In the following manner, filtering processing is performed on each pixel in the first chromaticity image, and a first target chromaticity image is obtained according to the filtering result, and filtering processing is performed on each pixel in the second chromaticity image, And obtain the second target chrominance image according to the filtering result:

确定以第二像素点为中心的第二类预设窗口内的像素点,其中,所述第二像素点为所述第一色度图像或所述第二色度图像内的任一像素点;Determine the pixels in the second type of preset window centered on the second pixel, where the second pixel is any pixel in the first chromaticity image or the second chromaticity image ;

计算所确定像素点的像素值对应的第二方差和第二平均值;Calculate the second variance and the second average value corresponding to the pixel value of the determined pixel point;

根据所述第二方差和所述第二平均值,对所述第二像素点进行滤波处理。Filter processing is performed on the second pixel point according to the second variance and the second average value.

优选的,所述根据所述第二方差和所述第二平均值,对所述第二像素点进行滤波处理,包括:Preferably, performing filtering processing on the second pixel points according to the second variance and the second average value includes:

按照如下公式,对所述第二像素点进行滤波处理:According to the following formula, filter processing is performed on the second pixel point:

Figure BDA0001120683910000041
Figure BDA0001120683910000041

式中,Xb为所述第二像素点滤波后的像素值;σ2为所述第二方差;ε2为预设的第二平滑参数;X为所述第二像素点的像素值;

Figure BDA0001120683910000042
为所述第二平均值。In the formula, X b is the filtered pixel value of the second pixel point; σ 2 is the second variance; ε 2 is the preset second smoothing parameter; X is the pixel value of the second pixel point;
Figure BDA0001120683910000042
is the second average value.

第二方面,本发明实施例提供了一种图像处理装置,所述装置包括:In a second aspect, an embodiment of the present invention provides an image processing apparatus, and the apparatus includes:

分离模块,用于分离出原始图像的亮度分量以及色度分量,得到原始亮度图像以及原始色度图像;The separation module is used to separate the luminance component and the chrominance component of the original image to obtain the original luminance image and the original chrominance image;

滤波处理模块,用于基于快速滤波算法,对所述原始亮度图像进行滤波处理,得到第一亮度图像;a filtering processing module, configured to perform filtering processing on the original luminance image based on a fast filtering algorithm to obtain a first luminance image;

曲线调整模块,用于对所述原始亮度图像进行曲线调整,得到第二亮度图像;a curve adjustment module, configured to perform curve adjustment on the original brightness image to obtain a second brightness image;

融合模块,用于基于阿尔法融合算法以及所述第一亮度图像,对所述原始亮度图像和所述第二亮度图像进行图像融合,获得目标亮度图像;a fusion module, configured to perform image fusion on the original brightness image and the second brightness image based on an alpha fusion algorithm and the first brightness image to obtain a target brightness image;

获得模块,用于基于所述目标亮度图像和所述原始色度图像,获得目标图像。An obtaining module is configured to obtain a target image based on the target luminance image and the original chrominance image.

优选的,所述快速滤波算法为导向图滤波法、快速高斯滤波法以及盒子滤波法中的任意一种。Preferably, the fast filtering algorithm is any one of a guided graph filtering method, a fast Gaussian filtering method and a box filtering method.

优选的,所述融合模块,包括:Preferably, the fusion module includes:

第一计算子模块,用于按照像素点位置,分别计算所述原始亮度图像与所述第一亮度图像中各个像素点的亮度分量之差,获得各个像素点的亮度差异值;a first calculation sub-module, configured to calculate the difference between the brightness components of each pixel in the original brightness image and the first brightness image according to the pixel position, and obtain the brightness difference value of each pixel;

第一确定子模块,用于基于各个像素点的亮度差异值,确定各个像素点对应的阿尔法分量;The first determination sub-module is used to determine the alpha component corresponding to each pixel point based on the brightness difference value of each pixel point;

融合子模块,用于基于各个像素点对应的阿尔法分量,对所述原始亮度图像和所述第二亮度图像进行图像融合,获得目标亮度图像。The fusion sub-module is configured to perform image fusion on the original brightness image and the second brightness image based on the alpha component corresponding to each pixel to obtain a target brightness image.

优选的,所述滤波处理模块,包括:Preferably, the filtering processing module includes:

处理子模块,用于对所述原始亮度图像进行缩小处理,获得第三亮度图像;a processing submodule, used for reducing the original brightness image to obtain a third brightness image;

获得子模块,用于基于快速滤波算法以及所述第三亮度图像,获得对所述原始亮度图像进行滤波处理后得到的第一亮度图像。The obtaining sub-module is configured to obtain a first luminance image obtained by filtering the original luminance image based on the fast filtering algorithm and the third luminance image.

优选的,当所述快速滤波算法为导向图滤波法时,所述滤波处理模块,具体用于:Preferably, when the fast filtering algorithm is a directed graph filtering method, the filtering processing module is specifically used for:

对所述原始亮度图像中每一像素点进行滤波处理,并根据滤波结果获得第一亮度图像;Perform filtering processing on each pixel in the original brightness image, and obtain a first brightness image according to the filtering result;

其中,所述滤波处理模块,包括:Wherein, the filtering processing module includes:

第二确定子模块,用于确定以第一像素点为中心的第一类预设窗口内的像素点;所述第一像素点为所述原始亮度图像内的任一像素点;a second determination sub-module, configured to determine a pixel point in the first type of preset window centered on the first pixel point; the first pixel point is any pixel point in the original brightness image;

第二计算子模块,用于计算所确定像素点的亮度分量对应的第一方差和第一平均值;The second calculation submodule is used to calculate the first variance and the first average value corresponding to the brightness component of the determined pixel point;

滤波处理子模块,用于根据所述第一方差和所述第一平均值,对所述第一像素点进行滤波处理。A filtering processing sub-module, configured to perform filtering processing on the first pixel point according to the first variance and the first average value.

优选的,所述第二计算子模块,包括:Preferably, the second calculation submodule includes:

第一获得单元,用于获得第四亮度图像,其中,所述第四亮度图像为:根据所述原始亮度图像中每个像素点Y分量的平方值确定的图像;a first obtaining unit, configured to obtain a fourth brightness image, wherein the fourth brightness image is: an image determined according to the square value of the Y component of each pixel in the original brightness image;

第二获得单元,用于获得分别对应所述原始亮度图像以及所述第四亮度图像的第一积分图像以及第二积分图像;a second obtaining unit, configured to obtain a first integral image and a second integral image respectively corresponding to the original luminance image and the fourth luminance image;

第一计算单元,用于基于所述第一积分图像以及所述第二积分图像,计算所确定像素点的亮度分量对应的第一方差和第一平均值。A first calculation unit, configured to calculate a first variance and a first average value corresponding to the luminance component of the determined pixel point based on the first integral image and the second integral image.

优选的,所述滤波处理子模块,具体用于:Preferably, the filtering processing sub-module is specifically used for:

按照如下公式,对所述第一像素点进行滤波处理:According to the following formula, filter processing is performed on the first pixel point:

Figure BDA0001120683910000061
Figure BDA0001120683910000061

式中,Yb为所述第一像素点滤波后的亮度分量;σ1为所述第一方差;ε1为预设的第一平滑参数;Y为所述第一像素点的亮度分量;

Figure BDA0001120683910000062
为所述第一平均值。In the formula, Y b is the filtered luminance component of the first pixel; σ 1 is the first variance; ε 1 is the preset first smoothing parameter; Y is the luminance component of the first pixel ;
Figure BDA0001120683910000062
is the first average value.

优选的,所述曲线调整模块,具体用于:Preferably, the curve adjustment module is specifically used for:

按照如下公式,调整所述原始亮度图像中每个像素点的亮度分量,获得第二亮度图像:According to the following formula, adjust the luminance component of each pixel in the original luminance image to obtain a second luminance image:

Figure BDA0001120683910000063
Figure BDA0001120683910000063

式中,k为比例系数,Yh(i,j)表示所述原始亮度图像中像素坐标为(i,j)的像素点对应的调整后的亮度分量,Y(i,j)表示所述原始亮度图像中像素坐标为(i,j)的像素点的亮度分量。In the formula, k is the scale coefficient, Y h (i, j) represents the adjusted brightness component corresponding to the pixel point whose pixel coordinate is (i, j) in the original brightness image, and Y(i, j) represents the The luminance component of the pixel whose pixel coordinate is (i, j) in the original luminance image.

优选的,所述获得模块,包括:Preferably, the obtaining module includes:

导向图滤波处理子模块,用于对所述原始色度图像进行导向图滤波处理,获得目标色度图像;A guide map filtering processing sub-module, configured to perform guide map filtering processing on the original chromaticity image to obtain a target chromaticity image;

合并子模块,用于合并所述目标亮度图像和所述目标色度图像,得到目标图像。The merging submodule is used for merging the target luminance image and the target chrominance image to obtain a target image.

优选的,所述原始色度图像包括:U分量对应的第一色度图像以及V分量对应的第二色度图像,所述导向图滤波处理子模块,具体用于:Preferably, the original chrominance image includes: a first chrominance image corresponding to the U component and a second chrominance image corresponding to the V component, and the guide map filtering processing sub-module is specifically used for:

对所述第一色度图像中每一像素点进行滤波处理,并根据滤波结果获得第一目标色度图像,对所述第二色度图像中每一像素点进行滤波处理,并根据滤波结果获得第二目标色度图像;Perform filtering processing on each pixel in the first chromaticity image, and obtain a first target chromaticity image according to the filtering result, perform filtering processing on each pixel in the second chromaticity image, and obtain a first target chromaticity image according to the filtering result. obtain a second target chromaticity image;

其中,所述导向图滤波处理子模块,包括:Wherein, the guide map filtering processing sub-module includes:

确定单元,用于确定以第二像素点为中心的第二类预设窗口内的像素点,其中,所述第二像素点为所述第一色度图像或所述第二色度图像内的任一像素点;A determination unit, configured to determine a pixel point within a second type of preset window centered on a second pixel point, wherein the second pixel point is within the first chromaticity image or the second chromaticity image any pixel of ;

第二计算单元,用于计算所确定像素点的像素值对应的第二方差和第二平均值;a second calculation unit, configured to calculate the second variance and the second average value corresponding to the pixel value of the determined pixel point;

滤波处理单元,用于根据所述第二方差和所述第二平均值,对所述第二像素点进行滤波处理。A filtering processing unit, configured to perform filtering processing on the second pixel point according to the second variance and the second average value.

优选的,所述滤波处理单元,具体用于:Preferably, the filtering processing unit is specifically used for:

按照如下公式,对所述第二像素点进行滤波处理:According to the following formula, filter processing is performed on the second pixel point:

Figure BDA0001120683910000071
Figure BDA0001120683910000071

式中,Xb为所述第二像素点滤波后的像素值;σ2为所述第二方差;ε2为预设的第二平滑参数;X为所述第二像素点的像素值;

Figure BDA0001120683910000072
为所述第二平均值。In the formula, X b is the filtered pixel value of the second pixel point; σ 2 is the second variance; ε 2 is the preset second smoothing parameter; X is the pixel value of the second pixel point;
Figure BDA0001120683910000072
is the second average value.

由以上可见,本发明实施例提供的方案中,首先分离出原始图像的亮度分量以及色度分量,得到原始亮度图像以及原始色度图像;再基于快速滤波算法,对该原始亮度图像进行滤波处理,得到第一亮度图像;并对该原始亮度图像进行曲线调整,得到第二亮度图像;然后基于阿尔法融合算法和第一亮度图像,对该原始亮度图像和该第二亮度图像进行图像融合,获得目标亮度图像;最后基于该目标亮度图像和该原始色度图像,获得目标图像。与现有技术相比,本方案中采用的滤波算法为区别于高斯滤波法的快速滤波算法,此类快速滤波算法对图像进行滤波处理时,在保证图像处理效果的同时,还能保证图像处理算法占用的系统资源少,图像处理速度快,因此,本方案还可以应用于移动设备等性能较差的设备,以使得上述性能较差的设备可以对高质量视频图像进行实时处理。It can be seen from the above that in the solution provided by the embodiment of the present invention, the luminance component and the chrominance component of the original image are first separated to obtain the original luminance image and the original chrominance image; and then the original luminance image is filtered based on a fast filtering algorithm. , obtain a first brightness image; and perform curve adjustment on the original brightness image to obtain a second brightness image; then based on the alpha fusion algorithm and the first brightness image, perform image fusion on the original brightness image and the second brightness image to obtain A target luminance image; finally, a target image is obtained based on the target luminance image and the original chrominance image. Compared with the prior art, the filtering algorithm adopted in this solution is a fast filtering algorithm which is different from the Gaussian filtering method. When such a fast filtering algorithm performs filtering processing on an image, it can ensure the image processing effect while ensuring the image processing effect. The algorithm occupies less system resources and the image processing speed is fast. Therefore, this solution can also be applied to devices with poor performance such as mobile devices, so that the devices with poor performance can process high-quality video images in real time.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to explain the embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings without creative efforts.

图1为本发明实施例提供的一种图像处理方法的第一种流程示意图;FIG. 1 is a first schematic flowchart of an image processing method provided by an embodiment of the present invention;

图2为本发明实施例提供的一种图像处理方法中涉及的公式(1)的函数图像;2 is a function image of formula (1) involved in an image processing method provided by an embodiment of the present invention;

图3为本发明实施例提供的一种图像处理方法中涉及的函数f(x)的函数图像;3 is a function image of a function f(x) involved in an image processing method provided by an embodiment of the present invention;

图4为本发明实施例提供的一种图像处理方法的第二种流程示意图;4 is a second schematic flowchart of an image processing method provided by an embodiment of the present invention;

图5为本发明实施例提供的一种图像处理装置的第一种结构示意图;FIG. 5 is a first structural schematic diagram of an image processing apparatus according to an embodiment of the present invention;

图6为本发明实施例提供的一种图像处理装置的第二种结构示意图。FIG. 6 is a schematic diagram of a second structure of an image processing apparatus according to an embodiment of the present invention.

具体实施方式Detailed ways

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

下面首先对本发明涉及的技术术语进行简单介绍。The following briefly introduces the technical terms involved in the present invention.

图像处理:如上所述,图像处理技术是指用计算机对图像进行分析,以达到所需结果的技术。在现有技术中,可以对工业相机、扫描仪等设备经过拍摄得到的单张图像进行图像处理,当然,还可以对摄像机拍摄到的或者视频播放器在播放视频时所播放的每一帧图像实时地进行图像处理。Image Processing: As mentioned above, image processing techniques refer to techniques that use computers to analyze images to achieve desired results. In the prior art, image processing can be performed on a single image captured by industrial cameras, scanners, and other equipment. Of course, each frame of image captured by a camera or played by a video player when playing a video can also be processed. Image processing is performed in real time.

图像的亮度分量以及色度分量:在现有技术中,YUV是一种主要应用于电视系统以及模拟视频领域的颜色编码方式,YUV图像分为三个分量,“Y”表示明亮度(Luminance或Luma),也就是灰度值;而“U”和“V”表示的则是色度(Chrominance或Chroma),作用是描述影像色彩及饱和度,用于指定像素的颜色。图像的亮度分量可以是指YUV编码格式下图像的Y分量,而色度分量则可以是指YUV编码格式下图像的U分量以及V分量。Luminance component and chrominance component of an image: In the prior art, YUV is a color coding method mainly used in TV systems and analog video fields. A YUV image is divided into three components. Luma), which is the grayscale value; and "U" and "V" represent the chroma (Chrominance or Chroma), which is used to describe the color and saturation of the image, and is used to specify the color of the pixel. The luminance component of the image may refer to the Y component of the image in the YUV encoding format, and the chrominance component may refer to the U component and the V component of the image in the YUV encoding format.

下面再通过具体实施例对本发明进行详细介绍。The present invention will be described in detail below through specific embodiments.

图1为本发明实施例提供的一种图像处理方法的第一种流程示意图,该方法包括:FIG. 1 is a first schematic flowchart of an image processing method provided by an embodiment of the present invention, and the method includes:

S101:分离出原始图像的亮度分量以及色度分量,得到原始亮度图像以及原始色度图像。S101: Separate the luminance component and the chrominance component of the original image to obtain the original luminance image and the original chrominance image.

此处的亮度分量对应为Y分量,色度分量可以是指U分量和V分量。如上所述,此颜色空间的图像包括三个分量,所以,可以依据现有技术分离此处的亮度分量以及色度分量。The luminance component here corresponds to the Y component, and the chrominance component may refer to the U component and the V component. As mentioned above, the image in this color space includes three components, so the luminance component and the chrominance component here can be separated according to the prior art.

例如,对于数码相机常用的I420格式的图像,本领域技术人员公知的是,I420格式的图像在存储时,先存储图像中各个像素点的Y分量,再存储各个像素点的U分量,最后存储各个像素点的V分量;在读取图像中的数据时,分别找到Y、U和V三个分量的起始点,就可以从图像中分别读取到图像中所有的Y、U和V三个分量;可见,对于I420格式的图像,亮度分量和色度分量的分离非常方便快捷,不需要额外的内存拷贝和颜色转换。For example, for an image in I420 format commonly used in digital cameras, it is well known to those skilled in the art that when an image in I420 format is stored, the Y component of each pixel in the image is first stored, then the U component of each pixel is stored, and finally The V component of each pixel; when reading the data in the image, find the starting points of the three components of Y, U and V, respectively, and then read all three Y, U and V from the image. Components; it can be seen that for images in I420 format, the separation of luminance components and chrominance components is very convenient and fast, and no additional memory copying and color conversion are required.

可以理解,得到的原始亮度图像中,每一个像素点的亮度分量为对应在该原始图像中相同位置的像素点的亮度分量,同理,得到的原始色度图像中,每一个像素点的色度分量为对应在该原始图像中相同位置的像素点的色度分量。It can be understood that in the obtained original luminance image, the luminance component of each pixel is the luminance component corresponding to the pixel at the same position in the original image. Similarly, in the obtained original chromaticity image, the color of each pixel is The chrominance component is the chrominance component corresponding to the pixel at the same position in the original image.

S102:基于快速滤波算法,对该原始亮度图像进行滤波处理,得到第一亮度图像。S102: Based on a fast filtering algorithm, perform filtering processing on the original luminance image to obtain a first luminance image.

此处的快速滤波算法为导向图滤波法、快速高斯滤波法以及盒子滤波法中的任意一种。上述导向图滤波法、快速高斯滤波法以及盒子滤波法为现有技术中常用的滤波算法,本领域技术人员可以参照现有技术对图像记性滤波处理,本发明在此不再赘述。The fast filtering algorithm here is any one of the guided graph filtering method, the fast Gaussian filtering method and the box filtering method. The above-mentioned guide map filtering method, fast Gaussian filtering method and box filtering method are commonly used filtering algorithms in the prior art, and those skilled in the art can refer to the prior art for image memory filtering processing, which will not be repeated in the present invention.

此类快速滤波算法,相对于现有的应用于图像处理的高斯滤波法,其在对图像进行滤波处理时,可以在不降低图像处理效果的前提下,保证图像处理算法占用的系统资源少,图像处理速度快,例如,此类快速滤波算法运行时对设备的CPU(Central ProcessingUnit,中央处理器)占用率低,减少设备发热量。Compared with the existing Gaussian filtering method applied to image processing, this kind of fast filtering algorithm can ensure that the image processing algorithm occupies less system resources without reducing the image processing effect when filtering the image. The image processing speed is fast. For example, when such a fast filtering algorithm runs, the CPU (Central Processing Unit, central processing unit) occupancy rate of the device is low, and the heat generation of the device is reduced.

本发明实施例中,为了加快滤波处理的速度,上述基于快速滤波算法,对该原始亮度图像进行滤波处理,得到第一亮度图像(S102),可以包括两个步骤:In the embodiment of the present invention, in order to speed up the filtering processing, the above-mentioned filtering processing is performed on the original brightness image based on the fast filtering algorithm to obtain the first brightness image (S102), which may include two steps:

第一步:对该原始亮度图像进行缩小处理,获得第三亮度图像。The first step: reducing the original brightness image to obtain a third brightness image.

可以理解,对图像做缩小处理,可以是将图像缩小预设倍数,当然也可以将图像缩小到预设大小的图像。缩小后获得的第三亮度图像中,每个像素点的亮度分量可以为:在原始亮度图像中对应的多个像素点的亮度分量的平均值。It can be understood that when the image is reduced, the image may be reduced by a preset multiple, and of course, the image may also be reduced to a preset size. In the third luminance image obtained after reduction, the luminance component of each pixel point may be an average value of luminance components of a plurality of corresponding pixel points in the original luminance image.

例如:对该原始亮度图像的长和宽均缩小4倍,则此时获得的第三亮度图像中,坐标值为(1,1)的像素点对应的亮度分量应该为:原始亮度图像中坐标值分别为(1,1)和(4,4)的两个像素点所组成的矩形区域中,所有像素点的亮度分量的平均值。For example, if the length and width of the original brightness image are reduced by 4 times, then in the third brightness image obtained at this time, the brightness component corresponding to the pixel whose coordinate value is (1, 1) should be: the coordinate in the original brightness image The average value of the luminance components of all pixels in the rectangular area composed of two pixels whose values are (1, 1) and (4, 4).

第二步:基于快速滤波算法以及该第三亮度图像,获得对该原始亮度图像进行滤波处理后得到的第一亮度图像。Step 2: Based on the fast filtering algorithm and the third luminance image, obtain a first luminance image obtained by filtering the original luminance image.

第三亮度图像中的像素点的数量显然是小于原始亮度图像中像素点的数量,所以缩小处理后,减少了需要进行滤波处理的像素点的数量,进而加快了对图像滤波处理的速度。The number of pixels in the third brightness image is obviously smaller than the number of pixels in the original brightness image, so after the downscaling process, the number of pixels that need to be filtered is reduced, thereby speeding up the image filtering process.

可以理解,此处所述的第二步中,需要对该第三亮度图像执行快速滤波算法,另外,执行滤波算法后的得到的图像还应该进行放大处理,以获得第一亮度图像。具体的放大处理方法,可参考现有技术,本发明实施例不做详细介绍。It can be understood that in the second step described here, a fast filtering algorithm needs to be performed on the third luminance image, and in addition, the image obtained after executing the filtering algorithm should also be enlarged to obtain the first luminance image. For a specific amplification processing method, reference may be made to the prior art, and detailed descriptions are not provided in the embodiment of the present invention.

应该说明的是,相对于盒子滤波(box blur)和快速高斯滤波,导向图滤波法对系统资源的占用更少,所以本发明实施例中,该快速滤波算法优选为导向图滤波法。当该快速滤波算法为导向图滤波法时,上述基于快速滤波算法,对该原始亮度图像进行滤波处理,得到第一亮度图像(S102),包括:It should be noted that, compared with box blur and fast Gaussian filtering, the guided graph filtering method occupies less system resources. Therefore, in this embodiment of the present invention, the fast filtering algorithm is preferably the guided graph filtering method. When the fast filtering algorithm is a guide map filtering method, the above-mentioned filtering processing is performed on the original brightness image based on the fast filtering algorithm to obtain a first brightness image (S102), including:

按照以下方式,对该原始亮度图像中每一像素点进行滤波处理,并根据滤波结果获得第一亮度图像:Perform filtering processing on each pixel in the original luminance image in the following manner, and obtain a first luminance image according to the filtering result:

第一步:确定以第一像素点为中心的第一类预设窗口内的像素点,其中,该第一像素点为该原始亮度图像内的任一像素点。Step 1: Determine a pixel point in the first type of preset window centered on the first pixel point, where the first pixel point is any pixel point in the original brightness image.

该第一类预设窗口是指具有预设窗口大小值的窗口,其中心就是上述第一像素点,即,当前正在进行滤波处理的像素点。例如,对原始亮度图像中的像素点a进行滤波处理时,该第一像素点即为像素点a;假设该第一类预设窗口的大小为5×5,像素点a的像素坐标为(x,y),则像素点a对应的第一类预设窗口为:原始亮度图像中,像素坐标分别为(x-2,y-2)和(x+2,y+2)的两个像素点作为左上角和右下角所构成的矩形区域,此时,所确定的像素点即为该矩形区域内的所有像素点。The first type of preset window refers to a window with a preset window size value, the center of which is the above-mentioned first pixel point, that is, the pixel point currently undergoing filtering processing. For example, when filtering the pixel point a in the original brightness image, the first pixel point is the pixel point a; assuming that the size of the first type of preset window is 5 × 5, the pixel coordinate of the pixel point a is ( x, y), then the first type of preset window corresponding to the pixel point a is: in the original brightness image, the pixel coordinates are two of (x-2, y-2) and (x+2, y+2) respectively The pixel points are used as a rectangular area formed by the upper left corner and the lower right corner. At this time, the determined pixel points are all the pixel points in the rectangular area.

在实际使用过程中,该第一类预设窗口的窗口大小值应根据图像的大小选择,例如,对于1920×1080的图像,可以选择该窗口大小值为5×5。In actual use, the window size value of the first type of preset window should be selected according to the size of the image. For example, for a 1920×1080 image, the window size value can be selected as 5×5.

第二步:计算所确定像素点的亮度分量对应的第一方差和第一平均值。Step 2: Calculate the first variance and the first average value corresponding to the luminance component of the determined pixel point.

当确定第一类预设窗口中的像素点后,可以依据通用的数学公式计算获得该第一方差和第一平均值。但是,当该第一类预设窗口的窗口大小值较大时,计算该第一平均值以及第一方差的运算时间就会较长,例如:对于一个11×11的第一类预设窗口,其中的像素点总数为121个,所以计算第一平均值以及第一方差所采用的数据量大,以致运算时间长。After the pixel points in the first type of preset window are determined, the first variance and the first average value can be obtained by calculation according to a general mathematical formula. However, when the value of the window size of the first type of preset window is relatively large, the computation time for calculating the first average value and the first variance will be longer, for example, for a 11×11 type 1 preset window window, in which the total number of pixel points is 121, so the amount of data used to calculate the first average value and the first variance is large, so that the operation time is long.

在本发明实施例中,为了加快计算该第一方差和第一平均值,可以采用积分图加速处理。上述计算所确定像素点的亮度分量对应的第一方差和第一平均值,包括:In this embodiment of the present invention, in order to speed up the calculation of the first variance and the first average value, an integral graph may be used to speed up the processing. The first variance and the first average value corresponding to the brightness component of the determined pixel point in the above calculation include:

步骤一:获得第四亮度图像,其中,该第四亮度图像为:根据原始亮度图像中每个像素点Y分量的平方值确定的图像。Step 1: Obtain a fourth brightness image, where the fourth brightness image is an image determined according to the square value of the Y component of each pixel in the original brightness image.

即表示,第四亮度图像中,每个像素点的亮度分量为原始亮度图像中对应在相同位置的像素点的亮度分量的平方,例如,在原始亮度图像中,坐标值为(m,n)的像素点b的的亮度分量为M,则在第四亮度图像中,坐标值为(m,n)的像素点b’的亮度分量为M2That is to say, in the fourth brightness image, the brightness component of each pixel is the square of the brightness component of the pixel corresponding to the same position in the original brightness image. For example, in the original brightness image, the coordinate value is (m, n) The luminance component of the pixel point b is M, then in the fourth luminance image, the luminance component of the pixel point b' whose coordinate value is (m, n) is M 2 .

步骤二:获得分别对应该原始亮度图像以及该第四亮度图像的第一积分图像以及第二积分图像;Step 2: obtaining a first integral image and a second integral image respectively corresponding to the original luminance image and the fourth luminance image;

可以理解,积分图像的任意一像素点(x,y)的亮度分量等于从原图像的左上角到该像素点的所构成的矩形区域内所有的像素点的亮度分量之和。所以第一积分图像中,任一像素点(x,y)的亮度分量等于从原始亮度图像的左上角到原始亮度图像的像素点(x,y)所构成的矩形区域内所有的像素点的亮度分量之和;第二积分图像中,任一像素点(x,y)的亮度分量等于从第四亮度图像的左上角到第四亮度图像的像素点(x,y)所构成的矩形区域内所有的像素点的亮度分量之和。It can be understood that the luminance component of any pixel (x, y) of the integral image is equal to the sum of the luminance components of all pixels in the rectangular area formed by the pixel from the upper left corner of the original image. Therefore, in the first integral image, the luminance component of any pixel (x, y) is equal to the sum of all the pixels in the rectangular area formed from the upper left corner of the original luminance image to the pixel (x, y) of the original luminance image. The sum of luminance components; in the second integral image, the luminance component of any pixel (x, y) is equal to the rectangular area formed from the upper left corner of the fourth luminance image to the pixel (x, y) of the fourth luminance image The sum of the luminance components of all pixels within.

步骤三:基于该第一积分图像以及该第二积分图像,计算所确定像素点的亮度分量对应的第一方差和第一平均值。Step 3: Based on the first integral image and the second integral image, calculate the first variance and the first average value corresponding to the luminance component of the determined pixel point.

例如,上述第一像素点的坐标为(100,50),第一预设窗口的窗口大小值为11×11,假设在原始亮度图像中,以坐标为(100,50)的像素点为中心的11×11区域内,所有像素点的亮度分量的平均值为

Figure BDA0001120683910000121
在第二积分图像中,以坐标为(100,50)的像素点为中心的11×11区域内,所有像素点的亮度分量的平均值为
Figure BDA0001120683910000122
则此时所确定的像素点对应的第一方差
Figure BDA0001120683910000123
For example, the coordinates of the first pixel are (100, 50), and the window size of the first preset window is 11×11. It is assumed that in the original brightness image, the pixel with coordinates (100, 50) is the center In the 11×11 area of the average value of the luminance components of all pixels is
Figure BDA0001120683910000121
In the second integral image, in the 11×11 area centered on the pixel with coordinates (100, 50), the average value of the luminance components of all pixels is
Figure BDA0001120683910000122
Then the first variance corresponding to the pixel point determined at this time
Figure BDA0001120683910000123

其中,再假设第一积分图像中,该坐标为(100,50)的像素点的亮度分量为I1,坐标为(105,44)的像素点的亮度分量为I2,坐标为(94,55)的像素点的亮度分量为I3,坐标为(94,44)的像素点的亮度分量为I4,则所确定的像素点对应的第一平均值

Figure BDA0001120683910000124
Wherein, it is further assumed that in the first integral image, the luminance component of the pixel with coordinates (100, 50) is I 1 , the luminance component of the pixel with coordinates (105, 44) is I 2 , and the coordinates are (94, 55) the brightness component of the pixel point is I 3 , and the brightness component of the pixel point whose coordinates are (94, 44) is I 4 , then the first average value corresponding to the determined pixel point
Figure BDA0001120683910000124

本领域技术人员公知的是,积分图可以用以加速计算方差和平均值,具体原理可参照现有技术,本发明实施例在此不做详细介绍。It is well known to those skilled in the art that the integral graph can be used to accelerate the calculation of variance and average value, and the specific principle may refer to the prior art, which is not described in detail in this embodiment of the present invention.

第三步:根据该第一方差和该第一平均值,对第一像素点进行滤波处理。The third step: filtering the first pixel point according to the first variance and the first average value.

在获得第一像素点对应的第一方差和第一平均值后,本领域技术人员可以基于现有技术中的公式获得滤波处理后的第一像素点的亮度分量对应的滤波值。而在本发明实施例中,上述根据该第一方差和该第一平均值,对第一像素点进行滤波处理,可以是:After obtaining the first variance and the first average value corresponding to the first pixel, those skilled in the art can obtain the filtered value corresponding to the luminance component of the filtered first pixel based on the formula in the prior art. However, in the embodiment of the present invention, the filtering processing performed on the first pixel point according to the first variance and the first average value may be:

按照如下公式,对第一像素点进行滤波处理:The first pixel is filtered according to the following formula:

Figure BDA0001120683910000131
Figure BDA0001120683910000131

式中,Yb为第一像素点滤波后的亮度分量,即第一亮度图像中对应的像素点的亮度分量;σ1为该第一方差;ε1为预设的第一平滑参数;Y为第一像素点的亮度分量;

Figure BDA0001120683910000132
为该第一平均值。In the formula, Y b is the luminance component filtered by the first pixel point, that is, the luminance component of the corresponding pixel point in the first luminance image; σ 1 is the first variance; ε 1 is the preset first smoothing parameter; Y is the luminance component of the first pixel;
Figure BDA0001120683910000132
is the first average.

在实际应用过程中,ε1的取值可以基于实际情况,通常为15~20。In the actual application process, the value of ε 1 can be based on the actual situation, and is usually 15-20.

相较于现有技术中的快速导向图滤波法所采用的滤波处理公式,本发明中采用的滤波处理的公式更加简单,去掉了对系数二次求平均值的操作,减小了计算滤波值的繁琐程度,而且几乎不影响图像的处理效果。Compared with the filtering processing formula adopted by the fast guide map filtering method in the prior art, the filtering processing formula adopted in the present invention is simpler, the operation of averaging the coefficients twice is removed, and the calculation filter is reduced. The cumbersomeness of the value, and almost does not affect the processing effect of the image.

应该说明的是,本发明实施例中,最优的,可以结合上述缩小处理技术和积分图加速处理技术来进行滤波处理操作。It should be noted that, in the embodiment of the present invention, optimally, the filtering processing operation may be performed in combination with the above-mentioned reduction processing technology and integral graph acceleration processing technology.

例如,将原始亮度图像缩小k倍,记缩小后得到的图像为X;然后计算图像X中每个像素点的Y分量的平方值,获得图像Y;再获得分别对应该图像X以及该图像Y的积分图像W以及积分图像V。For example, reduce the original brightness image by k times, and denote the image obtained after the reduction as X; then calculate the square value of the Y component of each pixel in the image X to obtain the image Y; then obtain the corresponding image X and the image Y respectively The integral image W and integral image V of .

然后,基于积分图像W以及积分图像V,计算图像X中,每一个像素点对应的具有预设窗口大小值的窗口中所有的像素点对应的方差和平均值。例如,在图像X中像素坐标为(i,j)的像素点所对应的窗口中,所有的像素点的方差为σ3,平均值为

Figure BDA0001120683910000133
那么此时,在原始亮度图像中以(ki,kj)为左上角,大小为k×k的正方形区域内任一像素点都按照如下公式计算滤波后的值:Then, based on the integral image W and the integral image V, in the image X, the variance and the average value corresponding to all the pixel points in the window with the preset window size value corresponding to each pixel point are calculated. For example, in the window corresponding to the pixel whose pixel coordinate is (i, j) in the image X, the variance of all the pixels is σ 3 , and the average value is
Figure BDA0001120683910000133
Then, in the original brightness image, with (ki, kj) as the upper left corner, any pixel in a square area of size k×k calculates the filtered value according to the following formula:

Figure BDA0001120683910000134
Figure BDA0001120683910000134

式中,Y’为原始亮度图像中该正方形区域内的某一像素点的亮度分量,Yc为原始亮度图像中该像素点对应的滤波处理后的亮度分量,ε1仍然为前述第一平滑参数。In the formula, Y' is the luminance component of a certain pixel in the square area in the original luminance image, Y c is the filtered luminance component corresponding to the pixel in the original luminance image, and ε 1 is still the aforementioned first smoothing parameter.

S103:对该原始亮度图像进行曲线调整,得到第二亮度图像。S103: Perform curve adjustment on the original brightness image to obtain a second brightness image.

对原始亮度图像的曲线调整可以通过现有技术中的上凸函数来实现,例如通过三次样条曲线来调整。为了使曲线调整的参数调整更加方便,设置了一种全新的二次曲线,即在本发明实施例中,上述对该原始亮度图像进行曲线调整,得到第二亮度图像(S103),包括:The curve adjustment of the original luminance image can be realized by the convex function in the prior art, for example, the adjustment by a cubic spline curve. In order to make the parameter adjustment of curve adjustment more convenient, a brand-new quadratic curve is set, that is, in the embodiment of the present invention, the above-mentioned curve adjustment is performed on the original brightness image to obtain a second brightness image (S103), including:

按照如下公式,调整该原始亮度图像中每个像素点的亮度分量,获得第二亮度图像:According to the following formula, adjust the luminance component of each pixel in the original luminance image to obtain a second luminance image:

Figure BDA0001120683910000141
Figure BDA0001120683910000141

式中,k为比例系数,Yh(i,j)表示该原始亮度图像中像素坐标为(i,j)的像素点对应的调整后的亮度分量,Y(i,j)表示该原始亮度图像中像素坐标为(i,j)的像素点的亮度分量。In the formula, k is the scale coefficient, Y h (i, j) represents the adjusted brightness component corresponding to the pixel whose pixel coordinate is (i, j) in the original brightness image, and Y(i, j) represents the original brightness The luminance component of the pixel whose pixel coordinate is (i, j) in the image.

可以理解,当k的取值较大时,曲线调整后的亮度分量的增加量可能会过大,而当k的取值较小时,曲线调整后的亮度分量的增加量可能会偏小,所以在实际应用中,优选的,k=0.4~0.6。It can be understood that when the value of k is large, the increase of the brightness component after the curve adjustment may be too large, and when the value of k is small, the increase of the brightness component after the curve adjustment may be small, so In practical applications, preferably, k=0.4-0.6.

此曲线调整的公式可以由如下两个公式合并得到:The formula for this curve adjustment can be obtained by combining the following two formulas:

c(x)=k(1-x)x+x (1)c(x)=k(1-x)x+x (1)

Figure BDA0001120683910000142
Figure BDA0001120683910000142

公式(1)对应的函数图像如图2所示,由于公式(1)对应的函数的值域和定义域都是[0,1],因此必须通过

Figure BDA0001120683910000143
将输入的值转换为[0,1]中的一个数值。The function image corresponding to formula (1) is shown in Figure 2. Since the value range and definition domain of the function corresponding to formula (1) are both [0, 1], it must pass
Figure BDA0001120683910000143
Convert the entered value to a numeric value in [0, 1].

应该强调的是,上述曲线调整的公式中,数值255的取值是基于常用的256级灰度确定的,实际使用过程中,还可能会出现1024级灰度等,所以上述曲线调整的公式可以为:It should be emphasized that in the above curve adjustment formula, the value of 255 is determined based on the commonly used 256-level grayscale. In actual use, 1024-level grayscale may also appear, so the above curve adjustment formula can be for:

Figure BDA0001120683910000151
Figure BDA0001120683910000151

式中,t表示灰度级数。例如,对于1024级灰度,t=1024。In the formula, t represents the number of gray levels. For example, for 1024-level grayscale, t=1024.

可以理解,采用上述曲线调整公式获得的第二亮度图像中,每个像素点的亮度分量均大于原始亮度图像中相同位置的像素点的亮度分量,所以可以把第二亮度图像看成是针对于原始亮度图像的高亮图像。另外,对于包含有人脸的图像,由于图像的亮度得到提升,相当于是对图像中的人脸做了肤色美白效果,所以相对于现有技术,本发明实施例用于图像美颜时,不需要额外的美白操作。It can be understood that in the second brightness image obtained by using the above curve adjustment formula, the brightness component of each pixel point is greater than the brightness component of the pixel point at the same position in the original brightness image, so the second brightness image can be regarded as a A highlight image of the original luminance image. In addition, for an image containing a human face, since the brightness of the image is improved, it is equivalent to whitening the skin color of the human face in the image. Therefore, compared with the prior art, when the embodiment of the present invention is used for image beautification, it does not require Extra whitening operation.

应该强调的是,曲线调整并不限于增加亮度分量,也可以是降低亮度分量,例如,用下凹函数来降低亮度分量,得到的第二亮度图像中,每个像素点的亮度分量均小于原始亮度图像中相同位置的像素点的亮度分量。It should be emphasized that the curve adjustment is not limited to increasing the brightness component, but also reducing the brightness component. For example, using a concave function to reduce the brightness component, in the obtained second brightness image, the brightness component of each pixel is smaller than the original brightness component. The luminance component of the pixel at the same position in the luminance image.

S104:基于阿尔法融合算法以及第一亮度图像,对该原始亮度图像和该第二亮度图像进行图像融合,获得目标亮度图像。S104: Based on the alpha fusion algorithm and the first brightness image, perform image fusion on the original brightness image and the second brightness image to obtain a target brightness image.

在本发明实施例中,此处所述的基于阿尔法融合算法以及第一亮度图像,对该原始亮度图像和该第二亮度图像进行图像融合,获得目标亮度图像(S104),可以包括如下三个步骤:In this embodiment of the present invention, based on the alpha fusion algorithm and the first brightness image, image fusion is performed on the original brightness image and the second brightness image to obtain a target brightness image (S104), which may include the following three step:

步骤一:按照像素点位置,分别计算该原始亮度图像与该第一亮度图像中各个像素点的亮度分量之差,获得各个像素点的亮度差异值。Step 1: Calculate the difference between the luminance components of each pixel in the original luminance image and the first luminance image according to the pixel position, and obtain the luminance difference value of each pixel.

应该说明,直接计算原始亮度图像与第一亮度图像中相同的像素点的亮度分量之差得到的差值,以256级灰度为例,该差值会在-255~255的范围内,为了将该范围控制在0~255,首先通过如下公式对该差值添加一个大小为128的偏移量:It should be noted that the difference obtained by directly calculating the difference between the luminance components of the same pixel in the original luminance image and the first luminance image, taking 256-level grayscale as an example, the difference will be in the range of -255 to 255. In order to To control the range from 0 to 255, first add an offset of 128 to the difference by the following formula:

D(i,j)=clip(Y(i,j)-Yb(i,j)+128);D(i,j)=clip(Y(i,j) -Yb (i,j)+128);

式中,D(i,j)表示初步得到的差异值,Y(i,j)表示原始亮度图像中坐标为(i,j)的像素点的亮度分量,Yb(i,j)表示第一亮度图像中坐标为(i,j)的像素点的亮度分量,另外,clip()表示一个定义如下的函数:In the formula, D(i,j) represents the difference value obtained initially, Y(i,j) represents the brightness component of the pixel whose coordinates are (i,j) in the original brightness image, and Yb (i,j) represents the first The luminance component of a pixel whose coordinates are (i, j) in a luminance image. In addition, clip() represents a function defined as follows:

Figure BDA0001120683910000161
Figure BDA0001120683910000161

在本发明实施例中,可以将该初步得到的差异值作为步骤一最终得到的像素点的亮度差异值。但是为了增加亮度差异值的差异幅度,可以将该初步得到的差异值作为自变量输入如下函数:In this embodiment of the present invention, the initially obtained difference value may be used as the brightness difference value of the pixel point finally obtained in step 1. However, in order to increase the difference range of the brightness difference value, the initially obtained difference value can be input into the following function as an independent variable:

Figure BDA0001120683910000162
Figure BDA0001120683910000162

函数f(x)的函数图像如图3所示。通过函数f(x)计算出来的结果值乘以数值255后得到的值,可以作为步骤一最终得到的像素点的亮度差异值。当然,还可以通过f(x)进行多次拉伸操作,即进一步的增加亮度差异值的差异幅度。本发明实施例并不限于用f(x)来完成拉伸操作,还可以是现有技术中的线性变换。The function image of the function f(x) is shown in Figure 3. The value obtained by multiplying the result value calculated by the function f(x) by the value 255 can be used as the brightness difference value of the pixel point finally obtained in step 1. Of course, multiple stretching operations can also be performed through f(x), that is, to further increase the difference magnitude of the luminance difference value. The embodiment of the present invention is not limited to using f(x) to complete the stretching operation, and may also be a linear transformation in the prior art.

具体的拉伸次数可以根据实际情况而定,通常情况下,可以进行三次拉伸,此时,最终得到的像素点的亮度差异值为:The specific stretching times can be determined according to the actual situation. Usually, three stretching can be carried out. At this time, the brightness difference value of the pixel points finally obtained is:

Figure BDA0001120683910000163
Figure BDA0001120683910000163

式中,M(i,j)为最终得到的像素点的亮度差异值。In the formula, M(i,j) is the brightness difference value of the pixel point finally obtained.

应该说明,以M(i,j)为像素点(i,j)的亮度分量,可以获得一亮度差异图像。另外,此步骤中所涉及的各个像素点可以是指原始亮度图像中的各个像素点,可以理解,原始亮度图像中的每个像素点都对应有一个亮度差异值。It should be noted that, taking M(i, j) as the luminance component of the pixel point (i, j), a luminance difference image can be obtained. In addition, each pixel involved in this step may refer to each pixel in the original brightness image, and it can be understood that each pixel in the original brightness image corresponds to a brightness difference value.

步骤二:基于各个像素点的亮度差异值,确定各个像素点对应的阿尔法分量。Step 2: Determine the alpha component corresponding to each pixel point based on the luminance difference value of each pixel point.

原始亮度图像中的像素点(i,j)的阿尔法通道值为M(i,j),该像素点(i,j)的阿尔法分量可以为

Figure BDA0001120683910000171
其中,t表示灰度级数;以256级灰度为例,此原始亮度图像中的像素点(i,j)的阿尔法分量可以为
Figure BDA0001120683910000172
The alpha channel value of the pixel (i, j) in the original luminance image is M(i, j), and the alpha component of the pixel (i, j) can be
Figure BDA0001120683910000171
Among them, t represents the number of gray levels; taking 256 levels of gray as an example, the alpha component of the pixel (i, j) in the original brightness image can be
Figure BDA0001120683910000172

步骤三:基于各个像素点对应的阿尔法分量,对该原始亮度图像和该第二亮度图像进行图像融合,获得目标亮度图像。Step 3: Based on the alpha component corresponding to each pixel point, perform image fusion on the original brightness image and the second brightness image to obtain a target brightness image.

对于步骤三,可以通过如下公式进行融合,进而获得目标亮度图像:For step 3, the following formula can be used for fusion to obtain the target brightness image:

Yr(i,j)=(M(i,j)Y(i,j)+(255-M(i,j))Yh(i,j))/255; Yr (i,j)=(M(i,j)Y( i ,j)+(255-M(i,j))Yh(i,j))/255;

式中,Yr(i,j)表示目标亮度图像中像素坐标为(i,j)的像素点的亮度分量,Y(i,j)表示原始亮度图像中坐标为(i,j)的像素点的亮度分量,Yh(i,j)表示该第二亮度图像中像素坐标为(i,j)的像素点的亮度分量。In the formula, Y r (i, j) represents the brightness component of the pixel whose pixel coordinate is (i, j) in the target brightness image, and Y(i, j) represents the pixel whose coordinate is (i, j) in the original brightness image The luminance component of the point, Y h (i, j) represents the luminance component of the pixel whose pixel coordinate is (i, j) in the second luminance image.

应该说明的是,步骤三可以理解为以上述亮度差异图为阿尔法通道,对该原始亮度图像和该第二亮度图像进行图像融合,获得目标亮度图像。It should be noted that step 3 can be understood as taking the above-mentioned brightness difference map as an alpha channel, and performing image fusion on the original brightness image and the second brightness image to obtain a target brightness image.

S105:基于该目标亮度图像和该原始色度图像,获得目标图像。S105: Based on the target luminance image and the original chrominance image, obtain a target image.

此处可以直接将获得的目标亮度图像与原始色度图像进行合并,获得目标图像。具体的合并方法,属于现有技术,本发明实施例在此不做详细说明。Here, the obtained target luminance image and the original chrominance image can be directly merged to obtain the target image. The specific merging method belongs to the prior art, and is not described in detail in this embodiment of the present invention.

应用本发明实施例提供的方案后,图像处理的速度大幅度增加,因此,对于图像的实时处理可以很容易地在移动设备等性能较差的设备上处理。下表1对比了不同的移动设备上分别应用现有技术以及本发明实施例提供的图像处理方法时,每秒处理的图像帧数。After applying the solution provided by the embodiment of the present invention, the speed of image processing is greatly increased, and therefore, the real-time processing of images can be easily processed on devices with poor performance such as mobile devices. Table 1 below compares the number of image frames processed per second when the prior art and the image processing method provided by the embodiment of the present invention are respectively applied to different mobile devices.

表1Table 1

Figure BDA0001120683910000181
Figure BDA0001120683910000181

应该说明,表1中的现有技术以及本发明实施例的图像处理方法,均未结合现有技术中的Neon(一种单指令多数据扩展结构)优化技术,如果结合Neon优化技术,现有技术以及本发明实施例提供的图像处理方法每秒处理的图像帧数还可以提升30%~50%。It should be noted that the prior art in Table 1 and the image processing method of the embodiment of the present invention are not combined with the Neon (a single instruction multiple data extension structure) optimization technology in the prior art. If combined with the Neon optimization technology, the existing The technology and the image processing method provided by the embodiments of the present invention can also increase the number of image frames processed per second by 30% to 50%.

由以上可见,本发明实施例提供的方案中,首先分离出原始图像的亮度分量以及色度分量,得到原始亮度图像以及原始色度图像;再基于快速滤波算法,对该原始亮度图像进行滤波处理,得到第一亮度图像;并对该原始亮度图像进行曲线调整,得到第二亮度图像;然后基于阿尔法融合算法和第一亮度图像,对该原始亮度图像和该第二亮度图像进行图像融合,获得目标亮度图像;最后基于该目标亮度图像和该原始色度图像,获得目标图像。与现有技术相比,本方案中采用的滤波算法为区别于高斯滤波法的快速滤波算法,此类快速滤波算法对图像进行滤波处理时,在保证图像处理效果的同时,还能保证图像处理算法占用的系统资源少,图像处理速度快,因此,本方案还可以应用于移动设备等性能较差的设备,以使得上述性能较差的设备可以对高质量视频图像进行实时处理。It can be seen from the above that in the solution provided by the embodiment of the present invention, the luminance component and the chrominance component of the original image are first separated to obtain the original luminance image and the original chrominance image; and then the original luminance image is filtered based on a fast filtering algorithm. , obtain a first brightness image; and perform curve adjustment on the original brightness image to obtain a second brightness image; then based on the alpha fusion algorithm and the first brightness image, perform image fusion on the original brightness image and the second brightness image to obtain A target luminance image; finally, a target image is obtained based on the target luminance image and the original chrominance image. Compared with the prior art, the filtering algorithm adopted in this solution is a fast filtering algorithm which is different from the Gaussian filtering method. When such a fast filtering algorithm performs filtering processing on an image, it can ensure the image processing effect while ensuring the image processing effect. The algorithm occupies less system resources and the image processing speed is fast. Therefore, this solution can also be applied to devices with poor performance such as mobile devices, so that the devices with poor performance can process high-quality video images in real time.

以图像中的人脸美化算法为例,本发明实施例可以对图像中的人脸进行美化处理,使图像中的人脸更加美白光洁,达到磨皮的效果。本发明实施例可以应用在具有美颜功能的软件产品中;也可以用在具有人脸检测功能的软件产品中,在人脸检测功能的软件产品检测到图像中的人脸后,对该人脸进行美化处理。Taking the face beautification algorithm in the image as an example, the embodiment of the present invention can beautify the face in the image, so that the face in the image is whiter and smoother, and achieves the effect of microdermabrasion. The embodiments of the present invention can be applied to a software product with a beauty function; and can also be used in a software product with a face detection function. After the software product with a face detection function detects a human face in an image, the The face is beautified.

在图像的人脸美化技术领域,众所周知的是,随着手机的普及,手机相机的应用也越来越多,其中与手机拍照相关的应用最多,需求量也是最大的。但是传统的手机只能简单的拍照,对于照片的美化一般需要在PC(personal computer,个人计算机)上手工完成,虽然也有一些自动化工具,但是这类工具大多是针对PC的CPU设计的。近来随着照片美化需求的增大,手机上也出现了一些针对照片美化的App(Application,应用程序),但这类App大多都是拍完照后,专门针对单张照片进行特定的美化,很少能够在预览的时候做到实时的美颜处理。In the field of image face beautification technology, it is well known that with the popularity of mobile phones, there are more and more applications of mobile phone cameras. Among them, the applications related to mobile phone photography are the most and the demand is also the largest. However, traditional mobile phones can only simply take pictures, and the beautification of pictures generally needs to be done manually on a PC (personal computer, personal computer). Although there are some automated tools, most of these tools are designed for the CPU of the PC. Recently, with the increasing demand for photo beautification, some apps (Applications) for photo beautification have appeared on mobile phones, but most of these apps are designed to beautify a single photo after taking a photo. Few can achieve real-time beauty processing during preview.

现有技术中,基于曲线调整的美颜算法可以分为以下几步:首先用高斯滤波找出斑点等颜色偏暗的区域,用一个大的高斯半径对原图的亮度图进行高斯滤波,然后用原图亮度图减去高斯滤波的图像得到一张差异图,差异图中的暗区域就是斑点所在的区域;找到暗区域后,然后对原图的亮度进行曲线调整,其方法就是用一条上凸的曲线对原图的亮度进行重新映射,这样就得到了一张高亮图,经过适当的调整可以使得高亮图中斑点的亮度与原始图中的肤色亮度接近,然后将该差异图映射到[0,1]区间,并以此作为alpha(阿尔法)通道将原图与高亮图进行融合,这样就得到了祛除斑点或是斑点变暗的图像,从而达到美颜的效果。In the prior art, the beautification algorithm based on curve adjustment can be divided into the following steps: first, use Gaussian filtering to find dark areas such as spots, and use a large Gaussian radius to perform Gaussian filtering on the brightness map of the original image, then Subtract the Gaussian filtered image from the original image brightness image to get a difference image. The dark area in the difference image is the area where the spots are located; after finding the dark area, adjust the brightness of the original image by using a The convex curve remaps the brightness of the original image, so that a highlight image is obtained. After appropriate adjustment, the brightness of the spots in the highlight image can be close to the brightness of the skin color in the original image, and then the difference map is mapped to [ 0,1] interval, and use this as the alpha (alpha) channel to fuse the original image with the highlight image, so as to obtain an image with spots removed or darkened, so as to achieve the effect of beauty.

基于曲线调整的美颜算法图像的亮度分量是整体按照平滑曲线进行调整的,所以对于头发等特别暗的区域可以比较好地保留对比度,这样进行图像调整后得到的整个图像较清晰。但是,现有技术中基于曲线调整的美颜算法进行图像处理时,需要首先找出斑点区域,对图像进行高斯模糊,而且要选用模糊半径比较大的高斯模糊,这样,美颜算法运行时会占用较多的系统资源,算法运行速度慢,对于大的视频图像无法在手机等性能较差的设备上进行实时处理。The brightness component of the beautifying algorithm image based on curve adjustment is adjusted according to a smooth curve as a whole, so the contrast can be better preserved for particularly dark areas such as hair, and the entire image obtained after image adjustment is clearer. However, in the prior art, when the beautifying algorithm based on curve adjustment performs image processing, it is necessary to first find the spot area, perform Gaussian blur on the image, and select a Gaussian blur with a relatively large blur radius. It takes up a lot of system resources, and the algorithm runs slowly. For large video images, it cannot be processed in real time on devices with poor performance such as mobile phones.

应用本发明实施例,在保证图像处理效果的同时,还能保证图像处理算法占用的系统资源少,图像处理速度快,在移动设备上处理1280x720分辨率的视频图像,移动设备只需要单核CPU就可以实现实时处理图像,移动设备的CPU占用率低,发热量少。By applying the embodiments of the present invention, while ensuring the image processing effect, it can also ensure that the image processing algorithm occupies less system resources, and the image processing speed is fast. When processing video images with a resolution of 1280×720 on a mobile device, the mobile device only needs a single-core CPU Real-time image processing can be achieved, the CPU usage of mobile devices is low, and the heat generation is low.

应该说明的是,目前用于移动设备的美颜算法主要有两大类:一种是基于曲线调整的美颜算法,而另一种是基于保边滤波的美颜算法。It should be noted that there are currently two main categories of beauty algorithms for mobile devices: one is a beauty algorithm based on curve adjustment, and the other is a beauty algorithm based on edge-preserving filtering.

基于保边滤波的美颜算法可以根据选用的保边滤波算法不同细分为多类,常用的保边滤波有双边滤波,表面模糊,局部均方差,导向图滤波,场域变换等。此类美颜算法基本思想就是利用保边滤波对原图像进行处理,从而平滑掉人脸的斑点和痘痘等瑕疵,而对于像眼睛,眉毛这种面积比较大,并且对比度明显的区域基本保持不变,从而达到人脸美化的效果。The beautification algorithm based on edge-preserving filtering can be subdivided into multiple categories according to the selected edge-preserving filtering algorithm. Commonly used edge-preserving filters include bilateral filtering, surface blurring, local mean square error, guided map filtering, and field transformation. The basic idea of this kind of beauty algorithm is to use edge-preserving filtering to process the original image, so as to smooth out the spots and acne on the face, while for the eyes and eyebrows, the area is relatively large, and the contrast area is basically maintained. unchanged, so as to achieve the effect of face beautification.

基于保边滤波的美颜算法可以很好地祛除图像中人脸上的斑点和痘痘等瑕疵,但是对于图像中头发等比较细的物体容易一并被模糊了,同时对于图像中像鼻子边缘等分界不是特别明显的地方容易造成模糊;图像中像眼睛等对比度比较明显的区域,虽然能够保持的比较好,但是还是有一定程度的模糊,图像整体上会有一定的朦胧感。The beautification algorithm based on edge-preserving filtering can well remove the spots and acne on the face of the image, but it is easy to blur the thin objects such as hair in the image, and the edge of the nose in the image is easy to be blurred. The places where the equal divisions are not particularly obvious are easy to cause blurring; although the areas with obvious contrast such as eyes in the image can be maintained well, there is still a certain degree of blurring, and the image as a whole will have a certain hazy feeling.

但是当本发明实施例中的快速滤波算法选用导向图滤波法时,不存在现有技术中的保边滤波算法造成的图像清晰度下降的问题。However, when the directed graph filtering method is selected as the fast filtering algorithm in the embodiment of the present invention, there is no problem that the image definition is reduced due to the edge-preserving filtering algorithm in the prior art.

相对于图1,如图4所示的一种图像处理方法的第二种流程示意图,上述基于该目标亮度图像和该原始色度图像,得到目标图像(S105),可以包括:With respect to FIG. 1 , as shown in the second schematic flow chart of an image processing method shown in FIG. 4 , the above-mentioned obtaining the target image based on the target luminance image and the original chromaticity image (S105) may include:

S1051:对该原始色度图像进行导向图滤波处理,获得目标色度图像。S1051: Perform guide map filtering processing on the original chrominance image to obtain a target chrominance image.

应该说明的是,原始色度图像包括U分量对应的第一色度图像以及V分量对应的第二色度图像,本发明实施例中,除了对原始亮度图像进行滤波处理外,还可以对原始色度图像进行滤波处理,即分别对该第一色度图像以及第二色度图像进行滤波处理。It should be noted that the original chrominance image includes the first chrominance image corresponding to the U component and the second chrominance image corresponding to the V component. In this embodiment of the present invention, in addition to filtering the original luminance image, the The chrominance image is filtered, that is, the first chrominance image and the second chrominance image are filtered separately.

本发明实施例中,对于原始色度图像的滤波处理方法可以与对原始亮度图像的滤波处理方法相似,具体细节可以参照前述方法实施例。具体的,上述对该原始色度图像进行导向图滤波处理,获得目标色度图像(S1051),可以包括:In this embodiment of the present invention, the filtering processing method for the original chrominance image may be similar to the filtering processing method for the original luminance image, and the specific details may refer to the foregoing method embodiments. Specifically, performing the guide map filtering process on the original chrominance image above to obtain the target chrominance image (S1051) may include:

按照以下方式,对该原始色度图像中每一像素点进行滤波处理,并根据滤波结果获得目标色度图像:Filter each pixel in the original chrominance image in the following manner, and obtain the target chrominance image according to the filtering result:

第一步:确定以第二像素点为中心的第二类预设窗口内的像素点,其中,所述第二像素点为所述第一色度图像或所述第二色度图像内的任一像素点。Step 1: Determine the pixel points in the second type of preset window centered on the second pixel point, wherein the second pixel point is the first chromaticity image or the second chromaticity image. any pixel.

该第二类预设窗口是指具有预设窗口大小值的窗口,该第二类预设窗口的中心就是上述第二像素点,即,当前正在进行滤波处理的像素点。例如,对第一色度图像中的像素点a进行滤波处理时,该第二像素点即为像素点a;同时,假设该第二类预设窗口的大小为3×3,像素点a的像素坐标为(x,y),则像素点a对应的第二类预设窗口为:原始色度图像中,像素坐标分别为(x-1,y-1)和(x+1,y+1)的两个像素点所构成的矩形区域,此时,所确定的像素点即为该矩形区域内的所有像素点。The second type of preset window refers to a window with a preset window size value, and the center of the second type of preset window is the above-mentioned second pixel, that is, the pixel currently undergoing filtering processing. For example, when filtering the pixel point a in the first chromaticity image, the second pixel point is the pixel point a; at the same time, assuming that the size of the second type of preset window is 3×3, the size of the pixel point a is If the pixel coordinates are (x, y), the second type of preset window corresponding to the pixel point a is: in the original chromaticity image, the pixel coordinates are (x-1, y-1) and (x+1, y+ respectively) 1) The rectangular area formed by the two pixel points, at this time, the determined pixel points are all the pixel points in the rectangular area.

在实际使用过程中,该第二类预设窗口的窗口大小值应根据图像的大小选择,例如,对于1920×1080的图像,可以选择该窗口大小值为3×3。In actual use, the window size value of the second type of preset window should be selected according to the size of the image. For example, for a 1920×1080 image, the window size value can be selected as 3×3.

应该说明的是,对应同一原始图像的第一类预设窗口的窗口大小值大于第二类预设窗口的窗口大小值。It should be noted that the window size value of the first type of preset windows corresponding to the same original image is larger than the window size value of the second type of preset windows.

第二步:计算所确定像素点的像素值对应的第二方差和第二平均值,可以理解,当该原始色度图像为前述第一色度图像时,该像素值为像素点对应的U分量,当该原始色度图像为前述第二色度图像时,该像素值为像素点对应的V分量。Step 2: Calculate the second variance and the second average value corresponding to the pixel value of the determined pixel point. It can be understood that when the original chromaticity image is the aforementioned first chromaticity image, the pixel value is the U corresponding to the pixel point. component, when the original chromaticity image is the aforementioned second chromaticity image, the pixel value is the V component corresponding to the pixel point.

当确定像素点后,可以依据通用的数学公式计算获得该第二方差和第二平均值。但是,当该第二类预设窗口的窗口大小值较大时,计算该第二平均值以及第二方差的运算时间就会较长,例如:对于一个11×11的第二类预设窗口,其中的像素点总数为121个,所以计算第二平均值以及第二方差所采用的数据量大,以致运算时间长。After the pixel points are determined, the second variance and the second average value can be obtained by calculation according to a general mathematical formula. However, when the window size value of the second type of preset window is larger, the calculation time of the second average value and the second variance will be longer, for example, for a 11×11 second type of preset window , the total number of pixel points is 121, so the amount of data used to calculate the second average value and the second variance is large, so the operation time is long.

在本发明实施例中,为了加快计算该第二方差和第二平均值,可以采用积分图加速处理。上述计算所确定像素点的像素值对应的第二方差和第二平均值,包括:In this embodiment of the present invention, in order to speed up the calculation of the second variance and the second average value, an integral graph may be used to speed up the processing. The second variance and the second average value corresponding to the pixel value of the determined pixel point in the above calculation include:

步骤一:计算该原始色度图像中每个像素点的像素值的平方值,获得第三色度图像。Step 1: Calculate the square value of the pixel value of each pixel in the original chromaticity image to obtain a third chromaticity image.

即表示,第三色度图像中,每个像素点的像素值为原始色度图像中对应在相同位置的像素点的像素值的平方,例如,在原始色度图像中,坐标值为(m,n)的像素点b的的像素值为M,则在第三色度图像中,坐标值为(m,n)的像素点b’的的像素值为M2That is to say, in the third chromaticity image, the pixel value of each pixel is the square of the pixel value of the pixel corresponding to the same position in the original chromaticity image. For example, in the original chromaticity image, the coordinate value is (m , n) the pixel value of the pixel point b is M, then in the third chromaticity image, the pixel value of the pixel point b' with the coordinate value (m, n) is M 2 .

步骤二:获得分别对应该原始色度图像以及该第三色度图像的第三积分图像以及第四积分图像;Step 2: obtaining a third integral image and a fourth integral image respectively corresponding to the original chromaticity image and the third chromaticity image;

可以理解,第三积分图像中,任一像素点(x,y)的像素值等于从原始色度图像的左上角到原始色度图像的像素点(x,y)所构成的矩形区域内所有的像素点的像素值之和;第四积分图像中,任一像素点(x,y)的像素值等于从第三色度图像的左上角到第三色度图像的像素点(x,y)所构成的矩形区域内所有的像素点的像素值之和。It can be understood that in the third integral image, the pixel value of any pixel point (x, y) is equal to all the pixels in the rectangular area from the upper left corner of the original chromaticity image to the pixel point (x, y) of the original chromaticity image. In the fourth integral image, the pixel value of any pixel (x, y) is equal to the pixel value from the upper left corner of the third chromaticity image to the pixel (x, y) of the third chromaticity image ) is the sum of the pixel values of all the pixels in the rectangular area.

步骤三:基于该第三积分图像以及该第四积分图像,计算所确定像素点的像素值对应的第二方差和第二平均值。Step 3: Based on the third integral image and the fourth integral image, calculate the second variance and the second average value corresponding to the pixel value of the determined pixel point.

例如,上述第二像素点的坐标为(100,50),第二预设窗口的窗口大小值为11×11,假设在原始色度图像中,以坐标为(100,50)的像素点为中心的11×11区域内,所有像素点的像素值的平均值为

Figure BDA0001120683910000221
在第四积分图像中,以坐标为(100,50)的像素点为中心的11×11区域内,所有像素点的像素值的平均值为
Figure BDA0001120683910000222
则此时所确定的像素点对应的第二方差
Figure BDA0001120683910000223
For example, the coordinates of the second pixel point above are (100, 50), and the window size of the second preset window is 11×11. Suppose that in the original chromaticity image, the pixel point with coordinates (100, 50) is In the 11×11 area in the center, the average value of all pixel points is
Figure BDA0001120683910000221
In the fourth integral image, in the 11×11 area centered on the pixel point whose coordinates are (100, 50), the average value of the pixel values of all the pixel points is
Figure BDA0001120683910000222
Then the second variance corresponding to the pixel point determined at this time
Figure BDA0001120683910000223

其中,再假设第三积分图像中,该坐标为(100,50)的像素点的像素值为Z1,坐标为(105,44)的像素点的像素值为Z2,坐标为(94,55)的像素点的像素值为Z3,坐标为(94,44)的像素点的像素值为Z4,则所确定的像素点对应的第二平均值

Figure BDA0001120683910000224
Among them, it is further assumed that in the third integral image, the pixel value of the pixel with coordinates (100, 50) is Z 1 , the pixel value of the pixel with coordinates (105, 44) is Z 2 , and the coordinates are (94, The pixel value of the pixel point of 55) is Z 3 , and the pixel value of the pixel point whose coordinates are (94, 44) is Z 4 , then the second average value corresponding to the determined pixel point
Figure BDA0001120683910000224

本领域技术人员公知的是,积分图可以用以加速计算方差和平均值,具体原理可参照现有技术以及前述对于亮度分量的滤波处理过程,本发明实施例在此不做详细介绍。It is known to those skilled in the art that the integral map can be used to speed up the calculation of variance and average value. For the specific principle, reference may be made to the prior art and the aforementioned filtering process for the luminance component, which is not described in detail in this embodiment of the present invention.

第三步:根据该第二方差和该第二平均值,对第二像素点进行滤波处理。The third step: filtering the second pixel point according to the second variance and the second average value.

在本发明实施例中,上述根据该第二方差和该第二平均值,对第二像素点进行滤波处理,可以是:In the embodiment of the present invention, the filtering processing performed on the second pixel point according to the second variance and the second average value may be:

按照如下公式,对第二像素点进行滤波处理:The second pixel is filtered according to the following formula:

Figure BDA0001120683910000225
Figure BDA0001120683910000225

式中,Xb为第二像素点滤波后的像素值;σ2为该第二方差;ε2为预设的第二平滑参数;X为第二像素点的像素值;

Figure BDA0001120683910000231
为该第二平均值。In the formula, X b is the filtered pixel value of the second pixel point; σ 2 is the second variance; ε 2 is the preset second smoothing parameter; X is the pixel value of the second pixel point;
Figure BDA0001120683910000231
is the second average.

在实际应用过程中,ε2的取值可以基于实际情况,但是对应于同一原始图像,ε2的取值应小于ε1的取值,ε2取值可以是6~10,最优取值为8。In the actual application process, the value of ε 2 can be based on the actual situation, but corresponding to the same original image, the value of ε 2 should be less than the value of ε 1 , the value of ε 2 can be 6 to 10, the optimal value is 8.

本发明实施例中,为了使得对第二像素点的滤波处理更加简单,占用的较少的系统资源,所以使用上述滤波处理的公式。当然,对第二像素点的滤波处理所采用的公式还可以参照现有技术,本发明实施例在此不做限定。In the embodiment of the present invention, in order to make the filtering processing on the second pixel point simpler and occupy less system resources, the above filtering processing formula is used. Certainly, the formula used for the filtering processing of the second pixel point may also refer to the prior art, which is not limited in this embodiment of the present invention.

另外,分别对U、V通道(色度分量)进行滤波处理时,可以参考对亮度分量的滤波处理,结合图像缩小处理技术和积分图加速处理技术来进行色度分量的滤波处理。In addition, when filtering the U and V channels (chrominance components) separately, you can refer to the filtering processing of the luminance component, and perform the filtering processing of the chrominance component by combining the image reduction processing technology and the integral image acceleration processing technology.

可以理解,对U、V通道进行滤波处理,可以使得最终得到的目标图像的颜色过渡更加自然。并且,应该强调的是,如果对于亮度分量的滤波处理占用较多的系统资源,那么系统中的资源可能不足以支持对U、V通道(色度分量)进行的滤波处理,但是由于本发明实施例中,对于亮度分量的滤波处理占用的系统资源少,所以系统中有足够的资源支持对U、V通道(色度分量)进行的滤波处理。It can be understood that filtering the U and V channels can make the color transition of the final target image more natural. Moreover, it should be emphasized that if the filtering processing of the luminance component occupies more system resources, the resources in the system may not be enough to support the filtering processing of the U and V channels (chrominance components), but due to the implementation of the present invention In an example, the filtering processing of the luminance component occupies few system resources, so there are sufficient resources in the system to support the filtering processing performed on the U and V channels (chrominance components).

S1052:合并该目标亮度图像和该目标色度图像,得到目标图像。S1052: Combine the target luminance image and the target chrominance image to obtain a target image.

当然,合并该目标亮度图像和该目标色度图像的具体方法参考现有技术,本发明实施例在此不做详细介绍。Of course, reference is made to the prior art for a specific method of combining the target luminance image and the target chrominance image, which is not described in detail in this embodiment of the present invention.

与现有技术相比,本方案中采用的滤波算法为区别于高斯滤波法的快速滤波算法,此类快速滤波算法对图像进行滤波处理时,在保证图像处理效果的同时,还能保证图像处理算法占用的系统资源少,图像处理速度快,因此,本方案还可以应用于移动设备等性能较差的设备,以使得上述性能较差的设备可以对高质量视频图像进行实时处理。更重要的,由于由于本发明实施例中,对于亮度分量的滤波处理占用的系统资源少,所以系统中有足够的资源支持对U、V通道(色度分量)进行的滤波处理,使最终得到的目标图像的颜色过渡更加自然,提升图像处理效果。Compared with the prior art, the filtering algorithm adopted in this solution is a fast filtering algorithm which is different from the Gaussian filtering method. When such a fast filtering algorithm performs filtering processing on an image, it can ensure the image processing effect while ensuring the image processing effect. The algorithm occupies less system resources and the image processing speed is fast. Therefore, this solution can also be applied to devices with poor performance such as mobile devices, so that the devices with poor performance can process high-quality video images in real time. More importantly, since in the embodiment of the present invention, the filtering processing of the luminance component occupies less system resources, there are sufficient resources in the system to support the filtering processing of the U and V channels (chrominance components), so that the final result is obtained. The color transition of the target image is more natural, improving the image processing effect.

相应于图1,如图5所示的本发明实施例提供的一种图像处理装置的第一种结构示意图,该装置包括:Corresponding to FIG. 1 , as shown in FIG. 5 , a first structural schematic diagram of an image processing apparatus provided by an embodiment of the present invention, the apparatus includes:

分离模块110,用于分离出原始图像的亮度分量以及色度分量,得到原始亮度图像以及原始色度图像;The separation module 110 is used to separate the luminance component and the chrominance component of the original image to obtain the original luminance image and the original chrominance image;

滤波处理模块120,用于基于快速滤波算法,对所述原始亮度图像进行滤波处理,得到第一亮度图像;A filtering processing module 120, configured to perform filtering processing on the original luminance image based on a fast filtering algorithm to obtain a first luminance image;

曲线调整模块130,用于对所述原始亮度图像进行曲线调整,得到第二亮度图像;a curve adjustment module 130, configured to perform curve adjustment on the original brightness image to obtain a second brightness image;

融合模块140,用于基于阿尔法融合算法以及所述第一亮度图像,对所述原始亮度图像和所述第二亮度图像进行图像融合,获得目标亮度图像;A fusion module 140, configured to perform image fusion on the original brightness image and the second brightness image based on an alpha fusion algorithm and the first brightness image to obtain a target brightness image;

获得模块150,用于基于所述目标亮度图像和所述原始色度图像,获得目标图像。The obtaining module 150 is configured to obtain a target image based on the target luminance image and the original chrominance image.

具体的,所述快速滤波算法为导向图滤波法、快速高斯滤波法以及盒子滤波法中的任意一种。Specifically, the fast filtering algorithm is any one of a guided graph filtering method, a fast Gaussian filtering method and a box filtering method.

具体的,所述融合模块140,包括第一计算子模块、第一确定子模块和融合子模块(图中未示出)。Specifically, the fusion module 140 includes a first calculation sub-module, a first determination sub-module and a fusion sub-module (not shown in the figure).

该第一计算子模块,用于按照像素点位置,分别计算所述原始亮度图像与所述第一亮度图像中各个像素点的亮度分量之差,获得各个像素点的亮度差异值;The first calculation sub-module is configured to calculate the difference between the luminance components of each pixel in the original luminance image and the first luminance image according to the pixel position, and obtain the luminance difference value of each pixel;

该第一确定子模块,用于基于各个像素点的亮度差异值,确定各个像素点对应的阿尔法分量;The first determination submodule is used to determine the alpha component corresponding to each pixel point based on the brightness difference value of each pixel point;

该融合子模块,用于基于各个像素点对应的阿尔法分量,对所述原始亮度图像和所述第二亮度图像进行图像融合,获得目标亮度图像。The fusion sub-module is configured to perform image fusion on the original brightness image and the second brightness image based on the alpha component corresponding to each pixel to obtain a target brightness image.

具体的,所述滤波处理模块120,包括处理子模块和获得子模块(图中未示出)。Specifically, the filtering processing module 120 includes a processing sub-module and an obtaining sub-module (not shown in the figure).

该处理子模块,用于对所述原始亮度图像进行缩小处理,获得第三亮度图像;The processing submodule is used for reducing the original brightness image to obtain a third brightness image;

该获得子模块,用于基于快速滤波算法以及所述第三亮度图像,获得对所述原始亮度图像进行滤波处理后得到的第一亮度图像。The obtaining sub-module is configured to obtain a first luminance image obtained by filtering the original luminance image based on the fast filtering algorithm and the third luminance image.

具体的,当所述快速滤波算法为导向图滤波法时,所述滤波处理模块120,具体用于:Specifically, when the fast filtering algorithm is a directed graph filtering method, the filtering processing module 120 is specifically used for:

对所述原始亮度图像中每一像素点进行滤波处理,并根据滤波结果获得第一亮度图像;Perform filtering processing on each pixel in the original brightness image, and obtain a first brightness image according to the filtering result;

其中,所述滤波处理模块120,包括第二确定子模块、第二计算子模块和滤波处理子模块(图中未示出)。Wherein, the filtering processing module 120 includes a second determining sub-module, a second calculating sub-module and a filtering processing sub-module (not shown in the figure).

该第二确定子模块,用于确定以第一像素点为中心的第一类预设窗口内的像素点;所述第一像素点为所述原始亮度图像内的任一像素点;The second determination submodule is used to determine a pixel point in the first type of preset window centered on the first pixel point; the first pixel point is any pixel point in the original brightness image;

该第二计算子模块,用于计算所确定像素点的亮度分量对应的第一方差和第一平均值;The second calculation submodule is used to calculate the first variance and the first average value corresponding to the brightness component of the determined pixel point;

该滤波处理子模块,用于根据所述第一方差和所述第一平均值,对所述第一像素点进行滤波处理。The filtering processing sub-module is configured to perform filtering processing on the first pixel point according to the first variance and the first average value.

在实际应用中,具体的,所述第二计算子模块,包括第一获得单元、第二获得单元和第一计算单元(图中未示出)。In practical applications, specifically, the second calculation sub-module includes a first obtaining unit, a second obtaining unit and a first calculating unit (not shown in the figure).

该第一获得单元,用于获得第四亮度图像,其中,所述第四亮度图像为:根据所述原始亮度图像中每个像素点Y分量的平方值确定的图像;The first obtaining unit is configured to obtain a fourth luminance image, wherein the fourth luminance image is: an image determined according to the square value of the Y component of each pixel in the original luminance image;

该第二获得单元,用于获得分别对应所述原始亮度图像以及所述第四亮度图像的第一积分图像以及第二积分图像;the second obtaining unit, configured to obtain a first integral image and a second integral image respectively corresponding to the original luminance image and the fourth luminance image;

该第一计算单元,用于基于所述第一积分图像以及所述第二积分图像,计算所确定像素点的亮度分量对应的第一方差和第一平均值。The first calculation unit is configured to calculate, based on the first integral image and the second integral image, a first variance and a first average value corresponding to the luminance component of the determined pixel point.

在实际应用中,所述滤波处理子模块,具体用于:In practical applications, the filtering processing sub-module is specifically used for:

按照如下公式,对所述第一像素点进行滤波处理:According to the following formula, filter processing is performed on the first pixel point:

Figure BDA0001120683910000251
Figure BDA0001120683910000251

式中,Yb为所述第一像素点滤波后的亮度分量;σ1为所述第一方差;ε1为预设的第一平滑参数;Y为所述第一像素点的亮度分量;

Figure BDA0001120683910000261
为所述第一平均值。In the formula, Y b is the filtered luminance component of the first pixel; σ 1 is the first variance; ε 1 is the preset first smoothing parameter; Y is the luminance component of the first pixel ;
Figure BDA0001120683910000261
is the first average value.

在实际应用中,所述曲线调整模块130,具体用于:In practical applications, the curve adjustment module 130 is specifically used for:

按照如下公式,调整所述原始亮度图像中每个像素点的亮度分量,获得第二亮度图像:According to the following formula, adjust the luminance component of each pixel in the original luminance image to obtain a second luminance image:

Figure BDA0001120683910000262
Figure BDA0001120683910000262

式中,k为比例系数,Yh(i,j)表示所述原始亮度图像中像素坐标为(i,j)的像素点对应的调整后的亮度分量,Y(i,j)表示所述原始亮度图像中像素坐标为(i,j)的像素点的亮度分量。In the formula, k is the scale coefficient, Y h (i, j) represents the adjusted brightness component corresponding to the pixel point whose pixel coordinate is (i, j) in the original brightness image, and Y(i, j) represents the The luminance component of the pixel whose pixel coordinate is (i, j) in the original luminance image.

由以上可见,本发明实施例提供的方案中,首先分离出原始图像的亮度分量以及色度分量,得到原始亮度图像以及原始色度图像;再基于快速滤波算法,对该原始亮度图像进行滤波处理,得到第一亮度图像;并对该原始亮度图像进行曲线调整,得到第二亮度图像;然后基于阿尔法融合算法和第一亮度图像,对该原始亮度图像和该第二亮度图像进行图像融合,获得目标亮度图像;最后基于该目标亮度图像和该原始色度图像,获得目标图像。与现有技术相比,本方案中采用的滤波算法为区别于高斯滤波法的快速滤波算法,此类快速滤波算法对图像进行滤波处理时,在保证图像处理效果的同时,还能保证图像处理算法占用的系统资源少,图像处理速度快,因此,本方案还可以应用于移动设备等性能较差的设备,以使得上述性能较差的设备可以对高质量视频图像进行实时处理。It can be seen from the above that in the solution provided by the embodiment of the present invention, the luminance component and the chrominance component of the original image are first separated to obtain the original luminance image and the original chrominance image; and then the original luminance image is filtered based on a fast filtering algorithm. , obtain a first brightness image; and perform curve adjustment on the original brightness image to obtain a second brightness image; then based on the alpha fusion algorithm and the first brightness image, perform image fusion on the original brightness image and the second brightness image to obtain A target luminance image; finally, a target image is obtained based on the target luminance image and the original chrominance image. Compared with the prior art, the filtering algorithm adopted in this solution is a fast filtering algorithm which is different from the Gaussian filtering method. When such a fast filtering algorithm performs filtering processing on an image, it can ensure the image processing effect while ensuring the image processing effect. The algorithm occupies less system resources and the image processing speed is fast. Therefore, this solution can also be applied to devices with poor performance such as mobile devices, so that the devices with poor performance can process high-quality video images in real time.

相应于图4所示方法实施例,如图6所示本的发明实施例提供的一种图像处理装置的第二种结构示意图,所述获得模块150,包括:Corresponding to the method embodiment shown in FIG. 4 , as shown in FIG. 6 , a second schematic structural diagram of an image processing apparatus provided by an embodiment of the present invention, the obtaining module 150 includes:

导向图滤波处理子模块1501,用于对所述原始色度图像进行导向图滤波处理,获得目标色度图像;The guide map filtering processing sub-module 1501 is used to perform guide map filtering processing on the original chromaticity image to obtain a target chromaticity image;

合并子模块1502,用于合并所述目标亮度图像和所述目标色度图像,得到目标图像。The merging sub-module 1502 is used for merging the target luminance image and the target chrominance image to obtain a target image.

在实际应用中,所述原始色度图像包括U分量对应的第一色度图像以及V分量对应的第二色度图像,所述导向图滤波处理子模块,具体用于:In practical applications, the original chrominance image includes a first chrominance image corresponding to the U component and a second chrominance image corresponding to the V component, and the guide map filtering processing sub-module is specifically used for:

对所述第一色度图像中每一像素点进行滤波处理,并根据滤波结果获得第一目标色度图像,对所述第二色度图像中每一像素点进行滤波处理,并根据滤波结果获得第二目标色度图像;Perform filtering processing on each pixel in the first chromaticity image, and obtain a first target chromaticity image according to the filtering result, perform filtering processing on each pixel in the second chromaticity image, and obtain a first target chromaticity image according to the filtering result. obtain a second target chromaticity image;

其中,所述导向图滤波处理子模块1501,包括确定单元、第三计算单元和滤波处理单元(图中未示出)。Wherein, the guide map filtering processing sub-module 1501 includes a determining unit, a third computing unit and a filtering processing unit (not shown in the figure).

确定单元,用于确定以第二像素点为中心的第二类预设窗口内的像素点,其中,所述第二像素点为所述第一色度图像或所述第二色度图像内的任一像素点;A determination unit, configured to determine a pixel point within a second type of preset window centered on a second pixel point, wherein the second pixel point is within the first chromaticity image or the second chromaticity image any pixel of ;

第二计算单元,用于计算所确定像素点的像素值对应的第二方差和第二平均值;a second calculation unit, configured to calculate the second variance and the second average value corresponding to the pixel value of the determined pixel point;

滤波处理单元,用于根据所述第二方差和所述第二平均值,对所述第二像素点进行滤波处理。A filtering processing unit, configured to perform filtering processing on the second pixel point according to the second variance and the second average value.

具体的,所述第三计算单元,可以包括第一计算子单元、获得子单元和第二计算子单元(图中未示出)。Specifically, the third calculation unit may include a first calculation subunit, an obtaining subunit, and a second calculation subunit (not shown in the figure).

第一计算子单元,用于计算所述原始色度图像中每个像素点的像素值的平方值,获得第三色度图像;a first calculation subunit, used to calculate the square value of the pixel value of each pixel in the original chromaticity image to obtain a third chromaticity image;

获得子单元,用于获得分别对应所述原始色度图像以及所述第三色度图像的第三积分图像以及第四积分图像;an obtaining subunit for obtaining a third integral image and a fourth integral image corresponding to the original chromaticity image and the third chromaticity image respectively;

第二计算子单元,用于基于所述第三积分图像以及所述第四积分图像,计算所确定像素点的像素值对应的第二方差和第二平均值。The second calculation subunit is configured to calculate the second variance and the second average value corresponding to the pixel value of the determined pixel point based on the third integral image and the fourth integral image.

在实际应用中,所述滤波处理单元,具体用于:In practical applications, the filtering processing unit is specifically used for:

按照如下公式,对所述第二像素点进行滤波处理:According to the following formula, filter processing is performed on the second pixel point:

Figure BDA0001120683910000271
Figure BDA0001120683910000271

式中,Xb为所述第二像素点滤波后的像素值;σ2为所述第二方差;ε2为预设的第二平滑参数;X为所述第二像素点的像素值;

Figure BDA0001120683910000281
为所述第二平均值。In the formula, X b is the filtered pixel value of the second pixel point; σ 2 is the second variance; ε 2 is the preset second smoothing parameter; X is the pixel value of the second pixel point;
Figure BDA0001120683910000281
is the second average value.

与现有技术相比,本方案中采用的滤波算法为区别于高斯滤波法的快速滤波算法,此类快速滤波算法对图像进行滤波处理时,在保证图像处理效果的同时,还能保证图像处理算法占用的系统资源少,图像处理速度快,因此,本方案还可以应用于移动设备等性能较差的设备,以使得上述性能较差的设备可以对高质量视频图像进行实时处理。更重要的,由于由于本发明实施例中,对于亮度分量的滤波处理占用的系统资源少,所以系统中有足够的资源支持对U、V通道(色度分量)进行的滤波处理,使最终得到的目标图像的颜色过渡更加自然,提升图像处理效果。Compared with the prior art, the filtering algorithm adopted in this solution is a fast filtering algorithm which is different from the Gaussian filtering method. When such a fast filtering algorithm performs filtering processing on an image, it can ensure the image processing effect while ensuring the image processing effect. The algorithm occupies less system resources and the image processing speed is fast. Therefore, this solution can also be applied to devices with poor performance such as mobile devices, so that the devices with poor performance can process high-quality video images in real time. More importantly, since in the embodiment of the present invention, the filtering processing of the luminance component occupies less system resources, there are sufficient resources in the system to support the filtering processing of the U and V channels (chrominance components), so that the final result is obtained. The color transition of the target image is more natural, improving the image processing effect.

需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that, in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any relationship between these entities or operations. any such actual relationship or sequence exists. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, method, article or device that includes a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, method, article or apparatus. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in a process, method, article or apparatus that includes the element.

本说明书中的各个实施例均采用相关的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于装置实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。Each embodiment in this specification is described in a related manner, and the same and similar parts between the various embodiments may be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the apparatus embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and reference may be made to some descriptions of the method embodiments for related parts.

本领域普通技术人员可以理解实现上述方法实施方式中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,所述的程序可以存储于计算机可读取存储介质中,这里所称得的存储介质,如:ROM/RAM、磁碟、光盘等。Those of ordinary skill in the art can understand that all or part of the steps in the implementation of the above method can be completed by instructing the relevant hardware through a program, and the program can be stored in a computer-readable storage medium. Storage medium, such as: ROM/RAM, magnetic disk, optical disk, etc.

以上所述仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内所作的任何修改、等同替换、改进等,均包含在本发明的保护范围内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (20)

1. An image processing method, characterized in that the method comprises:
separating out a brightness component and a chrominance component of an original image to obtain an original brightness image and an original chrominance image;
based on a rapid filtering algorithm, filtering the original brightness image to obtain a first brightness image;
performing curve adjustment on the original brightness image to obtain a second brightness image;
performing image fusion on the original brightness image and the second brightness image based on an alpha fusion algorithm and the first brightness image to obtain a target brightness image;
obtaining a target image based on the target brightness image and the original chrominance image;
wherein the image fusing the original luminance image and the second luminance image based on an alpha fusion algorithm and the first luminance image to obtain a target luminance image includes:
according to the positions of the pixels, respectively calculating the difference of the brightness components of each pixel in the original brightness image and the first brightness image to obtain the brightness difference value of each pixel;
determining alpha components corresponding to the pixel points based on the brightness difference values of the pixel points;
and carrying out image fusion on the original brightness image and the second brightness image based on the alpha component corresponding to each pixel point to obtain a target brightness image.
2. The method of claim 1, wherein the fast filtering algorithm is any one of a guide map filtering method, a fast gaussian filtering method, and a box filtering method.
3. The method according to claim 1, wherein the filtering the original luminance image based on the fast filtering algorithm to obtain a first luminance image comprises:
carrying out reduction processing on the original brightness image to obtain a third brightness image;
and obtaining a first brightness image obtained by filtering the original brightness image based on a rapid filtering algorithm and the third brightness image.
4. The method according to claim 1, wherein when the fast filtering algorithm is a guide map filtering method, the filtering the original luminance image based on the fast filtering algorithm to obtain a first luminance image comprises:
according to the following mode, filtering processing is carried out on each pixel point in the original brightness image, and a first brightness image is obtained according to a filtering result:
determining pixel points in a first-class preset window with a first pixel point as a center, wherein the first pixel point is any pixel point in the original brightness image;
calculating a first variance and a first average value corresponding to the brightness component of the determined pixel point;
and carrying out filtering processing on the first pixel point according to the first variance and the first average value.
5. The method of claim 4, wherein the calculating a first variance and a first mean corresponding to the luminance component of the determined pixel point comprises:
obtaining a fourth luminance image, wherein the fourth luminance image is: determining an image according to a square value of Y component of each pixel point in the original brightness image;
obtaining a first integral image and a second integral image respectively corresponding to the original brightness image and the fourth brightness image;
and calculating a first variance and a first average value corresponding to the brightness component of the determined pixel point based on the first integral image and the second integral image.
6. The method according to claim 4, wherein the filtering the first pixel according to the first variance and the first mean value comprises:
and carrying out filtering processing on the first pixel point according to the following formula:
Figure FDA0002728452370000021
in the formula, YbFiltering the brightness component of the first pixel point; sigma1Is the first variance;1is a preset first smoothing parameter; y is the brightness component of the first pixel point;
Figure FDA0002728452370000022
is the first average value.
7. The method of claim 1, wherein the curve adjusting the original luminance image to obtain a second luminance image comprises:
adjusting the brightness component of each pixel point in the original brightness image according to the following formula to obtain a second brightness image:
Figure FDA0002728452370000031
wherein k is a proportionality coefficient and Y ish(i, j) represents the adjusted brightness component corresponding to the pixel point with the pixel coordinate (i, j) in the original brightness image, and Y (i, j) represents the brightness component of the pixel point with the pixel coordinate (i, j) in the original brightness image.
8. The method of claim 1, wherein deriving a target image based on the target luma image and the original chroma images comprises:
conducting guide map filtering processing on the original chrominance image to obtain a target chrominance image;
and combining the target brightness image and the target chromaticity image to obtain a target image.
9. The method of claim 8, wherein the original chroma image comprises: a first chrominance image corresponding to the U component and a second chrominance image corresponding to the V component,
the step of performing guide map filtering processing on the original chrominance image to obtain a target chrominance image comprises:
according to the following mode, filtering each pixel point in the first chrominance image, obtaining a first target chrominance image according to a filtering result, filtering each pixel point in the second chrominance image, and obtaining a second target chrominance image according to the filtering result:
determining a pixel point in a second-class preset window with a second pixel point as a center, wherein the second pixel point is any one pixel point in the first chrominance image or the second chrominance image;
calculating a second variance and a second average value corresponding to the pixel value of the determined pixel point;
and carrying out filtering processing on the second pixel point according to the second variance and the second average value.
10. The method according to claim 9, wherein the filtering the second pixel according to the second variance and the second average value includes:
and carrying out filtering processing on the second pixel point according to the following formula:
Figure FDA0002728452370000032
in the formula, XbFiltering the pixel value of the second pixel point; sigma2Is the second variance;2the second smoothing parameter is preset; x is the pixel value of the second pixel point;
Figure FDA0002728452370000041
is the second average value.
11. An image processing apparatus, characterized in that the apparatus comprises:
the separation module is used for separating the brightness component and the chrominance component of the original image to obtain an original brightness image and an original chrominance image;
the filtering processing module is used for carrying out filtering processing on the original brightness image based on a rapid filtering algorithm to obtain a first brightness image;
the curve adjusting module is used for adjusting the curve of the original brightness image to obtain a second brightness image;
the fusion module is used for carrying out image fusion on the original brightness image and the second brightness image based on an alpha fusion algorithm and the first brightness image to obtain a target brightness image;
an obtaining module, configured to obtain a target image based on the target luminance image and the original chrominance image;
wherein, the fusion module comprises:
the first calculation submodule is used for respectively calculating the difference of the brightness components of each pixel point in the original brightness image and the first brightness image according to the position of the pixel point to obtain the brightness difference value of each pixel point;
the first determining submodule is used for determining alpha components corresponding to the pixels based on the brightness difference value of each pixel;
and the fusion submodule is used for carrying out image fusion on the original brightness image and the second brightness image based on the alpha component corresponding to each pixel point to obtain a target brightness image.
12. The apparatus of claim 11, wherein the fast filtering algorithm is any one of a guide map filtering method, a fast gaussian filtering method, and a box filtering method.
13. The apparatus of claim 11, wherein the filter processing module comprises:
the processing submodule is used for carrying out reduction processing on the original brightness image to obtain a third brightness image;
and the obtaining submodule is used for obtaining a first brightness image obtained after filtering the original brightness image based on a rapid filtering algorithm and the third brightness image.
14. The apparatus according to claim 11, wherein when the fast filtering algorithm is a guided graph filtering method, the filtering processing module is specifically configured to:
filtering each pixel point in the original brightness image, and obtaining a first brightness image according to a filtering result;
wherein, the filtering processing module comprises:
the second determining submodule is used for determining pixel points in a first-class preset window with the first pixel points as centers; the first pixel point is any pixel point in the original brightness image;
the second calculation submodule is used for calculating a first variance and a first average value corresponding to the brightness component of the determined pixel point;
and the filtering processing submodule is used for carrying out filtering processing on the first pixel point according to the first variance and the first average value.
15. The apparatus of claim 14, wherein the second computation submodule comprises:
a first obtaining unit, configured to obtain a fourth luminance image, where the fourth luminance image is: determining an image according to a square value of Y component of each pixel point in the original brightness image;
a second obtaining unit configured to obtain a first integral image and a second integral image that respectively correspond to the original luminance image and the fourth luminance image;
and the first calculation unit is used for calculating a first variance and a first average value corresponding to the brightness component of the determined pixel point based on the first integral image and the second integral image.
16. The apparatus according to claim 14, wherein the filtering processing sub-module is specifically configured to:
and carrying out filtering processing on the first pixel point according to the following formula:
Figure FDA0002728452370000051
in the formula, YbFiltering the brightness component of the first pixel point; sigma1Is the first variance;1is a preset first smoothing parameter; y is the brightness component of the first pixel point;
Figure FDA0002728452370000052
is the first average value.
17. The apparatus of claim 11, wherein the curve adjustment module is specifically configured to:
adjusting the brightness component of each pixel point in the original brightness image according to the following formula to obtain a second brightness image:
Figure FDA0002728452370000061
wherein k is a proportionality coefficient and Y ish(i, j) represents the adjusted brightness component corresponding to the pixel point with the pixel coordinate (i, j) in the original brightness image, and Y (i, j) represents the brightness component of the pixel point with the pixel coordinate (i, j) in the original brightness image.
18. The apparatus of claim 11, wherein the obtaining module comprises:
the guide map filtering processing submodule is used for carrying out guide map filtering processing on the original chrominance image to obtain a target chrominance image;
and the merging submodule is used for merging the target brightness image and the target chrominance image to obtain a target image.
19. The apparatus of claim 18, wherein the original chroma image comprises: the first chrominance image corresponding to the U component and the second chrominance image corresponding to the V component, the guide map filtering processing sub-module is specifically configured to:
filtering each pixel point in the first chrominance image, obtaining a first target chrominance image according to a filtering result, filtering each pixel point in the second chrominance image, and obtaining a second target chrominance image according to the filtering result;
wherein, the guide graph filtering processing submodule comprises:
the determining unit is used for determining pixel points in a second-class preset window with second pixel points as centers, wherein the second pixel points are any pixel points in the first chrominance image or the second chrominance image;
the second calculation unit is used for calculating a second variance and a second average value corresponding to the pixel value of the determined pixel point;
and the filtering processing unit is used for carrying out filtering processing on the second pixel point according to the second variance and the second average value.
20. The apparatus according to claim 19, wherein the filtering processing unit is specifically configured to:
and carrying out filtering processing on the second pixel point according to the following formula:
Figure FDA0002728452370000071
in the formula, XbFiltering the pixel value of the second pixel point; sigma2Is the second variance;2the second smoothing parameter is preset; x is the pixel value of the second pixel point;
Figure FDA0002728452370000072
is the second average value.
CN201610853241.XA 2016-09-26 2016-09-26 An image processing method and device Active CN107871303B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610853241.XA CN107871303B (en) 2016-09-26 2016-09-26 An image processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610853241.XA CN107871303B (en) 2016-09-26 2016-09-26 An image processing method and device

Publications (2)

Publication Number Publication Date
CN107871303A CN107871303A (en) 2018-04-03
CN107871303B true CN107871303B (en) 2020-11-27

Family

ID=61752179

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610853241.XA Active CN107871303B (en) 2016-09-26 2016-09-26 An image processing method and device

Country Status (1)

Country Link
CN (1) CN107871303B (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110858281B (en) * 2018-08-22 2022-10-04 浙江宇视科技有限公司 Image processing method, image processing device, electronic eye and storage medium
CN109580619B (en) * 2018-12-03 2021-09-17 余姚市腾翔电子科技有限公司 Bathtub blocking alarm mechanism
CN109829859B (en) * 2018-12-05 2024-05-24 平安科技(深圳)有限公司 Image processing method and terminal device
CN109308868B (en) * 2018-12-18 2021-03-19 惠科股份有限公司 Display panel driving method and system and display device
CN110379358B (en) * 2019-07-04 2021-03-30 南京宇丰晔禾信息科技有限公司 LED display screen image playing and controlling method and device
WO2021056538A1 (en) * 2019-09-29 2021-04-01 深圳市大疆创新科技有限公司 Image processing method and device
EP3937492B1 (en) * 2020-07-07 2024-09-04 Google LLC Alpha channel post processing in image coding
CN111918095B (en) * 2020-08-05 2022-06-03 广州市百果园信息技术有限公司 Dim light enhancement method and device, mobile terminal and storage medium
CN111899197B (en) * 2020-08-05 2024-04-30 广州市百果园信息技术有限公司 Image brightening and denoising method and device, mobile terminal and storage medium
CN115222607B (en) * 2021-04-20 2025-10-31 Oppo广东移动通信有限公司 Eye image processing method and device, electronic equipment and storage medium
CN113793247A (en) * 2021-07-08 2021-12-14 福建榕基软件股份有限公司 Ornament image beautifying method and terminal

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5831604A (en) * 1996-06-03 1998-11-03 Intel Corporation Alpha blending palettized image data
CN102231206A (en) * 2011-07-14 2011-11-02 浙江理工大学 Colorized night vision image brightness enhancement method applicable to automotive assisted driving system
CN104240194A (en) * 2014-04-29 2014-12-24 西南科技大学 Low-light-level image enhancement algorithm based on parabolic function
CN104537615A (en) * 2014-12-04 2015-04-22 大连理工大学 Local Retinex enhancement algorithm based on HSV color spaces
CN105931206A (en) * 2016-05-10 2016-09-07 深圳市和天创科技有限公司 Method for enhancing sharpness of color image with color constancy
CN105956993A (en) * 2016-05-03 2016-09-21 成都索贝数码科技股份有限公司 Instant presenting method of mobile end video beauty based on GPU

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7970206B2 (en) * 2006-12-13 2011-06-28 Adobe Systems Incorporated Method and system for dynamic, luminance-based color contrasting in a region of interest in a graphic image
TW201432622A (en) * 2012-11-07 2014-08-16 Koninkl Philips Nv Generation of a depth map for an image
US9654700B2 (en) * 2014-09-16 2017-05-16 Google Technology Holdings LLC Computational camera using fusion of image sensors

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5831604A (en) * 1996-06-03 1998-11-03 Intel Corporation Alpha blending palettized image data
CN102231206A (en) * 2011-07-14 2011-11-02 浙江理工大学 Colorized night vision image brightness enhancement method applicable to automotive assisted driving system
CN104240194A (en) * 2014-04-29 2014-12-24 西南科技大学 Low-light-level image enhancement algorithm based on parabolic function
CN104537615A (en) * 2014-12-04 2015-04-22 大连理工大学 Local Retinex enhancement algorithm based on HSV color spaces
CN105956993A (en) * 2016-05-03 2016-09-21 成都索贝数码科技股份有限公司 Instant presenting method of mobile end video beauty based on GPU
CN105931206A (en) * 2016-05-10 2016-09-07 深圳市和天创科技有限公司 Method for enhancing sharpness of color image with color constancy

Also Published As

Publication number Publication date
CN107871303A (en) 2018-04-03

Similar Documents

Publication Publication Date Title
CN107871303B (en) An image processing method and device
Li et al. Visual-salience-based tone mapping for high dynamic range images
CN104067311B (en) Digital makeup
US9514525B2 (en) Temporal filtering for image data using spatial filtering and noise history
US9413951B2 (en) Dynamic motion estimation and compensation for temporal filtering
US9672414B2 (en) Enhancement of skin, including faces, in photographs
CN107204034B (en) An image processing method and terminal
CN107993209B (en) Image processing method, apparatus, computer-readable storage medium and electronic device
US20140079319A1 (en) Methods for enhancing images and apparatuses using the same
JP4858609B2 (en) Noise reduction device, noise reduction method, and noise reduction program
CN108027961A (en) Method and apparatus for inverse tone mapping (ITM)
WO2018082185A1 (en) Image processing method and device
CN105096267B (en) A kind of method and apparatus that eye brightness is adjusted based on identification of taking pictures
KR102819311B1 (en) Content based image processing
CN111369478B (en) Face image enhancement method and device, computer equipment and storage medium
US8488899B2 (en) Image processing apparatus, method and recording medium
CN110706162B (en) Image processing method, device and computer storage medium
WO2016189901A1 (en) Image processing device, image processing method, program, recording medium recording same, video capture device, and video recording/reproduction device
WO2017161542A1 (en) Skin map-aided skin smoothing of images using a bilateral filter
CN114862729A (en) Image processing method, image processing device, computer equipment and storage medium
CN115082350A (en) Stroboscopic image processing method and device, electronic device and readable storage medium
RU2332716C2 (en) Method and device for anisotropic filtering of dynamic video picture
CN113298888A (en) Image processing method, device, equipment and storage medium
HK40073122B (en) Image processing method, device, computer equipment and storage medium
CN116894788A (en) Image processing methods, devices, electronic equipment and storage media

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