CN109903224B - Image scaling method and device, computer equipment and storage medium - Google Patents
Image scaling method and device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN109903224B CN109903224B CN201910071588.2A CN201910071588A CN109903224B CN 109903224 B CN109903224 B CN 109903224B CN 201910071588 A CN201910071588 A CN 201910071588A CN 109903224 B CN109903224 B CN 109903224B
- Authority
- CN
- China
- Prior art keywords
- value
- original pixel
- neighborhood
- point
- 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
Links
Images
Landscapes
- Image Processing (AREA)
Abstract
Description
技术领域Technical Field
本申请涉及图像处理技术领域,特别是涉及一种图像缩放方法、装置、计算机设备和存储介质。The present application relates to the field of image processing technology, and in particular to an image scaling method, device, computer equipment and storage medium.
背景技术Background Art
随着显示技术的发展,对不同分辨率之间的图像缩放技术的需求也在提升,例如高清或超高清显示技术中,需要通过图像缩放技术将现有视频资源缩放至匹配的大小以在小屏或超高清屏进行缩放显示,以满足显示分辨率要求。With the development of display technology, the demand for image scaling technology between different resolutions is also increasing. For example, in high-definition or ultra-high-definition display technology, image scaling technology is needed to scale existing video resources to a matching size so as to be scaled and displayed on a small screen or ultra-high-definition screen to meet the display resolution requirements.
传统的图像缩放方法主要有基于低通滤波的插值方法和基于边缘的插值方法。其中低通滤波插值方法包括如双线性插值、双三次插值等。在传统图像插值算法中,邻插值较简单,容易实现,早期的时候应用比较普遍,但是该方法会在新图像中产生明显的锯齿边缘和马赛克现象。双线性插值法具有平滑功能,能有效地克服邻法的不足,但会退化图像的高频部分,使图像细节变模糊。在放大倍数比较高时,高阶插值,如双三次和三次样条插值等比低阶插值效果好。Traditional image scaling methods mainly include low-pass filtering-based interpolation methods and edge-based interpolation methods. Among them, low-pass filtering interpolation methods include bilinear interpolation, bicubic interpolation, etc. In traditional image interpolation algorithms, neighbor interpolation is simpler and easier to implement. It was widely used in the early days, but this method will produce obvious jagged edges and mosaic phenomena in the new image. Bilinear interpolation has a smoothing function and can effectively overcome the shortcomings of the neighbor method, but it will degenerate the high-frequency part of the image and blur the image details. When the magnification is relatively high, high-order interpolation, such as bicubic and cubic spline interpolation, is better than low-order interpolation.
传统的图像缩放方法通过插值运算可以使插值生成的像素灰度值延续原图像灰度变化的连续性,从而使缩放后得到的图像浓淡变化自然平滑。但是在图像中,有些像素与相邻像素间灰度值存在突变,即存在灰度不连续性,这些具有灰度值突变的像素就是图像中描述对象的轮廓或纹理图像的边缘像素,在图像放大中,对这些具有不连续灰度特性的像素,如果采用常规的插值算法生成新增加的像素,势必会使放大后的图像的轮廓和纹理模糊,边缘信息丢失,导致缩放后得到的图像质量差。Traditional image scaling methods use interpolation operations to make the interpolated pixel grayscale values continue the continuity of the original image grayscale changes, so that the image obtained after scaling has natural and smooth changes in light and dark. However, in the image, there are mutations in the grayscale values between some pixels and adjacent pixels, that is, there is grayscale discontinuity. These pixels with grayscale mutations are the edge pixels of the image that describe the outline of the object or the texture image. In image magnification, for these pixels with discontinuous grayscale characteristics, if conventional interpolation algorithms are used to generate new pixels, the outline and texture of the enlarged image will inevitably be blurred, and the edge information will be lost, resulting in poor image quality after scaling.
发明内容Summary of the invention
基于此,有必要针对上述技术问题,提供一种能够保留图像边缘信息,提升缩放后得到的目标图像的质量的图像缩放方法、装置、计算机设备和存储介质。Based on this, it is necessary to provide an image scaling method, device, computer equipment and storage medium that can retain image edge information and improve the quality of the target image obtained after scaling to address the above technical problems.
一种图像缩放方法,所述方法包括:An image scaling method, the method comprising:
获取目标图像中的待插值像素点;确定待插值像素点在原始图像中的映射坐标点,并获取原始图像中映射坐标点周围预设邻域内各个原始像素点的像素值;根据邻域内各个原始像素点的像素值,确定映射坐标点的边缘梯度方向信息和边缘强度信息;根据映射坐标点与邻域内各个原始像素点之间的高斯距离,确定邻域内各个原始像素点的权重;根据边缘梯度方向信息、边缘强度信息和高斯距离,确定邻域内各个原始像素点的边缘增强衰减矫正系数;利用边缘增强衰减矫正系数对各个原始像素点的权重进行加权,得到卷积滤波权重;根据卷积滤波权重与邻域内各个原始像素点的像素值的乘积,确定目标图像中待插值像素点的像素值。Obtain the pixel point to be interpolated in the target image; determine the mapping coordinate point of the pixel point to be interpolated in the original image, and obtain the pixel value of each original pixel point in a preset neighborhood around the mapping coordinate point in the original image; determine the edge gradient direction information and edge intensity information of the mapping coordinate point according to the pixel value of each original pixel point in the neighborhood; determine the weight of each original pixel point in the neighborhood according to the Gaussian distance between the mapping coordinate point and each original pixel point in the neighborhood; determine the edge enhancement attenuation correction coefficient of each original pixel point in the neighborhood according to the edge gradient direction information, edge intensity information and Gaussian distance; weight the weight of each original pixel point using the edge enhancement attenuation correction coefficient to obtain the convolution filter weight; determine the pixel value of the pixel point to be interpolated in the target image according to the product of the convolution filter weight and the pixel value of each original pixel point in the neighborhood.
一种图像缩放装置,所述装置包括:An image scaling device, comprising:
待插值像素点获取模块,用于获取目标图像中的待插值像素点;The module for obtaining pixels to be interpolated is used to obtain pixels to be interpolated in the target image;
邻域像素获取模块,用于确定待插值像素点在原始图像中的映射坐标点,并获取原始图像中映射坐标点周围预设邻域内各个原始像素点的像素值;A neighborhood pixel acquisition module is used to determine the mapping coordinate point of the pixel point to be interpolated in the original image, and to obtain the pixel value of each original pixel point in a preset neighborhood around the mapping coordinate point in the original image;
边缘信息确定模块,用于根据邻域内各个原始像素点的像素值,确定映射坐标点的边缘梯度方向信息和边缘强度信息;An edge information determination module is used to determine edge gradient direction information and edge intensity information of a mapping coordinate point according to the pixel value of each original pixel point in the neighborhood;
原始权重确定模块,用于根据映射坐标点与邻域内各个原始像素点之间的高斯距离,确定邻域内各个原始像素点的权重;The original weight determination module is used to determine the weight of each original pixel point in the neighborhood according to the Gaussian distance between the mapped coordinate point and each original pixel point in the neighborhood;
增强衰减矫正系数确定模块,用于根据边缘梯度方向信息、边缘强度信息和高斯距离,确定邻域内各个原始像素点的边缘增强衰减矫正系数;The enhancement attenuation correction coefficient determination module is used to determine the edge enhancement attenuation correction coefficient of each original pixel in the neighborhood according to the edge gradient direction information, edge intensity information and Gaussian distance;
待插值像素点像素值确定模块,用于利用边缘增强衰减矫正系数对各个原始像素点的权重进行加权,得到卷积滤波权重;根据卷积滤波权重与邻域内各个原始像素点的像素值的乘积,确定目标图像中待插值像素点的像素值。The pixel value determination module for the pixel point to be interpolated is used to weight the weights of each original pixel point using the edge enhancement attenuation correction coefficient to obtain the convolution filter weight; according to the product of the convolution filter weight and the pixel value of each original pixel point in the neighborhood, the pixel value of the pixel point to be interpolated in the target image is determined.
一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,所述处理器执行所述计算机程序时实现以下步骤:A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
获取目标图像中的待插值像素点;确定待插值像素点在原始图像中的映射坐标点,并获取原始图像中映射坐标点周围预设邻域内各个原始像素点的像素值;根据邻域内各个原始像素点的像素值,确定映射坐标点的边缘梯度方向信息和边缘强度信息;根据映射坐标点与邻域内各个原始像素点之间的高斯距离,确定邻域内各个原始像素点的权重;根据边缘梯度方向信息、边缘强度信息和高斯距离,确定邻域内各个原始像素点的边缘增强衰减矫正系数;利用边缘增强衰减矫正系数对各个原始像素点的权重进行加权,得到卷积滤波权重;根据卷积滤波权重与邻域内各个原始像素点的像素值的乘积,确定目标图像中待插值像素点的像素值。Obtain the pixel point to be interpolated in the target image; determine the mapping coordinate point of the pixel point to be interpolated in the original image, and obtain the pixel value of each original pixel point in a preset neighborhood around the mapping coordinate point in the original image; determine the edge gradient direction information and edge intensity information of the mapping coordinate point according to the pixel value of each original pixel point in the neighborhood; determine the weight of each original pixel point in the neighborhood according to the Gaussian distance between the mapping coordinate point and each original pixel point in the neighborhood; determine the edge enhancement attenuation correction coefficient of each original pixel point in the neighborhood according to the edge gradient direction information, edge intensity information and Gaussian distance; weight the weight of each original pixel point using the edge enhancement attenuation correction coefficient to obtain the convolution filter weight; determine the pixel value of the pixel point to be interpolated in the target image according to the product of the convolution filter weight and the pixel value of each original pixel point in the neighborhood.
一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现以下步骤:A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
获取目标图像中的待插值像素点;确定待插值像素点在原始图像中的映射坐标点,并获取原始图像中映射坐标点周围预设邻域内各个原始像素点的像素值;根据邻域内各个原始像素点的像素值,确定映射坐标点的边缘梯度方向信息和边缘强度信息;根据映射坐标点与邻域内各个原始像素点之间的高斯距离,确定邻域内各个原始像素点的权重;根据边缘梯度方向信息、边缘强度信息和高斯距离,确定邻域内各个原始像素点的边缘增强衰减矫正系数;利用边缘增强衰减矫正系数对各个原始像素点的权重进行加权,得到卷积滤波权重;根据卷积滤波权重与邻域内各个原始像素点的像素值的乘积,确定目标图像中待插值像素点的像素值。Obtain the pixel point to be interpolated in the target image; determine the mapping coordinate point of the pixel point to be interpolated in the original image, and obtain the pixel value of each original pixel point in a preset neighborhood around the mapping coordinate point in the original image; determine the edge gradient direction information and edge intensity information of the mapping coordinate point according to the pixel value of each original pixel point in the neighborhood; determine the weight of each original pixel point in the neighborhood according to the Gaussian distance between the mapping coordinate point and each original pixel point in the neighborhood; determine the edge enhancement attenuation correction coefficient of each original pixel point in the neighborhood according to the edge gradient direction information, edge intensity information and Gaussian distance; weight the weight of each original pixel point using the edge enhancement attenuation correction coefficient to obtain the convolution filter weight; determine the pixel value of the pixel point to be interpolated in the target image according to the product of the convolution filter weight and the pixel value of each original pixel point in the neighborhood.
上述图像缩放方法、装置、计算机设备和存储介质,根据待插值像素点对应的原始图像中的映射坐标点周围预设邻域内各个原始像素点的像素值,确定映射坐标点的边缘梯度方向信息和边缘强度信息,对邻域内各个原始像素点的权重进行增强或衰减得到增强或衰减后的各个原始像素点的权重,并根据增强或衰减后的各个原始像素点的权重和各个原始像素点的像素值求解得到待插值像素点的像素值。能够在插值过程中保持像素前后的相关性,并能在任意方向边缘上进行插值处理,以保持原图的边缘信息,使得图像在放大或缩小后保持清晰,避免了锯齿失真等现象的出现,保留了图像边缘信息的完整性和相关性,使缩放后的图像的轮廓和纹理更清晰,提升缩放后得到的目标图像的质量。The above-mentioned image scaling method, device, computer equipment and storage medium determine the edge gradient direction information and edge strength information of the mapping coordinate point according to the pixel values of each original pixel point in a preset neighborhood around the mapping coordinate point in the original image corresponding to the pixel point to be interpolated, enhance or attenuate the weight of each original pixel point in the neighborhood to obtain the weight of each original pixel point after enhancement or attenuation, and solve the pixel value of the pixel point to be interpolated according to the weight of each original pixel point after enhancement or attenuation and the pixel value of each original pixel point. It is able to maintain the correlation between the pixels before and after during the interpolation process, and can perform interpolation processing on the edges in any direction to maintain the edge information of the original image, so that the image remains clear after being enlarged or reduced, avoiding the occurrence of jagged distortion and other phenomena, retaining the integrity and correlation of the image edge information, making the contour and texture of the scaled image clearer, and improving the quality of the target image obtained after scaling.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1为一个实施例中图像缩放方法的流程示意图;FIG1 is a schematic diagram of a flow chart of an image scaling method in one embodiment;
图2为另一个实施例中图像缩放方法的流程示意图;FIG2 is a schematic diagram of a flow chart of an image scaling method in another embodiment;
图3为一个实施例中的示意图;FIG3 is a schematic diagram of an embodiment;
图4为一个实施例中的示意图;FIG4 is a schematic diagram of an embodiment;
图5为一个实施例中的示意图;FIG5 is a schematic diagram of an embodiment;
图6为一个实施例中的示意图;FIG6 is a schematic diagram of an embodiment;
图7为一个实施例中的示意图;FIG7 is a schematic diagram of an embodiment;
图8为一个实施例中图像缩放装置的结构框图;FIG8 is a structural block diagram of an image scaling device in one embodiment;
图9为一个实施例中计算机设备的内部结构图。FIG. 9 is a diagram showing the internal structure of a computer device in one embodiment.
具体实施方式DETAILED DESCRIPTION
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
本申请提供的图像缩放方法,可以应用于终端中。其中,终端可以但不限于是各种电视机、个人计算机、笔记本电脑、智能手机、平板电脑和便携式可穿戴设备等等。The image scaling method provided in the present application can be applied to a terminal, wherein the terminal can be, but is not limited to, various televisions, personal computers, notebook computers, smart phones, tablet computers, portable wearable devices, and the like.
在一个实施例中,如图1所示,提供了一种图像缩放方法,包括以下步骤S110-S180:In one embodiment, as shown in FIG1 , an image scaling method is provided, comprising the following steps S110 - S180:
S110,获取目标图像中的待插值像素点;S110, obtaining pixels to be interpolated in the target image;
其中,目标图像是对原始图像进行图像缩放后得到的图像,图像差值是利用原始图像中的已知像素点计算目标图像中未知像素点的过程,待插值像素点即是指缩放后的目标图像中需要通过计算确定的未知像素点。Among them, the target image is the image obtained after scaling the original image, the image difference is the process of calculating the unknown pixels in the target image using the known pixels in the original image, and the pixels to be interpolated refer to the unknown pixels in the scaled target image that need to be determined by calculation.
S120,确定待插值像素点在原始图像中的映射坐标点;S120, determining the mapping coordinate point of the pixel point to be interpolated in the original image;
作为示例地,如图3所示,假设输入原图低分辨率放大成高分辨目标图像,其原图宽高分别为Wsrc、hsrc,目标图像宽高分别为Wtar、htar。则目标图像中I行J列的待插值像素点的坐标值(Itar,Jtar)在原始图像中的映射坐标点的坐标值为(Isrc,Jsrc):As an example, as shown in FIG3 , it is assumed that the input original image is enlarged to a high-resolution target image with a low resolution, and the width and height of the original image are W src and h src , respectively, and the width and height of the target image are W tar and h tar , respectively. Then the coordinate value (I tar , J tar ) of the pixel point to be interpolated in row I and column J of the target image is the coordinate value of the mapping coordinate point in the original image (I src , J src ):
S130,获取原始图像中映射坐标点周围预设邻域内各个原始像素点的像素值;S130, obtaining the pixel value of each original pixel point in a preset neighborhood around the mapping coordinate point in the original image;
其中,映射坐标点周围预设邻域内各个原始像素点,可以根据实际需要确定该邻域内原始像素点的数量,例如可以是原始像素点周围2×2,3×4,3×3或者6×6等等的原始像素点。采用的邻域内原始像素点越多,缩放后生成的目标图像效果越好,信息越完整,但相应地运算量也会增加,故可以根据缩放情况选择合适的邻域内原始像素点的数量。Among them, the original pixel points in the preset neighborhood around the mapping coordinate point can determine the number of original pixel points in the neighborhood according to actual needs, for example, it can be 2×2, 3×4, 3×3 or 6×6 original pixel points around the original pixel point. The more original pixel points in the neighborhood are used, the better the target image effect generated after scaling and the more complete the information, but the amount of calculation will increase accordingly, so the appropriate number of original pixel points in the neighborhood can be selected according to the scaling situation.
作为示例地,如图4所示,可以选择待插值像素点(Itar,Jtar)在原始图像中映射坐标点(Isrc,Jsrc)周围4×4的邻域内原始像素点,作为邻域像素。As an example, as shown in FIG4 , the original pixels in a 4×4 neighborhood around the coordinate point (I src , J src ) mapped to the pixel point to be interpolated (I tar , J tar ) in the original image may be selected as neighborhood pixels.
S140,根据邻域内各个原始像素点的像素值,确定映射坐标点的边缘梯度方向信息和边缘强度信息;S140, determining edge gradient direction information and edge intensity information of the mapping coordinate point according to the pixel value of each original pixel point in the neighborhood;
其中,像素值是表征像素点取值的量,例如可以是像素点在某一颜色空间中的通道值,以RGB颜色空间为例,则像素点的像素值可以表示为(R,G,B),其中,R,G,B分别为RGB颜色空间三个通道的通道值。Among them, the pixel value is a quantity that characterizes the value of a pixel point. For example, it can be the channel value of a pixel point in a certain color space. Taking the RGB color space as an example, the pixel value of a pixel point can be expressed as (R, G, B), where R, G, and B are the channel values of the three channels of the RGB color space respectively.
在一个实施例中,如图2所示,S140根据邻域内各个原始像素点的像素值,确定映射坐标点的边缘梯度方向信息和边缘强度信息包括S141-S142:In one embodiment, as shown in FIG. 2 , S140 determines the edge gradient direction information and edge strength information of the mapping coordinate point according to the pixel value of each original pixel point in the neighborhood, including S141-S142:
S141,根据邻域内各个原始像素点的像素值,确定映射坐标点的水平边缘梯度值和对应的水平边缘强度值;S141, determining a horizontal edge gradient value and a corresponding horizontal edge intensity value of a mapping coordinate point according to the pixel value of each original pixel point in the neighborhood;
在一个实施例中,S141根据邻域内各个原始像素点的像素值,确定映射坐标点的水平边缘梯度值和对应的水平边缘强度值,包括:计算邻域内各个原始像素点的像素值的均值;获取邻域内原始像素点中的预设行的原始像素点;根据预设行的原始像素点在水平方向的差值,确定映射坐标点的水平边缘梯度值;根据预设行的原始像素点与均值之间的差值,确定映射坐标点的水平边缘强度值。In one embodiment, S141 determines the horizontal edge gradient value and the corresponding horizontal edge strength value of the mapping coordinate point according to the pixel values of each original pixel point in the neighborhood, including: calculating the average of the pixel values of each original pixel point in the neighborhood; obtaining the original pixel points of a preset row among the original pixel points in the neighborhood; determining the horizontal edge gradient value of the mapping coordinate point according to the difference in the horizontal direction of the original pixel points of the preset row; determining the horizontal edge strength value of the mapping coordinate point according to the difference between the original pixel points of the preset row and the average value.
进一步地,在一个实施例中,获取邻域内原始像素点中的预设行的原始像素点,包括:获取邻域内原始像素点中,除了第一行和最后一行之外的行数的原始像素点,作为预设行的原始像素点。Further, in one embodiment, obtaining original pixel points of a preset row among original pixel points in a neighborhood includes: obtaining original pixel points of a number of rows other than the first row and the last row among original pixel points in the neighborhood as original pixel points of the preset row.
作为示例地,以映射坐标点(Isrc,Jsrc)周围4×4的邻域内原始像素点为例,邻域内各个原始像素点的像素值的均值计算如下式:As an example, taking the original pixel points in a 4×4 neighborhood around the mapping coordinate point (I src , J src ) as an example, the mean value of the pixel values of each original pixel point in the neighborhood is calculated as follows:
上式中,avg为邻域内各个原始像素点的像素值的均值,i为邻域内原始像素点行下标,i取值0~3,j为邻域内原始像素点列下标,j取值0~3,pi,j为邻域内原始像素点(i,j)的像素值。In the above formula, avg is the average pixel value of each original pixel in the neighborhood, i is the row subscript of the original pixel in the neighborhood, i takes a value of 0 to 3, j is the column subscript of the original pixel in the neighborhood, j takes a value of 0 to 3, and pi ,j is the pixel value of the original pixel (i, j) in the neighborhood.
映射坐标点(Isrc,Jsrc)的水平边缘梯度值计算如下式所示:The horizontal edge gradient value of the mapping coordinate point (I src , J src ) is calculated as follows:
h_diff0=-1*p10-2*p11+2*p12+1*p13 h_diff0=-1*p 10 -2*p 11 +2*p 12 +1*p 13
h_diff1=-1*p20-2*p21+2*p22+1*p23 h_diff1=-1*p 20 -2*p 21 +2*p 22 +1*p 23
h_diff=h_diff0+h_diff1h_diff=h_diff0+h_diff1
上式中,h_diff0为邻域内第一行原始像素点在水平方向的差值,h_diff1为邻域内第二行原始像素点在水平方向的差值,h_diff为映射坐标点的水平边缘梯度值。In the above formula, h_diff0 is the horizontal difference of the original pixel points in the first row in the neighborhood, h_diff1 is the horizontal difference of the original pixel points in the second row in the neighborhood, and h_diff is the horizontal edge gradient value of the mapping coordinate point.
映射坐标点(Isrc,Jsrc)对应的水平边缘强度值计算如下式所示:The horizontal edge strength value corresponding to the mapping coordinate point (I src , J src ) is calculated as follows:
上式中,h_var为水平边缘强度值,abs为取绝对值。In the above formula, h_var is the horizontal edge strength value, and abs is the absolute value.
上述实施例中,为简便计算映射坐标点在4×4邻域内原始像素点的水平边缘梯度值和对应的水平边缘强度值,采用邻域内原始像素点中相关性较大的第一行和第二行像素值计算水平边缘梯度值和水平边缘强度值(邻域内原始像素点分别是0,1,2,3行,以及0,1,2,3列)。由于邻域中每行的第一列和第二列对待插值像素点的相关性高于第零列和第三列,因此采用[-1,-2,2,1]T的矩阵计算第一行和第二行的原始像素点在水平方向的差值,根据行方向差值之和的正负判断边缘水平梯度方向。根据计算得到的邻域内的像素平均值与第一行和第二行中各列像素值得到相应差值,并绝对值求和得到作为判别边缘水平方向强度信息的水平边缘强度值。In the above embodiment, in order to simply calculate the horizontal edge gradient value and the corresponding horizontal edge intensity value of the original pixel point in the 4×4 neighborhood of the mapping coordinate point, the first row and the second row of pixel values with greater correlation among the original pixel points in the neighborhood are used to calculate the horizontal edge gradient value and the horizontal edge intensity value (the original pixel points in the neighborhood are 0, 1, 2, 3 rows, and 0, 1, 2, 3 columns). Since the first column and the second column of each row in the neighborhood have a higher correlation with the interpolated pixel point than the zeroth column and the third column, the matrix of [-1, -2, 2, 1] T is used to calculate the horizontal difference of the original pixel points in the first row and the second row, and the horizontal gradient direction of the edge is determined according to the positive or negative sum of the row direction difference. The corresponding difference is obtained according to the calculated pixel average value in the neighborhood and the pixel values of each column in the first row and the second row, and the absolute value is summed to obtain the horizontal edge intensity value as the horizontal direction intensity information for determining the edge.
S142,根据邻域内各个原始像素点的像素值,确定映射坐标点的垂直边缘梯度值和对应的垂直边缘强度值。S142, determining the vertical edge gradient value and the corresponding vertical edge intensity value of the mapping coordinate point according to the pixel value of each original pixel point in the neighborhood.
在一个实施例中,S142根据邻域内各个原始像素点的像素值,确定映射坐标点的垂直边缘梯度值和对应的垂直边缘强度值,包括:计算邻域内各个原始像素点的像素值的均值;获取邻域内原始像素点中的预设列的原始像素点;根据预设列的原始像素点在垂直方向的差值,确定映射坐标点的垂直边缘梯度值;根据预设列的原始像素点与均值之间的差值,确定映射坐标点的垂直边缘强度值。In one embodiment, S142 determines the vertical edge gradient value and the corresponding vertical edge strength value of the mapping coordinate point according to the pixel values of each original pixel point in the neighborhood, including: calculating the average of the pixel values of each original pixel point in the neighborhood; obtaining the original pixel points of a preset column among the original pixel points in the neighborhood; determining the vertical edge gradient value of the mapping coordinate point according to the difference in the vertical direction between the original pixel points of the preset column; determining the vertical edge strength value of the mapping coordinate point according to the difference between the original pixel points of the preset column and the average value.
在一个实施例中,获取邻域内原始像素点中的预设列的原始像素点,包括:获取邻域内原始像素点中,除了第一列和最后一列之外的列数的原始像素点,作为预设列的原始像素点。In one embodiment, obtaining original pixel points of a preset column among original pixel points in a neighborhood includes: obtaining original pixel points of a number of columns other than the first column and the last column among original pixel points in the neighborhood as original pixel points of the preset column.
作为示例地,同样以映射坐标点(Isrc,Jsrc)周围4×4的邻域内原始像素点为例,邻域内各个原始像素点的像素值的均值计算如下式:As an example, also taking the original pixel points in the 4×4 neighborhood around the mapping coordinate point (I src , J src ) as an example, the mean value of the pixel values of each original pixel point in the neighborhood is calculated as follows:
上式中,avg为邻域内各个原始像素点的像素值的均值,i为邻域内原始像素点行下标,i取值0~3,j为邻域内原始像素点列下标,j取值0~3,pi,j为邻域内原始像素点(i,j)的像素值。In the above formula, avg is the average pixel value of each original pixel in the neighborhood, i is the row subscript of the original pixel in the neighborhood, i takes a value of 0 to 3, j is the column subscript of the original pixel in the neighborhood, j takes a value of 0 to 3, and pi ,j is the pixel value of the original pixel (i, j) in the neighborhood.
映射坐标点(Isrc,Jsrc)的垂直边缘梯度值计算如下式所示:The vertical edge gradient value of the mapping coordinate point (I src , J src ) is calculated as follows:
v_diff0=-1*p01-2*p11+2*p21+1*p31 v_diff0=-1*p 01 -2*p 11 +2*p 21 +1*p 31
v_diff1=-1*p02-2*p12+2*p22+1*p32 v_diff1=-1*p 02 -2*p 12 +2*p 22 +1*p 32
v_diff=v_diff0+v_diff1v_diff=v_diff0+v_diff1
上式中,v_diff0为邻域内第一行原始像素点在垂直方向的差值,v_diff1为邻域内第二行原始像素点在垂直方向的差值,v_diff为映射坐标点的垂直边缘梯度值。In the above formula, v_diff0 is the vertical difference of the original pixel points in the first row in the neighborhood, v_diff1 is the vertical difference of the original pixel points in the second row in the neighborhood, and v_diff is the vertical edge gradient value of the mapping coordinate point.
映射坐标点(Isrc,Jsrc)对应的垂直边缘强度值计算如下式所示:The vertical edge strength value corresponding to the mapping coordinate point (I src , J src ) is calculated as follows:
上式中,v_var为垂直边缘强度值,abs为取绝对值。In the above formula, v_var is the vertical edge strength value, and abs is the absolute value.
上述实施例中,为简便计算映射坐标点在4×4邻域内原始像素点的垂直边缘梯度值和对应的垂直边缘强度值,采用邻域内原始像素点中相关性较大的第一列和第二列像素值计算垂直边缘梯度值和垂直边缘强度值(邻域内原始像素点分别是0,1,2,3行,以及0,1,2,3列)。由于邻域中每列的第一行和第二行对待插值像素点的相关性高于第零行和第三行,因此采用[-1 -2 2 1]的矩阵计算第一列和第二列的原始像素点在垂直方向的差值,根据列方向差值之和的正负判断边缘垂直梯度方向。根据计算得到的邻域内的像素平均值与第一列和第二列中各行像素值得到相应差值,并绝对值求和得到作为判别边缘垂直方向强度信息的垂直边缘强度值。In the above embodiment, in order to simply calculate the vertical edge gradient value and the corresponding vertical edge strength value of the original pixel point in the 4×4 neighborhood of the mapping coordinate point, the first and second column pixel values with greater correlation in the original pixel points in the neighborhood are used to calculate the vertical edge gradient value and the vertical edge strength value (the original pixel points in the neighborhood are 0, 1, 2, 3 rows, and 0, 1, 2, 3 columns). Since the first and second rows of each column in the neighborhood have a higher correlation with the interpolated pixel points than the zeroth row and the third row, the matrix of [-1 -2 2 1] is used to calculate the difference in the vertical direction of the original pixel points in the first and second columns, and the vertical gradient direction of the edge is determined according to the positive or negative sum of the column direction difference. The corresponding difference is obtained based on the calculated pixel average value in the neighborhood and the pixel values of each row in the first and second columns, and the absolute value is summed to obtain the vertical edge strength value as the vertical direction strength information for determining the edge.
S150,根据映射坐标点与邻域内各个原始像素点之间的高斯距离,确定邻域内各个原始像素点的权重;S150, determining the weight of each original pixel point in the neighborhood according to the Gaussian distance between the mapped coordinate point and each original pixel point in the neighborhood;
作为示例地,映射坐标点与邻域内各个原始像素点之间的高斯距离计算如下式所示:As an example, the Gaussian distance between the mapped coordinate point and each original pixel point in the neighborhood is calculated as follows:
其中,(x,y)为以待插值像素点为中心4*4邻域内的任一原始像素点的坐标值,rsd(x,y)为映射坐标点与邻域内该坐标为(x,y)的原始像素点之间的高斯距离;Where (x, y) is the coordinate value of any original pixel point in a 4*4 neighborhood centered on the pixel point to be interpolated, and r sd (x, y) is the Gaussian distance between the mapped coordinate point and the original pixel point with coordinates (x, y) in the neighborhood;
以取4×4个邻域内原始像素点作为邻域像素为例,则在此步骤中,16个原始像素点对应有16个坐标值(x,y),可以分别计算得到16个高斯距离rsd(x,y)。Taking the original pixel points in a 4×4 neighborhood as neighborhood pixels as an example, in this step, 16 original pixel points correspond to 16 coordinate values (x, y), and 16 Gaussian distances r sd (x, y) can be calculated respectively.
根据rsd(x,y)确定对应的邻域内原始像素点的权重如下式所示:The weight of the original pixel in the corresponding neighborhood is determined according to r sd (x, y) as shown in the following formula:
其中,(x,y)为邻域内对应原始像素点的坐标值,w(x,y)为rsd(x,y)对应的权重,nx为归一化系数,rsd(x,y)为邻域内原始像素点相对映射坐标点的距离,σ为对应高斯分布的标准差;Where (x, y) is the coordinate value of the original pixel point in the neighborhood, w (x, y) is the weight corresponding to r sd (x, y), n x is the normalization coefficient, r sd (x, y) is the distance between the original pixel point in the neighborhood and the mapped coordinate point, and σ is the standard deviation of the corresponding Gaussian distribution;
以取4×4个邻域内原始像素点作为邻域像素为例,则在此步骤中,根据16个高斯距离rsd(x,y)可以计算得到16个原始像素点的16个权重。Taking the original pixels in a 4×4 neighborhood as neighborhood pixels as an example, in this step, 16 weights of the 16 original pixels can be calculated according to the 16 Gaussian distances r sd (x, y).
以上为本步骤中权重计算的基本原理,在实际应用中,为简化运算,在本步骤中可以直接通过查询已存的权重表得到不同高斯距离对应的权重。具体地,可以先根据相应平滑低通滤波的高斯曲线,根据邻域内各点的高斯距离查表得出相应的权重值,归一化系数nx对应的则是邻域内各点权重之和的倒数;The above is the basic principle of weight calculation in this step. In practical applications, in order to simplify the calculation, in this step, the weights corresponding to different Gaussian distances can be directly obtained by querying the stored weight table. Specifically, the corresponding weight value can be obtained by looking up the table according to the Gaussian distance of each point in the neighborhood based on the corresponding smooth low-pass filtered Gaussian curve. The normalization coefficient nx corresponds to the inverse of the sum of the weights of each point in the neighborhood.
本实施例中,由高斯距离能有效得出邻域内各原始像素点对当前待插值像素点的贡献权重,从而一定程度上保留了待插值像素点与原始图像邻域内原始像素点的相关性,使得原始图像中的图像边缘特征在一定程度上得到了保留。In this embodiment, the Gaussian distance can effectively derive the contribution weight of each original pixel in the neighborhood to the current pixel to be interpolated, thereby retaining the correlation between the pixel to be interpolated and the original pixel in the neighborhood of the original image to a certain extent, so that the image edge features in the original image are retained to a certain extent.
S160,根据边缘梯度方向信息、边缘强度信息和高斯距离,确定邻域内各个原始像素点的边缘增强衰减矫正系数;S160, determining an edge enhancement attenuation correction coefficient of each original pixel in the neighborhood according to the edge gradient direction information, the edge intensity information and the Gaussian distance;
在一个实施例中,如图2所示,S160根据边缘梯度方向信息、边缘强度信息和高斯距离,确定邻域内各个原始像素点的边缘增强衰减矫正系数,包括S161-S163:In one embodiment, as shown in FIG. 2 , S160 determines the edge enhancement attenuation correction coefficient of each original pixel in the neighborhood according to the edge gradient direction information, the edge intensity information and the Gaussian distance, including S161-S163:
S161,根据映射坐标点的水平边缘梯度值、水平边缘强度值和各个原始像素点相对映射坐标点的高斯距离,确定各个原始像素点的水平边缘矫正系数;S161, determining a horizontal edge correction coefficient of each original pixel point according to a horizontal edge gradient value, a horizontal edge intensity value, and a Gaussian distance of each original pixel point relative to the mapped coordinate point;
在一个实施例中,S161根据映射坐标点的水平边缘梯度值、水平边缘强度值和各个原始像素点相对映射坐标点的高斯距离,确定各个原始像素点的水平边缘矫正系数,包括:根据映射坐标点的水平边缘梯度值,确定水平边缘增强衰减指数的正负性;根据映射坐标点的水平边缘强度值,确定水平边缘增强衰减底数的大小;针对各个原始像素点,以水平边缘增强衰减底数为底数,以水平边缘增强衰减指数和该原始像素点到映射坐标点的高斯距离之积为指数,进行幂运算得到该原始像素点的水平边缘矫正系数。In one embodiment, S161 determines the horizontal edge correction coefficient of each original pixel point according to the horizontal edge gradient value, the horizontal edge intensity value and the Gaussian distance of each original pixel point relative to the mapping coordinate point, including: determining the positive or negative nature of the horizontal edge enhancement attenuation exponent according to the horizontal edge gradient value of the mapping coordinate point; determining the size of the horizontal edge enhancement attenuation base according to the horizontal edge intensity value of the mapping coordinate point; for each original pixel point, using the horizontal edge enhancement attenuation base as the base and the product of the horizontal edge enhancement attenuation exponent and the Gaussian distance from the original pixel point to the mapping coordinate point as the exponent, performing a power operation to obtain the horizontal edge correction coefficient of the original pixel point.
作为示例地,根据映射坐标点的水平边缘梯度值,确定水平边缘增强衰减指数的正负性如下式所示:As an example, according to the horizontal edge gradient value of the mapping coordinate point, the positive and negative of the horizontal edge enhancement attenuation index is determined as shown in the following formula:
上式中,h_signed为水平边缘增强衰减指数。In the above formula, h_signed is the horizontal edge enhancement attenuation index.
根据映射坐标点的水平边缘强度值,确定水平边缘增强衰减底数α的大小;According to the horizontal edge strength value of the mapping coordinate point, the size of the horizontal edge enhancement attenuation base α is determined;
针对各个原始像素点,以水平边缘增强衰减底数为底数,以水平边缘增强衰减指数和该原始像素点到映射坐标点的高斯距离之积为指数,进行幂运算得到该原始像素点的水平边缘矫正系数如下式所示:For each original pixel point, the horizontal edge enhancement attenuation base is used as the base, and the product of the horizontal edge enhancement attenuation exponent and the Gaussian distance from the original pixel point to the mapping coordinate point is used as the exponent. The horizontal edge correction coefficient of the original pixel point is obtained by performing a power operation as shown in the following formula:
上式中,α′(x,y)为坐标为(x,y)的原始像素点的水平边缘矫正系数。In the above formula, α′(x,y) is the horizontal edge correction coefficient of the original pixel with coordinates (x,y).
以上实施例为本步骤S161中依照原理计算的水平边缘矫正系数,在实际应用中,为了简化运算,在一个实施例中,S161根据映射坐标点的水平边缘梯度值、水平边缘强度值和各个原始像素点相对映射坐标点的高斯距离,确定各个原始像素点的水平边缘矫正系数,包括:根据映射坐标点的水平边缘梯度值的正负性,确定对应的曲线集;曲线集包括曲线斜率大于零的增强曲线集或曲线斜率小于零的衰减曲线集;根据水平边缘强度值,从确定的曲线集中选择对应的曲线,水平边缘强度值与选择的对应的曲线的斜率绝对值大小呈正比例;从选择的曲线中查询以各个原始像素点与映射坐标点之间的高斯距离为横坐标对应的纵坐标,作为各个原始像素点的水平边缘矫正系数。The above embodiment is the horizontal edge correction coefficient calculated according to the principle in this step S161. In practical applications, in order to simplify the calculation, in one embodiment, S161 determines the horizontal edge correction coefficient of each original pixel point according to the horizontal edge gradient value, the horizontal edge intensity value and the Gaussian distance of each original pixel point relative to the mapping coordinate point of the mapping coordinate point, including: determining a corresponding curve set according to the positive and negative nature of the horizontal edge gradient value of the mapping coordinate point; the curve set includes an enhancement curve set with a curve slope greater than zero or an attenuation curve set with a curve slope less than zero; selecting a corresponding curve from the determined curve set according to the horizontal edge intensity value, and the absolute value of the slope of the horizontal edge intensity value and the selected corresponding curve is positively proportional; querying the vertical coordinate corresponding to the Gaussian distance between each original pixel point and the mapping coordinate point as the horizontal coordinate from the selected curve as the horizontal edge correction coefficient of each original pixel point.
作为示例地,当映射坐标点的水平边缘梯度值h_diff大于或等于零时,确定为增强曲线集;其中,增强曲线集中包括预设条数的增强曲线,每条增强曲线对应一个取值区间的水平边缘梯度值h_diff;As an example, when the horizontal edge gradient value h_diff of the mapping coordinate point is greater than or equal to zero, it is determined as an enhancement curve set; wherein the enhancement curve set includes a preset number of enhancement curves, each enhancement curve corresponding to a horizontal edge gradient value h_diff in a value interval;
如图5所示,为一个实施例中增强曲线集中的7条增强曲线的示意图,根据水平边缘强度值h_var,从增强曲线集中选择对应的增强曲线如下:As shown in FIG. 5 , it is a schematic diagram of 7 enhancement curves in an enhancement curve set in one embodiment. According to the horizontal edge intensity value h_var, the corresponding enhancement curve is selected from the enhancement curve set as follows:
当h_var<strength_level_th0时,选择level0曲线;When h_var<strength_level_th0, select level0 curve;
当strength_level_th0≤h_var<strength_level_th1时选择level1曲线;When strength_level_th0≤h_var<strength_level_th1, select level1 curve;
当strength_level_th1≤h_var<strength_level_th2时选择level2曲线;When strength_level_th1≤h_var<strength_level_th2, select level2 curve;
当strength_level_th2≤h_var<strength_level_th3时选择level3曲线;When strength_level_th2≤h_var<strength_level_th3, select level3 curve;
当strength_level_th3≤h_var<strength_level_th4时选择level4曲线;When strength_level_th3≤h_var<strength_level_th4, select level4 curve;
当strength_level_th4≤h_var<strength_level_th5时选择level5曲线;When strength_level_th4≤h_var<strength_level_th5, select level5 curve;
当strength_level_th5≤h_var<strength_level_th6时选择level6曲线;When strength_level_th5≤h_var<strength_level_th6, select level6 curve;
当strength_level_th6≤h_var<strength_level_th7时选择level7曲线;When strength_level_th6≤h_var<strength_level_th7, select level7 curve;
当h_var≥strength_level_th7时选择level8曲线;When h_var≥strength_level_th7, select level8 curve;
其中,strength_level_th0~7代表预设的取值区间的阈值,其可以根据需求设置,对应的曲线level1~8的斜率依次递增;其中level0曲线的斜率为0,即不进行增强,对应的各个原始像素点(x,y)在该曲线中查询到的α′(x,y)取值均为1。Among them, strength_level_th0~7 represent the threshold values of the preset value range, which can be set according to the needs, and the slopes of the corresponding curves level1~8 increase successively; the slope of the level0 curve is 0, that is, no enhancement is performed, and the corresponding α′(x,y) values queried in the curve for each original pixel point (x,y) are all 1.
在选择了对应的增强曲线后,从该选择的增强曲线中查询以各个原始像素点与映射坐标点之间的高斯距离为横坐标对应的纵坐标,作为各个原始像素点的水平边缘矫正系数。After the corresponding enhancement curve is selected, the vertical coordinate corresponding to the Gaussian distance between each original pixel point and the mapping coordinate point as the horizontal coordinate is queried from the selected enhancement curve as the horizontal edge correction coefficient of each original pixel point.
当映射坐标点的水平边缘梯度值h_diff小于零时,确定为衰减曲线集;其中,衰减曲线集中包括预设条数的衰减曲线,每条衰减曲线对应一个取值区间的水平边缘梯度值h_diff;When the horizontal edge gradient value h_diff of the mapping coordinate point is less than zero, it is determined as an attenuation curve set; wherein the attenuation curve set includes a preset number of attenuation curves, and each attenuation curve corresponds to a horizontal edge gradient value h_diff in a value interval;
如图6所示,为一个实施例中衰减曲线集中的7条衰减曲线的示意图,根据水平边缘强度值h_var,从衰减曲线集中选择对应的衰减曲线如下:As shown in FIG6 , it is a schematic diagram of 7 attenuation curves in an attenuation curve set in one embodiment. According to the horizontal edge intensity value h_var, the corresponding attenuation curve is selected from the attenuation curve set as follows:
当h_var<strength_level_th0时,选择level0曲线;When h_var<strength_level_th0, select level0 curve;
当strength_level_th0≤h_var<strength_level_th1时选择level1曲线;When strength_level_th0≤h_var<strength_level_th1, select level1 curve;
当strength_level_th1≤h_var<strength_level_th2时选择level2曲线;When strength_level_th1≤h_var<strength_level_th2, select level2 curve;
当strength_level_th2≤h_var<strength_level_th3时选择level3曲线;When strength_level_th2≤h_var<strength_level_th3, select level3 curve;
当strength_level_th3≤h_var<strength_level_th4时选择level4曲线;When strength_level_th3≤h_var<strength_level_th4, select level4 curve;
当strength_level_th4≤h_var<strength_level_th5时选择level5曲线;When strength_level_th4≤h_var<strength_level_th5, select level5 curve;
当strength_level_th5≤h_var<strength_level_th6时选择level6曲线;When strength_level_th5≤h_var<strength_level_th6, select level6 curve;
当strength_level_th6≤h_var<strength_level_th7时选择level7曲线;When strength_level_th6≤h_var<strength_level_th7, select level7 curve;
当h_var≥strength_level_th7时选择level8曲线;When h_var≥strength_level_th7, select level8 curve;
其中,strength_level_th0~7代表预设的取值区间的阈值,其可以根据需求设置,对应的曲线level1~8的斜率依次递减(斜率的绝对值依次递增),其中level0曲线的斜率为0,即不进行衰减,对应的各个原始像素点(x,y)在该曲线中查询到的α′(x,y)取值均为1。Among them, strength_level_th0~7 represent the threshold values of the preset value range, which can be set according to the needs. The slopes of the corresponding curves level1~8 decrease successively (the absolute values of the slopes increase successively), among which the slope of the level0 curve is 0, that is, no attenuation is performed, and the corresponding α′(x,y) values queried in the curve for each original pixel point (x,y) are all 1.
在选择了对应的衰减曲线后,从该选择的衰减曲线中查询以各个原始像素点与映射坐标点之间的高斯距离为横坐标对应的纵坐标,作为各个原始像素点的水平边缘矫正系数。After the corresponding attenuation curve is selected, the vertical coordinate corresponding to the Gaussian distance between each original pixel point and the mapped coordinate point as the horizontal coordinate is queried from the selected attenuation curve as the horizontal edge correction coefficient of each original pixel point.
在其他实施例中,上述通过曲线查询获取对应的水平边缘矫正系数的方案,还有多种可替代方案,例如可以将上述曲线转换为对应的表格,通过查表的方式根据映射坐标点的水平边缘梯度值、水平边缘强度值和各个原始像素点相对映射坐标点的高斯距离,查询确定各个原始像素点的水平边缘矫正系数等等。In other embodiments, there are multiple alternative solutions to the above-mentioned solution of obtaining the corresponding horizontal edge correction coefficient through curve query. For example, the above-mentioned curve can be converted into a corresponding table, and the horizontal edge correction coefficient of each original pixel point can be queried and determined by table lookup based on the horizontal edge gradient value, horizontal edge intensity value and Gaussian distance of each original pixel point relative to the mapping coordinate point of the mapping coordinate point, and the like.
S162,根据映射坐标点的垂直边缘梯度值、垂直边缘强度值和各个原始像素点相对映射坐标点的高斯距离,确定各个原始像素点的垂直边缘矫正系数;S162, determining a vertical edge correction coefficient of each original pixel point according to a vertical edge gradient value, a vertical edge intensity value, and a Gaussian distance of each original pixel point relative to the mapped coordinate point;
在一个实施例中,S162根据映射坐标点的垂直边缘梯度值、垂直边缘强度值和各个原始像素点相对映射坐标点的高斯距离,确定各个原始像素点的垂直边缘矫正系数,包括:根据映射坐标点的垂直边缘梯度值的正负性,确定对应的曲线集;曲线集包括曲线斜率大于零的增强曲线集或曲线斜率小于零的衰减曲线集;根据垂直边缘强度值,从确定的曲线集中选择对应的曲线,垂直边缘强度值与选择的对应的曲线的斜率绝对值大小呈正比例;从选择的曲线中查询以各个原始像素点与映射坐标点之间的高斯距离为横坐标对应的纵坐标,作为各个原始像素点的垂直边缘矫正系数。In one embodiment, S162 determines the vertical edge correction coefficient of each original pixel point according to the vertical edge gradient value, the vertical edge strength value and the Gaussian distance of each original pixel point relative to the mapping coordinate point of the mapping coordinate point, including: determining a corresponding curve set according to the positive and negative vertical edge gradient value of the mapping coordinate point; the curve set includes an enhanced curve set with a curve slope greater than zero or an attenuation curve set with a curve slope less than zero; selecting a corresponding curve from the determined curve set according to the vertical edge strength value, and the vertical edge strength value is positively proportional to the absolute value of the slope of the selected corresponding curve; querying the vertical coordinate corresponding to the Gaussian distance between each original pixel point and the mapping coordinate point as the horizontal coordinate from the selected curve as the vertical edge correction coefficient of each original pixel point.
作为示例地,根据映射坐标点的垂直边缘梯度值,确定垂直边缘增强衰减指数的正负性如下式所示:As an example, according to the vertical edge gradient value of the mapping coordinate point, the positive and negative of the vertical edge enhancement attenuation index is determined as shown in the following formula:
上式中,v_signed为垂直边缘增强衰减指数。In the above formula, v_signed is the vertical edge enhancement attenuation index.
根据映射坐标点的垂直边缘强度值,确定垂直边缘增强衰减底数α的大小;According to the vertical edge strength value of the mapping coordinate point, the size of the vertical edge enhancement attenuation base α is determined;
针对各个原始像素点,以垂直边缘增强衰减底数为底数,以垂直边缘增强衰减指数和该原始像素点到映射坐标点的高斯距离之积为指数,进行幂运算得到该原始像素点的垂直边缘矫正系数如下式所示:For each original pixel point, the vertical edge enhancement attenuation base is used as the base, and the vertical edge enhancement attenuation exponent and the product of the Gaussian distance from the original pixel point to the mapping coordinate point are used as the exponent. The vertical edge correction coefficient of the original pixel point is obtained by performing a power operation as shown in the following formula:
上式中,β′(x,y)为坐标为(x,y)的原始像素点的垂直边缘矫正系数。In the above formula, β′(x, y) is the vertical edge correction coefficient of the original pixel with coordinates (x, y).
以上实施例为本步骤S162中依照原理计算的垂直边缘矫正系数,在实际应用中,为了简化运算,在一个实施例中,S162根据映射坐标点的垂直边缘梯度值、垂直边缘强度值和各个原始像素点相对映射坐标点的高斯距离,确定各个原始像素点的垂直边缘矫正系数,包括:根据映射坐标点的垂直边缘梯度值的正负性,确定对应的曲线集;曲线集包括曲线斜率大于零的增强曲线集或曲线斜率小于零的衰减曲线集;根据垂直边缘强度值,从确定的曲线集中选择对应的曲线,垂直边缘强度值与选择的对应的曲线的斜率绝对值大小呈正比例;从选择的曲线中查询以各个原始像素点与映射坐标点之间的高斯距离为横坐标对应的纵坐标,作为各个原始像素点的垂直边缘矫正系数。The above embodiment is the vertical edge correction coefficient calculated according to the principle in this step S162. In practical applications, in order to simplify the calculation, in one embodiment, S162 determines the vertical edge correction coefficient of each original pixel point according to the vertical edge gradient value, the vertical edge intensity value and the Gaussian distance of each original pixel point relative to the mapping coordinate point of the mapping coordinate point, including: determining a corresponding curve set according to the positive and negative vertical edge gradient value of the mapping coordinate point; the curve set includes an enhancement curve set with a curve slope greater than zero or an attenuation curve set with a curve slope less than zero; selecting a corresponding curve from the determined curve set according to the vertical edge intensity value, and the vertical edge intensity value is proportional to the absolute value of the slope of the selected corresponding curve; querying the vertical coordinate corresponding to the Gaussian distance between each original pixel point and the mapping coordinate point as the horizontal coordinate from the selected curve as the vertical edge correction coefficient of each original pixel point.
作为示例地,当映射坐标点的垂直边缘梯度值v_diff大于或等于零时,确定为增强曲线集;其中,增强曲线集中包括预设条数的增强曲线,每条增强曲线对应一个取值区间的垂直边缘梯度值v_diff;As an example, when the vertical edge gradient value v_diff of the mapping coordinate point is greater than or equal to zero, it is determined as an enhancement curve set; wherein the enhancement curve set includes a preset number of enhancement curves, each enhancement curve corresponding to a vertical edge gradient value v_diff in a value interval;
如图5所示,为一个实施例中增强曲线集中的7条增强曲线的示意图,根据垂直边缘强度值v_var,从增强曲线集中选择对应的增强曲线如下:As shown in FIG. 5 , it is a schematic diagram of 7 enhancement curves in an enhancement curve set in one embodiment. According to the vertical edge strength value v_var, the corresponding enhancement curve is selected from the enhancement curve set as follows:
当v_var<strength_level_th0时,选择level0曲线;When v_var<strength_level_th0, select level0 curve;
当strength_level_th0≤v_var<strength_level_th1时选择level1曲线;When strength_level_th0≤v_var<strength_level_th1, select level1 curve;
当strength_level_th1≤v_var<strength_level_th2时选择level2曲线;When strength_level_th1≤v_var<strength_level_th2, select level2 curve;
当strength_level_th2≤v_var<strength_level_th3时选择level3曲线;When strength_level_th2≤v_var<strength_level_th3, select level3 curve;
当strength_level_th3≤v_var<strength_level_th4时选择level4曲线;When strength_level_th3≤v_var<strength_level_th4, select level4 curve;
当strength_level_th4≤v_var<strength_level_th5时选择level5曲线;When strength_level_th4≤v_var<strength_level_th5, select level5 curve;
当strength_level_th5≤v_var<strength_level_th6时选择level6曲线;When strength_level_th5≤v_var<strength_level_th6, select level6 curve;
当strength_level_th6≤v_var<strength_level_th7时选择level7曲线;When strength_level_th6≤v_var<strength_level_th7, select level7 curve;
当v_var≥strength_level_th7时选择level8曲线;When v_var≥strength_level_th7, select level8 curve;
其中,strength_level_th0~7代表预设的取值区间的阈值,其可以根据需求设置,对应的曲线level1~8的斜率依次递增,其中level0曲线的斜率为0,即不进行增强,对应的各个原始像素点(x,y)在该曲线中查询到的β′(x,y)取值均为1。Among them, strength_level_th0~7 represent the thresholds of the preset value range, which can be set according to needs. The slopes of the corresponding curves level1~8 increase successively, and the slope of the level0 curve is 0, that is, no enhancement is performed, and the corresponding β′(x,y) values queried in the curve for each original pixel point (x, y) are all 1.
在选择了对应的增强曲线后,从该选择的增强曲线中查询以各个原始像素点与映射坐标点之间的高斯距离为横坐标对应的纵坐标,作为各个原始像素点的垂直边缘矫正系数。After the corresponding enhancement curve is selected, the vertical coordinate corresponding to the Gaussian distance between each original pixel point and the mapped coordinate point as the horizontal coordinate is queried from the selected enhancement curve as the vertical edge correction coefficient of each original pixel point.
当映射坐标点的垂直边缘梯度值v_diff小于零时,确定为衰减曲线集;其中,衰减曲线集中包括预设条数的衰减曲线,每条衰减曲线对应一个取值区间的垂直边缘梯度值v_diff;When the vertical edge gradient value v_diff of the mapping coordinate point is less than zero, it is determined to be an attenuation curve set; wherein the attenuation curve set includes a preset number of attenuation curves, and each attenuation curve corresponds to a vertical edge gradient value v_diff in a value interval;
如图6所示,为一个实施例中衰减曲线集中的7条衰减曲线的示意图,根据垂直边缘强度值v_var,从衰减曲线集中选择对应的衰减曲线如下:As shown in FIG. 6 , it is a schematic diagram of 7 attenuation curves in an attenuation curve set in one embodiment. According to the vertical edge strength value v_var, the corresponding attenuation curve is selected from the attenuation curve set as follows:
当v_var<strength_level_th0时,选择level0曲线;When v_var<strength_level_th0, select level0 curve;
当strength_level_th0≤v_var<strength_level_th1时选择level1曲线;When strength_level_th0≤v_var<strength_level_th1, select level1 curve;
当strength_level_th1≤v_var<strength_level_th2时选择level2曲线;When strength_level_th1≤v_var<strength_level_th2, select level2 curve;
当strength_level_th2≤v_var<strength_level_th3时选择level3曲线;When strength_level_th2≤v_var<strength_level_th3, select level3 curve;
当strength_level_th3≤v_var<strength_level_th4时选择level4曲线;When strength_level_th3≤v_var<strength_level_th4, select level4 curve;
当strength_level_th4≤v_var<strength_level_th5时选择level5曲线;When strength_level_th4≤v_var<strength_level_th5, select level5 curve;
当strength_level_th5≤v_var<strength_level_th6时选择level6曲线;When strength_level_th5≤v_var<strength_level_th6, select level6 curve;
当strength_level_th6≤v_var<strength_level_th7时选择level7曲线;When strength_level_th6≤v_var<strength_level_th7, select level7 curve;
当v_var≥strength_level_th7时选择level8曲线;When v_var≥strength_level_th7, select level8 curve;
其中,strength_level_th0~7代表预设的取值区间的阈值,其可以根据需求设置,对应的曲线level1~8的斜率依次递减(斜率的绝对值依次递增),其中level0曲线的斜率为0,即不进行衰减,对应的各个原始像素点(x,y)在该曲线中查询到的β′(x,y)取值均为1。Among them, strength_level_th0~7 represent the threshold values of the preset value range, which can be set according to the needs. The slopes of the corresponding curves level1~8 decrease successively (the absolute values of the slopes increase successively), among which the slope of the level0 curve is 0, that is, no attenuation is performed, and the corresponding β′(x,y) values queried in the curve for each original pixel point (x,y) are all 1.
在选择了对应的衰减曲线后,从该选择的衰减曲线中查询以各个原始像素点与映射坐标点之间的高斯距离为横坐标对应的纵坐标,作为各个原始像素点的垂直边缘矫正系数。After the corresponding attenuation curve is selected, the vertical coordinate corresponding to the Gaussian distance between each original pixel point and the mapped coordinate point as the horizontal coordinate is queried from the selected attenuation curve as the vertical edge correction coefficient of each original pixel point.
在其他实施例中,上述通过曲线查询获取对应的垂直边缘矫正系数的方案,还有多种可替代方案,例如可以将上述曲线转换为对应的表格,通过查表的方式根据映射坐标点的垂直边缘梯度值、垂直边缘强度值和各个原始像素点相对映射坐标点的高斯距离,查询确定各个原始像素点的垂直边缘矫正系数等等。In other embodiments, there are multiple alternative solutions to the above-mentioned solution of obtaining the corresponding vertical edge correction coefficient through curve query. For example, the above-mentioned curve can be converted into a corresponding table, and the vertical edge correction coefficient of each original pixel point can be queried and determined by table lookup based on the vertical edge gradient value, vertical edge intensity value and Gaussian distance of each original pixel point relative to the mapping coordinate point of the mapping coordinate point, and the like.
S163,根据各个原始像素点的水平边缘矫正系数和垂直边缘矫正系数,确定各个原始像素点的边缘增强衰减矫正系数。S163, determining an edge enhancement attenuation correction coefficient for each original pixel point according to the horizontal edge correction coefficient and the vertical edge correction coefficient for each original pixel point.
作为示例地,可以根据各个原始像素点的水平边缘矫正系数α′(x,y)和垂直边缘矫正系数β′(x,y),确定各个原始像素点的边缘增强衰减矫正系数coeij如下式所示:As an example, the edge enhancement attenuation correction coefficient coe ij of each original pixel may be determined according to the horizontal edge correction coefficient α′(x, y) and the vertical edge correction coefficient β′(x, y) of each original pixel, as shown in the following formula:
coeij=α′(x,y)×β′(x,y)coe ij =α′(x,y)×β′(x,y)
其中,i为邻域内原始像素点行下标,j为邻域内原始像素点列下标,coeij为原始像素点(i,j)的边缘增强衰减矫正系数,(x,y)为邻域内原始像素点(i,j)的坐标值。以邻域内包括4×4个原始像素点为例,则i可以取值0~3,j可以取值0~3。Among them, i is the row subscript of the original pixel point in the neighborhood, j is the column subscript of the original pixel point in the neighborhood, coe ij is the edge enhancement attenuation correction coefficient of the original pixel point (i, j), and (x, y) is the coordinate value of the original pixel point (i, j) in the neighborhood. Taking the neighborhood including 4×4 original pixels as an example, i can take values 0 to 3, and j can take values 0 to 3.
S170,利用边缘增强衰减矫正系数对各个原始像素点的权重进行加权,得到卷积滤波权重;S170, weighting the weight of each original pixel point using the edge enhancement attenuation correction coefficient to obtain a convolution filter weight;
作为示例地,以邻域内包括4×4个原始像素点为例,利用边缘增强衰减矫正系数对各个原始像素点的权重进行加权,得到卷积滤波权重如下式所示:As an example, taking the neighborhood including 4×4 original pixels as an example, the weight of each original pixel is weighted by using the edge enhancement attenuation correction coefficient, and the convolution filter weight is obtained as shown in the following formula:
其中,下标ij代表对应于邻域内第i行第j列原始像素点,w00~w33代表邻域内各原始像素点对应的衰减增强后的权重,wsad00~wsad33代表邻域内各原始像素点的高斯距离计算得到的邻域内各原始像素点的衰减增强前的权重,coe00~coe33代表邻域内各原始像素点的边缘增强衰减矫正系数, Wherein, the subscript ij represents the original pixel corresponding to the i-th row and j-th column in the neighborhood, w00 ~ w33 represent the weights of the original pixels in the neighborhood after attenuation enhancement, wsad00 ~ wsad33 represent the weights of the original pixels in the neighborhood before attenuation enhancement obtained by calculating the Gaussian distance of the original pixels in the neighborhood, coe 00 ~ coe 33 represent the edge enhancement attenuation correction coefficients of each original pixel in the neighborhood.
S180,根据卷积滤波权重与邻域内各个原始像素点的像素值的乘积,确定目标图像中待插值像素点的像素值。S180, determining the pixel value of the pixel point to be interpolated in the target image according to the product of the convolution filter weight and the pixel value of each original pixel point in the neighborhood.
作为示例地,以邻域内包括4×4个原始像素点为例,根据卷积滤波权重与邻域内各个原始像素点的像素值的乘积,确定目标图像中待插值像素点的像素值如下式所示:As an example, taking the neighborhood including 4×4 original pixels as an example, the pixel value of the pixel to be interpolated in the target image is determined according to the product of the convolution filter weight and the pixel value of each original pixel in the neighborhood as shown in the following formula:
其中pixeli,j代表邻域内第i行第j列待插值像素点的像素值,p00~p33代表待插值像素点4×4邻域内各原始像素点的像素值。Where pixel i,j represents the pixel value of the pixel to be interpolated in the i-th row and j-th column in the neighborhood, and p 00 to p 33 represent the pixel values of each original pixel in the 4×4 neighborhood of the pixel to be interpolated.
如图7为卷积滤波窗缩放过程示意图,h_step和v_step分别为水平方向和垂直方向待插值像素步进偏移;则以待插值像素点作为卷积窗中心位置搜索原始图像中映射坐标周边4x4邻域内的原始像素点,分别加权求和归一化后得出待插值像素点的像素值,以上即为一次卷积求出一个待插值像素点的方法,通过上述方法运算得到目标图像中的所有待插值像素点的像素值,即完成将原始图像缩放得到目标图像的过程。As shown in Figure 7, the convolution filter window scaling process is schematically shown, where h_step and v_step are the step offsets of the pixels to be interpolated in the horizontal and vertical directions respectively. The pixel to be interpolated is used as the center of the convolution window to search for the original pixels in the 4x4 neighborhood around the mapping coordinates in the original image, and the pixel values of the pixels to be interpolated are obtained after weighted summation and normalization. The above is a method for obtaining a pixel to be interpolated by one convolution. The pixel values of all the pixels to be interpolated in the target image are obtained by the above method, and the process of scaling the original image to obtain the target image is completed.
上述图像缩放方法,根据待插值像素点对应的原始图像中的映射坐标点周围预设邻域内各个原始像素点的像素值,确定映射坐标点的边缘梯度方向信息和边缘强度信息,对邻域内各个原始像素点的权重进行增强或衰减得到增强或衰减后的各个原始像素点的权重,并根据增强或衰减后的各个原始像素点的权重和各个原始像素点的像素值求解得到待插值像素点的像素值。能够在插值过程中保持像素前后的相关性,并能在任意方向边缘上进行插值处理,以保持原图的边缘信息,使得图像在放大或缩小后保持清晰,避免了锯齿失真等现象的出现,保留了图像边缘信息的完整性和相关性,使缩放后的图像的轮廓和纹理更清晰,提升缩放后得到的目标图像的质量。The above-mentioned image scaling method determines the edge gradient direction information and edge strength information of the mapping coordinate point according to the pixel values of each original pixel point in a preset neighborhood around the mapping coordinate point in the original image corresponding to the pixel point to be interpolated, enhances or attenuates the weight of each original pixel point in the neighborhood to obtain the weight of each original pixel point after enhancement or attenuation, and solves the pixel value of the pixel point to be interpolated according to the weight of each original pixel point after enhancement or attenuation and the pixel value of each original pixel point. It can maintain the correlation between the pixels before and after in the interpolation process, and can perform interpolation processing on the edges in any direction to maintain the edge information of the original image, so that the image remains clear after being enlarged or reduced, avoiding the occurrence of jagged distortion and other phenomena, retaining the integrity and correlation of the image edge information, making the contour and texture of the scaled image clearer, and improving the quality of the target image obtained after scaling.
应该理解的是,虽然图1-3的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图1-3中的至少一部分步骤可以包括多个子步骤或者多个阶段,这些子步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤的子步骤或者阶段的至少一部分轮流或者交替地执行。It should be understood that, although the various steps in the flowcharts of Figures 1-3 are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in Figures 1-3 may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
在一个实施例中,如图8所示,提供了一种图像缩放装置800,包括:待插值像素点获取模块810、邻域像素获取模块820、边缘信息确定模块830、原始权重确定模块840、增强衰减矫正系数确定模块850和待插值像素点像素值确定模块860,其中:In one embodiment, as shown in FIG8 , an image scaling device 800 is provided, comprising: a to-be-interpolated
待插值像素点获取模块810,用于获取目标图像中的待插值像素点;The pixel
邻域像素获取模块820,用于确定待插值像素点在原始图像中的映射坐标点,并获取原始图像中映射坐标点周围预设邻域内各个原始像素点的像素值;The neighborhood
边缘信息确定模块830,用于根据邻域内各个原始像素点的像素值,确定映射坐标点的边缘梯度方向信息和边缘强度信息;The edge
原始权重确定模块840,用于根据映射坐标点与邻域内各个原始像素点之间的高斯距离,确定邻域内各个原始像素点的权重;The original
增强衰减矫正系数确定模块850,用于根据边缘梯度方向信息、边缘强度信息和高斯距离,确定邻域内各个原始像素点的边缘增强衰减矫正系数;The enhancement attenuation correction
待插值像素点像素值确定模块860,用于利用边缘增强衰减矫正系数对各个原始像素点的权重进行加权,得到卷积滤波权重;根据卷积滤波权重与邻域内各个原始像素点的像素值的乘积,确定目标图像中待插值像素点的像素值。The pixel
在一个实施例中,边缘信息确定模块830包括:In one embodiment, the edge
水平边缘信息确定模块,用于根据邻域内各个原始像素点的像素值,确定映射坐标点的水平边缘梯度值和对应的水平边缘强度值;A horizontal edge information determination module is used to determine the horizontal edge gradient value and the corresponding horizontal edge intensity value of the mapping coordinate point according to the pixel value of each original pixel point in the neighborhood;
垂直边缘信息确定模块,用于根据邻域内各个原始像素点的像素值,确定映射坐标点的垂直边缘梯度值和对应的垂直边缘强度值。The vertical edge information determination module is used to determine the vertical edge gradient value and the corresponding vertical edge intensity value of the mapping coordinate point according to the pixel value of each original pixel point in the neighborhood.
在一个实施例中,水平边缘信息确定模块用于:计算邻域内各个原始像素点的像素值的均值;获取邻域内原始像素点中的预设行的原始像素点;根据预设行的原始像素点在水平方向的差值,确定映射坐标点的水平边缘梯度值;根据预设行的原始像素点与均值之间的差值,确定映射坐标点的水平边缘强度值。In one embodiment, the horizontal edge information determination module is used to: calculate the mean of the pixel values of each original pixel point in the neighborhood; obtain the original pixel points of a preset row among the original pixel points in the neighborhood; determine the horizontal edge gradient value of the mapping coordinate point according to the difference in the horizontal direction of the original pixel points of the preset row; determine the horizontal edge intensity value of the mapping coordinate point according to the difference between the original pixel points of the preset row and the mean.
在一个实施例中,垂直边缘信息确定模块用于:计算邻域内各个原始像素点的像素值的均值;获取邻域内原始像素点中的预设列的原始像素点;根据预设列的原始像素点在垂直方向的差值,确定映射坐标点的垂直边缘梯度值;根据预设列的原始像素点与均值之间的差值,确定映射坐标点的垂直边缘强度值。In one embodiment, the vertical edge information determination module is used to: calculate the mean of the pixel values of each original pixel point in the neighborhood; obtain the original pixel points of a preset column among the original pixel points in the neighborhood; determine the vertical edge gradient value of the mapping coordinate point based on the difference in the vertical direction of the original pixel points of the preset column; determine the vertical edge intensity value of the mapping coordinate point based on the difference between the original pixel points of the preset column and the mean.
在一个实施例中,增强衰减矫正系数确定模块850包括:In one embodiment, the enhanced attenuation correction
水平边缘矫正系数确定模块,用于根据映射坐标点的水平边缘梯度值、水平边缘强度值和各个原始像素点相对映射坐标点的高斯距离,确定各个原始像素点的水平边缘矫正系数;A horizontal edge correction coefficient determination module is used to determine the horizontal edge correction coefficient of each original pixel point according to the horizontal edge gradient value, the horizontal edge intensity value and the Gaussian distance of each original pixel point relative to the mapping coordinate point;
垂直边缘矫正系数确定模块,用于根据映射坐标点的垂直边缘梯度值、垂直边缘强度值和各个原始像素点相对映射坐标点的高斯距离,确定各个原始像素点的垂直边缘矫正系数;A vertical edge correction coefficient determination module is used to determine the vertical edge correction coefficient of each original pixel point according to the vertical edge gradient value, the vertical edge intensity value and the Gaussian distance of each original pixel point relative to the mapping coordinate point;
边缘增强衰减矫正系数确定模块,用于根据各个原始像素点的水平边缘矫正系数和垂直边缘矫正系数,确定各个原始像素点的边缘增强衰减矫正系数。The edge enhancement attenuation correction coefficient determination module is used to determine the edge enhancement attenuation correction coefficient of each original pixel point according to the horizontal edge correction coefficient and the vertical edge correction coefficient of each original pixel point.
在一个实施例中,水平边缘矫正系数确定模块用于:根据映射坐标点的水平边缘梯度值,确定水平边缘增强衰减指数的正负性;根据映射坐标点的水平边缘强度值,确定水平边缘增强衰减底数的大小;针对各个原始像素点,以水平边缘增强衰减底数为底数,以水平边缘增强衰减指数和该原始像素点到映射坐标点的高斯距离之积为指数,进行幂运算得到该原始像素点的水平边缘矫正系数。In one embodiment, the horizontal edge correction coefficient determination module is used to: determine the positivity of the horizontal edge enhancement attenuation exponent according to the horizontal edge gradient value of the mapping coordinate point; determine the size of the horizontal edge enhancement attenuation base according to the horizontal edge intensity value of the mapping coordinate point; for each original pixel point, use the horizontal edge enhancement attenuation base as the base and the product of the horizontal edge enhancement attenuation exponent and the Gaussian distance from the original pixel point to the mapping coordinate point as the exponent to perform a power operation to obtain the horizontal edge correction coefficient of the original pixel point.
在一个实施例中,水平边缘矫正系数确定模块用于:根据映射坐标点的水平边缘梯度值的正负性,确定对应的曲线集;曲线集包括曲线斜率大于零的增强曲线集或曲线斜率小于零的衰减曲线集;根据水平边缘强度值,从确定的曲线集中选择对应的曲线,水平边缘强度值与选择的对应的曲线的斜率绝对值大小呈正比例;从选择的曲线中查询以各个原始像素点与映射坐标点之间的高斯距离为横坐标对应的纵坐标,作为各个原始像素点的水平边缘矫正系数。In one embodiment, the horizontal edge correction coefficient determination module is used to: determine a corresponding curve set according to the positive or negative horizontal edge gradient value of the mapping coordinate point; the curve set includes an enhancement curve set with a curve slope greater than zero or an attenuation curve set with a curve slope less than zero; select a corresponding curve from the determined curve set according to the horizontal edge intensity value, and the horizontal edge intensity value is positively proportional to the absolute value of the slope of the selected corresponding curve; query the vertical coordinate corresponding to the Gaussian distance between each original pixel point and the mapping coordinate point as the horizontal coordinate from the selected curve as the horizontal edge correction coefficient of each original pixel point.
在一个实施例中,垂直边缘矫正系数确定模块用于:根据映射坐标点的垂直边缘梯度值,确定垂直边缘增强衰减指数的正负性;根据映射坐标点的垂直边缘强度值,确定垂直边缘增强衰减底数的大小;针对各个原始像素点,以垂直边缘增强衰减底数为底数,以垂直边缘增强衰减指数和该原始像素点到映射坐标点的高斯距离之积为指数,进行幂运算得到该原始像素点的垂直边缘矫正系数。In one embodiment, the vertical edge correction coefficient determination module is used to: determine the positive or negative value of the vertical edge enhancement attenuation exponent according to the vertical edge gradient value of the mapping coordinate point; determine the size of the vertical edge enhancement attenuation base according to the vertical edge strength value of the mapping coordinate point; for each original pixel point, use the vertical edge enhancement attenuation base as the base, and use the product of the vertical edge enhancement attenuation exponent and the Gaussian distance from the original pixel point to the mapping coordinate point as the exponent to perform a power operation to obtain the vertical edge correction coefficient of the original pixel point.
在一个实施例中,垂直边缘矫正系数确定模块用于:根据映射坐标点的垂直边缘梯度值的正负性,确定对应的曲线集;曲线集包括曲线斜率大于零的增强曲线集或曲线斜率小于零的衰减曲线集;根据垂直边缘强度值,从确定的曲线集中选择对应的曲线,垂直边缘强度值与选择的对应的曲线的斜率绝对值大小呈正比例;从选择的曲线中查询以各个原始像素点与映射坐标点之间的高斯距离为横坐标对应的纵坐标,作为各个原始像素点的垂直边缘矫正系数。In one embodiment, the vertical edge correction coefficient determination module is used to: determine a corresponding curve set according to the positive or negative vertical edge gradient value of the mapping coordinate point; the curve set includes an enhancement curve set with a curve slope greater than zero or an attenuation curve set with a curve slope less than zero; select a corresponding curve from the determined curve set according to the vertical edge strength value, and the vertical edge strength value is positively proportional to the absolute value of the slope of the selected corresponding curve; query the vertical coordinate corresponding to the Gaussian distance between each original pixel point and the mapping coordinate point as the horizontal coordinate from the selected curve as the vertical edge correction coefficient of each original pixel point.
在一个实施例中,原始权重确定模块用于根据映射坐标点与邻域内各个原始像素点之间的高斯距离,确定邻域内各个原始像素点的权重如下式所示:In one embodiment, the original weight determination module is used to determine the weight of each original pixel point in the neighborhood according to the Gaussian distance between the mapping coordinate point and each original pixel point in the neighborhood, as shown in the following formula:
其中,(x,y)为邻域内原始像素点的坐标值,rsd(x,y)为邻域内原始像素点相对映射坐标点的高斯距离,w(x,y)为原始像素点(x,y)的权重,nx为归一化系数,σ为对应高斯分布的标准差。Among them, (x, y) is the coordinate value of the original pixel in the neighborhood, r sd (x, y) is the Gaussian distance between the original pixel and the mapped coordinate point in the neighborhood, w (x, y) is the weight of the original pixel (x, y), n x is the normalization coefficient, and σ is the standard deviation of the corresponding Gaussian distribution.
在一个实施例中,增强衰减矫正系数确定模块850用于根据边缘梯度方向信息、边缘强度信息和高斯距离,确定邻域内各个原始像素点的边缘增强衰减矫正系数如下式所示:In one embodiment, the enhancement attenuation correction
上式中,coeij为邻域内第i行第j列原始像素点的边缘增强衰减矫正系数,(x,y)为邻域内第i行第j列原始像素点的坐标值,rsd(x,y)为邻域内第i行第j列原始像素点相对于映射坐标点的高斯距离,h_signed的正负性根据水平边缘梯度值的正负性确定,v_signed的正负性根据垂直边缘梯度值的正负性确定,α的取值大小与水平边缘强度值呈正相关,β的取值大小与垂直边缘强度值呈正相关。In the above formula, coe ij is the edge enhancement attenuation correction coefficient of the original pixel point in the i-th row and j-th column in the neighborhood, (x, y) is the coordinate value of the original pixel point in the i-th row and j-th column in the neighborhood, r sd (x, y) is the Gaussian distance of the original pixel point in the i-th row and j-th column in the neighborhood relative to the mapped coordinate point, the positive and negative value of h_signed is determined according to the positive and negative value of the horizontal edge gradient, the positive and negative value of v_signed is determined according to the positive and negative value of the vertical edge gradient, the value of α is positively correlated with the horizontal edge strength value, and the value of β is positively correlated with the vertical edge strength value.
关于图像缩放装置的具体限定可以参见上文中对于图像缩放方法的限定,在此不再赘述。上述图像缩放装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For the specific definition of the image scaling device, please refer to the definition of the image scaling method above, which will not be repeated here. Each module in the above image scaling device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
在一个实施例中,提供了一种计算机设备,该计算机设备可以是终端,其内部结构图可以如图9所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口、显示屏和输入装置。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统和计算机程序。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机程序被处理器执行时以实现一种图像缩放方法。该计算机设备的显示屏可以是液晶显示屏或者电子墨水显示屏,该计算机设备的输入装置可以是显示屏上覆盖的触摸层,也可以是计算机设备外壳上设置的按键、轨迹球或触控板,还可以是外接的键盘、触控板或鼠标等。In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG9. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, an image scaling method is implemented. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covered on the display screen, or a key, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse, etc.
本领域技术人员可以理解,图9中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。Those skilled in the art will understand that the structure shown in FIG. 9 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
在一个实施例中,提供了一种计算机设备,包括存储器和处理器,存储器中存储有计算机程序,该处理器执行计算机程序时实现以下步骤:In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
获取目标图像中的待插值像素点;确定待插值像素点在原始图像中的映射坐标点,并获取原始图像中映射坐标点周围预设邻域内各个原始像素点的像素值;根据邻域内各个原始像素点的像素值,确定映射坐标点的边缘梯度方向信息和边缘强度信息;根据映射坐标点与邻域内各个原始像素点之间的高斯距离,确定邻域内各个原始像素点的权重;根据边缘梯度方向信息、边缘强度信息和高斯距离,确定邻域内各个原始像素点的边缘增强衰减矫正系数;利用边缘增强衰减矫正系数对各个原始像素点的权重进行加权,得到卷积滤波权重;根据卷积滤波权重与邻域内各个原始像素点的像素值的乘积,确定目标图像中待插值像素点的像素值。Obtain the pixel point to be interpolated in the target image; determine the mapping coordinate point of the pixel point to be interpolated in the original image, and obtain the pixel value of each original pixel point in a preset neighborhood around the mapping coordinate point in the original image; determine the edge gradient direction information and edge intensity information of the mapping coordinate point according to the pixel value of each original pixel point in the neighborhood; determine the weight of each original pixel point in the neighborhood according to the Gaussian distance between the mapping coordinate point and each original pixel point in the neighborhood; determine the edge enhancement attenuation correction coefficient of each original pixel point in the neighborhood according to the edge gradient direction information, edge intensity information and Gaussian distance; weight the weight of each original pixel point using the edge enhancement attenuation correction coefficient to obtain the convolution filter weight; determine the pixel value of the pixel point to be interpolated in the target image according to the product of the convolution filter weight and the pixel value of each original pixel point in the neighborhood.
在其它实施例中,处理器执行计算机程序时还实现如上任意一个实施例的图像缩放方法的步骤。In other embodiments, when the processor executes the computer program, the steps of the image scaling method in any one of the above embodiments are also implemented.
在一个实施例中,提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现以下步骤:In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
获取目标图像中的待插值像素点;确定待插值像素点在原始图像中的映射坐标点,并获取原始图像中映射坐标点周围预设邻域内各个原始像素点的像素值;根据邻域内各个原始像素点的像素值,确定映射坐标点的边缘梯度方向信息和边缘强度信息;根据映射坐标点与邻域内各个原始像素点之间的高斯距离,确定邻域内各个原始像素点的权重;根据边缘梯度方向信息、边缘强度信息和高斯距离,确定邻域内各个原始像素点的边缘增强衰减矫正系数;利用边缘增强衰减矫正系数对各个原始像素点的权重进行加权,得到卷积滤波权重;根据卷积滤波权重与邻域内各个原始像素点的像素值的乘积,确定目标图像中待插值像素点的像素值。Obtain the pixel point to be interpolated in the target image; determine the mapping coordinate point of the pixel point to be interpolated in the original image, and obtain the pixel value of each original pixel point in a preset neighborhood around the mapping coordinate point in the original image; determine the edge gradient direction information and edge intensity information of the mapping coordinate point according to the pixel value of each original pixel point in the neighborhood; determine the weight of each original pixel point in the neighborhood according to the Gaussian distance between the mapping coordinate point and each original pixel point in the neighborhood; determine the edge enhancement attenuation correction coefficient of each original pixel point in the neighborhood according to the edge gradient direction information, edge intensity information and Gaussian distance; weight the weight of each original pixel point using the edge enhancement attenuation correction coefficient to obtain the convolution filter weight; determine the pixel value of the pixel point to be interpolated in the target image according to the product of the convolution filter weight and the pixel value of each original pixel point in the neighborhood.
在其它实施例中,计算机程序被处理器执行时还实现如上任意一个实施例的图像缩放方法的步骤。In other embodiments, when the computer program is executed by a processor, the steps of the image scaling method of any of the above embodiments are also implemented.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一非易失性计算机可读取存储介质中,该计算机程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims (15)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910071588.2A CN109903224B (en) | 2019-01-25 | 2019-01-25 | Image scaling method and device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910071588.2A CN109903224B (en) | 2019-01-25 | 2019-01-25 | Image scaling method and device, computer equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109903224A CN109903224A (en) | 2019-06-18 |
CN109903224B true CN109903224B (en) | 2023-03-31 |
Family
ID=66944245
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910071588.2A Active CN109903224B (en) | 2019-01-25 | 2019-01-25 | Image scaling method and device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109903224B (en) |
Families Citing this family (19)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110738625B (en) * | 2019-10-21 | 2022-03-11 | Oppo广东移动通信有限公司 | Image resampling method, device, terminal and computer readable storage medium |
CN112862673B (en) * | 2019-11-12 | 2024-06-14 | 上海途擎微电子有限公司 | Adaptive image scaling method, adaptive image scaling device, and storage device |
CN111126254A (en) * | 2019-12-23 | 2020-05-08 | Oppo广东移动通信有限公司 | Image recognition method, device, equipment and storage medium |
CN111275730B (en) * | 2020-01-13 | 2024-10-01 | 平安国际智慧城市科技股份有限公司 | Map area determination method, device, equipment and storage medium |
KR20210112042A (en) * | 2020-03-04 | 2021-09-14 | 에스케이하이닉스 주식회사 | Image sensing device and operating method of the same |
CN111724304B (en) * | 2020-06-12 | 2024-04-19 | 深圳市爱协生科技股份有限公司 | Image scaling method and device, terminal equipment and storage medium |
CN113808012B (en) * | 2020-06-17 | 2024-07-12 | 京东方科技集团股份有限公司 | Image processing method, computer device, and computer-readable storage medium |
CN112037273B (en) * | 2020-09-09 | 2023-05-19 | 南昌虚拟现实研究院股份有限公司 | Depth information acquisition method and device, readable storage medium and computer equipment |
CN112508790B (en) * | 2020-12-16 | 2023-11-14 | 上海联影医疗科技股份有限公司 | Image interpolation method, device, equipment and medium |
CN113255656B (en) * | 2020-12-18 | 2024-12-03 | 深圳怡化时代智能自动化系统有限公司 | Image correcting method, device, equipment and storage medium |
CN112435171B (en) * | 2021-01-28 | 2021-04-20 | 杭州西瞳智能科技有限公司 | Reconstruction method of image resolution |
CN113850732B (en) * | 2021-08-10 | 2024-06-21 | 深圳曦华科技有限公司 | Local image processing method and device, electronic equipment and storage medium |
CN113781370B (en) * | 2021-08-19 | 2024-09-13 | 北京旷视科技有限公司 | Image enhancement method and device and electronic equipment |
CN113870113A (en) * | 2021-09-30 | 2021-12-31 | 上海载德信息科技股份有限公司 | An interpolation method, apparatus, device and storage medium |
CN114331836B (en) * | 2021-12-15 | 2025-02-07 | 锐芯微电子股份有限公司 | Image processing method and device, and readable storage medium |
CN114170091B (en) * | 2021-12-29 | 2025-06-06 | 杭州海康机器人股份有限公司 | Image scaling method, device, electronic device and storage medium |
CN115409975A (en) * | 2022-09-07 | 2022-11-29 | Oppo广东移动通信有限公司 | Down-sampling method, down-sampling device, electronic apparatus, and storage medium |
CN119494969B (en) * | 2025-01-13 | 2025-05-30 | 中国刑事警察学院 | Multi-scene video image texture feature extraction method based on attention mechanism |
CN120147114A (en) * | 2025-02-26 | 2025-06-13 | 郑州灏天智能科技有限公司 | A method for intelligent image scaling |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101216935A (en) * | 2008-01-17 | 2008-07-09 | 四川虹微技术有限公司 | Image Enlargement Method Based on Spline Function Interpolation Algorithm |
CN101615288A (en) * | 2008-06-27 | 2009-12-30 | 富士通株式会社 | Apparatus, method and computer readable recording medium for pixel interpolation |
CN106251339A (en) * | 2016-07-21 | 2016-12-21 | 深圳市大疆创新科技有限公司 | Image processing method and device |
CN107644398A (en) * | 2017-09-25 | 2018-01-30 | 上海兆芯集成电路有限公司 | Image interpolation method and its associated picture interpolating device |
CN108805806A (en) * | 2017-04-28 | 2018-11-13 | 华为技术有限公司 | Image processing method and device |
CN108961167A (en) * | 2018-07-12 | 2018-12-07 | 安徽理工大学 | A kind of Bayer-CFA interpolation method based on finite difference and gradient |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9076232B2 (en) * | 2011-11-29 | 2015-07-07 | Industry-Academic Cooperation Foundation, Yonsei University | Apparatus and method for interpolating image, and apparatus for processing image using the same |
-
2019
- 2019-01-25 CN CN201910071588.2A patent/CN109903224B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101216935A (en) * | 2008-01-17 | 2008-07-09 | 四川虹微技术有限公司 | Image Enlargement Method Based on Spline Function Interpolation Algorithm |
CN101615288A (en) * | 2008-06-27 | 2009-12-30 | 富士通株式会社 | Apparatus, method and computer readable recording medium for pixel interpolation |
CN106251339A (en) * | 2016-07-21 | 2016-12-21 | 深圳市大疆创新科技有限公司 | Image processing method and device |
CN108805806A (en) * | 2017-04-28 | 2018-11-13 | 华为技术有限公司 | Image processing method and device |
CN107644398A (en) * | 2017-09-25 | 2018-01-30 | 上海兆芯集成电路有限公司 | Image interpolation method and its associated picture interpolating device |
CN108961167A (en) * | 2018-07-12 | 2018-12-07 | 安徽理工大学 | A kind of Bayer-CFA interpolation method based on finite difference and gradient |
Also Published As
Publication number | Publication date |
---|---|
CN109903224A (en) | 2019-06-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109903224B (en) | Image scaling method and device, computer equipment and storage medium | |
CN103167218B (en) | A kind of super resolution ratio reconstruction method based on non-locality and equipment | |
CN109784372B (en) | Target classification method based on convolutional neural network | |
CN110021271B (en) | Optical compensation method, optical compensation system, display method and display device | |
CN110796624B (en) | Image generation method and device and electronic equipment | |
JPWO2014083857A1 (en) | Image processing apparatus and image processing method | |
CN104376542A (en) | Image enhancement method | |
CN112967207A (en) | Image processing method and device, electronic equipment and storage medium | |
CN116843566A (en) | Tone mapping method, tone mapping device, display device and storage medium | |
CN115619678A (en) | Image deformation correction method and device, computer equipment and storage medium | |
CN114372941B (en) | Low-light image enhancement method, device, equipment and medium | |
CN112419231A (en) | Visibility determination method, device, computer equipment and storage medium | |
CN114463225B (en) | Bilateral filtering method and device | |
CN107220934A (en) | Image rebuilding method and device | |
CN111784733B (en) | Image processing method, device, terminal and computer readable storage medium | |
CN113963072A (en) | Binocular camera calibration method and device, computer equipment and storage medium | |
WO2025025690A1 (en) | Method and apparatus for determining accuracy of vision system, and computer readable storage medium | |
CN114612295A (en) | Image super-resolution processing method and computer equipment | |
US9594955B2 (en) | Modified wallis filter for improving the local contrast of GIS related images | |
CN117974420A (en) | Image processing method, device, computer equipment and storage medium | |
JP2020191030A (en) | Image processing device | |
CN115314633B (en) | Camera focusing method, device, computer equipment and storage medium | |
CN116739936A (en) | Tone mapping method, tone mapping device, display device and storage medium | |
CN112465931B (en) | Image text erasing method, related equipment and readable storage medium | |
CN112163999B (en) | Image reconstruction method and device, electronic equipment and readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information |
Address after: 519000 No. 333, Kexing Road, Xiangzhou District, Zhuhai City, Guangdong Province Applicant after: ZHUHAI JIELI TECHNOLOGY Co.,Ltd. Address before: Floor 1-107, building 904, ShiJiHua Road, Zhuhai City, Guangdong Province Applicant before: ZHUHAI JIELI TECHNOLOGY Co.,Ltd. |
|
CB02 | Change of applicant information | ||
GR01 | Patent grant | ||
GR01 | Patent grant |