CN107256557B - Error-controllable subdivision surface image vectorization method - Google Patents
Error-controllable subdivision surface image vectorization method Download PDFInfo
- Publication number
- CN107256557B CN107256557B CN201710304102.6A CN201710304102A CN107256557B CN 107256557 B CN107256557 B CN 107256557B CN 201710304102 A CN201710304102 A CN 201710304102A CN 107256557 B CN107256557 B CN 107256557B
- Authority
- CN
- China
- Prior art keywords
- image
- mesh
- edge
- grid
- error
- 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.)
- Expired - Fee Related
Links
- 238000000034 method Methods 0.000 title claims abstract description 73
- 230000003044 adaptive effect Effects 0.000 claims abstract description 20
- 238000004364 calculation method Methods 0.000 claims description 14
- 239000003086 colorant Substances 0.000 claims description 11
- 238000005457 optimization Methods 0.000 claims description 11
- 239000011159 matrix material Substances 0.000 claims description 9
- 238000005070 sampling Methods 0.000 claims description 6
- 230000007423 decrease Effects 0.000 claims description 5
- 238000012545 processing Methods 0.000 claims description 5
- 238000004458 analytical method Methods 0.000 claims description 4
- 238000001514 detection method Methods 0.000 claims description 3
- 238000001914 filtration Methods 0.000 claims description 3
- 238000003672 processing method Methods 0.000 claims description 3
- 238000009877 rendering Methods 0.000 claims description 3
- 230000009977 dual effect Effects 0.000 claims 1
- 238000005516 engineering process Methods 0.000 abstract description 2
- 238000010586 diagram Methods 0.000 description 8
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000007812 deficiency Effects 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000009792 diffusion process Methods 0.000 description 1
- 238000002474 experimental method Methods 0.000 description 1
- 238000000605 extraction Methods 0.000 description 1
- 238000012800 visualization Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/13—Edge detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/70—Denoising; Smoothing
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/90—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using coding techniques not provided for in groups H04N19/10-H04N19/85, e.g. fractals
- H04N19/94—Vector quantisation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10024—Color image
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Image Analysis (AREA)
- Image Processing (AREA)
Abstract
本发明公开了一种误差可控的细分曲面图像矢量化方法,包括如下步骤:1)检测图像边缘特征,得到一个像素宽的初始图像特征线段;2)构造基于图像特征的初始网格,并在网格中标记图像特征;3)简化初始网格,构造保持图像特征的基网格;4)误差可控的Loop细分曲面拟合求得控制网格;5)光栅化矢量表示。给定一张光栅图像,本发明能够得到较好的矢量图像,如果初始重构结果的误差不能满足用户需求,本发明可以衡量出矢量化的重构图像与原图像误差,通过对基网格进行自适应细分以达到一定范围内的指定误差,做到误差可控。本发明研究使用细分曲面技术进行图像矢量化,目的是将光栅图像转换为满足误差要求的矢量表示,具有实际应用价值。
The invention discloses an error-controllable subdivision surface image vectorization method, comprising the following steps: 1) detecting edge features of an image to obtain an initial image feature line segment with a width of one pixel; 2) constructing an initial grid based on the image features, And mark the image features in the grid; 3) Simplify the initial grid to construct a base grid that maintains the image features; 4) Obtain the control grid by fitting the loop subdivision surface with controllable error; 5) Rasterized vector representation. Given a raster image, the present invention can obtain a better vector image. If the error of the initial reconstruction result cannot meet the needs of the user, the present invention can measure the error between the vectorized reconstructed image and the original image. Adaptive subdivision is performed to achieve a specified error within a certain range, so that the error is controllable. The present invention studies image vectorization using subdivision surface technology, and aims to convert raster images into vector representations that meet error requirements, which has practical application value.
Description
技术领域technical field
本发明涉及利用细分曲面技术进行图像矢量化的领域,尤其是指一种误差可控的细分曲面图像矢量化方法,目的是将光栅图像转换为满足误差要求的矢量表示。The invention relates to the field of image vectorization using subdivision surface technology, in particular to a subdivision surface image vectorization method with controllable error, which aims to convert a raster image into a vector representation that meets error requirements.
背景技术Background technique
在计算机中,图像有两种典型的表示方式,一种是光栅图像,也称为位图、点阵图像,一种是矢量图像,也称矢量图形、矢量表示。与光栅图像相比,矢量图形具有很多优点,如存储量小,易编辑,分辨率无关等。随着显示设备多样化的发展和分辨率的提高,矢量图像的优势日益凸显。图像矢量化的目的就是将点阵图像转换为矢量图像。In the computer, there are two typical representations of images, one is raster image, also known as bitmap, bitmap image, the other is vector image, also known as vector graphics, vector representation. Compared with raster images, vector graphics have many advantages, such as small storage, easy editing, resolution independent and so on. With the diversified development of display devices and the improvement of resolution, the advantages of vector images have become increasingly prominent. The purpose of image vectorization is to convert bitmap images into vector images.
近年来,学者们提出很多不同的图像矢量化算法。各种不同的几何图元被提出用来表示矢量图,包括直线、曲线、三角网格、参数曲面、细分曲面、扩散曲线等。然而,由于图像具有复杂的特征曲线和丰富的颜色变化,现有的这些矢量表示方式都存在共同的难点,一个是如何用较少的图元很好地表示出原图像,一个是该矢量表示的可编辑性。细分曲面具有良好的光顺性、适合表示任意复杂拓扑的物体、可编辑性强等诸多优点。文献[LIAO Z,HOPPE H,FORSYTH D,et al.A subdivision-based representation for vector imageediting[J].IEEE Transactions on Visualization and Computer Graphics,2012,18(11):1858-1867.]中,Liao等人提出基于分段光滑细分曲面表示的矢量图编辑算法。该矢量图表示方式具有强大的可编辑能力,而且可以实现多分辨率,一定条件下,当几何图元的数目增加时,分辨率越高,反之越低。但该算法也存在一些问题,首先该方法通过分裂亚像素边缘来建模图像边缘两侧颜色值的不连续,但是采用的亚像素边缘提取不够准确,得到的两侧的颜色值不准确,而且其矢量化结果过度依赖于基网格,不能做到误差可控。因此本发明对该框架的方法进行研究和改进,做到一定范围内的误差控制。In recent years, scholars have proposed many different image vectorization algorithms. A variety of different geometric primitives are proposed to represent vector graphics, including lines, curves, triangular meshes, parametric surfaces, subdivision surfaces, diffusion curves, etc. However, due to the complex characteristic curves and rich color changes of the image, these existing vector representations all have common difficulties. One is how to represent the original image well with fewer primitives, and the other is the vector representation. editability. Subdivision surfaces have many advantages, such as good smoothness, suitable for representing objects with arbitrary complex topology, and strong editability. In the literature [LIAO Z, HOPPE H, FORSYTH D, et al. A subdivision-based representation for vector imageediting [J]. IEEE Transactions on Visualization and Computer Graphics, 2012, 18(11): 1858-1867.], Liao et al. A vector image editing algorithm based on piecewise smooth subdivision surface representation was proposed. The vector representation has powerful editability and can achieve multi-resolution. Under certain conditions, when the number of geometric primitives increases, the resolution will be higher, and vice versa. However, this algorithm also has some problems. First, the method models the discontinuity of color values on both sides of the image edge by splitting the sub-pixel edges, but the sub-pixel edge extraction used is not accurate enough, and the obtained color values on both sides are inaccurate, and The vectorization result is overly dependent on the base grid, and the error cannot be controlled. Therefore, the method of the framework is studied and improved in the present invention to achieve error control within a certain range.
发明内容SUMMARY OF THE INVENTION
本发明的目的在于克服Liao等人提出的细分曲面表示的图像矢量化算法的不足,提出了一种误差可控的细分曲面图像矢量化方法,对矢量化结果做到一定范围内的误差控制,满足用户的误差要求。The purpose of the present invention is to overcome the deficiencies of the image vectorization algorithm represented by the subdivision surface proposed by Liao et al., and propose a subdivision surface image vectorization method with a controllable error, which can achieve an error within a certain range for the vectorization result. Control to meet the user's error requirements.
为实现上述目的,本发明所提供的技术方案为:一种误差可控的细分曲面图像矢量化方法,包括以下步骤:In order to achieve the above purpose, the technical solution provided by the present invention is: a method for vectorizing a subdivision surface image with controllable error, comprising the following steps:
1)检测图像边缘特征1) Detect image edge features
图像边缘是最显著的图像特征,为了在构造保持图像特征的基网格,使用图像边缘线段检测方法来提取图像的一个像素宽的特征线,其步骤为:The image edge is the most significant image feature. In order to construct the base grid that maintains the image features, the image edge line segment detection method is used to extract the one-pixel-wide feature line of the image. The steps are:
①高斯滤波:用高斯核卷积图像来抑制图像噪声和平滑图像;①Gaussian filtering: Convolve the image with a Gaussian kernel to suppress image noise and smooth the image;
②计算梯度幅值和边缘方向图:首先使用梯度算子分别计算出像素点的水平和垂直梯度,然后算出图像梯度幅值图,与此同时,比较像素水平和垂直梯度的大小,确定该像素点的边缘方向,如果水平梯度较大,则认为通过该像素是个垂直方向边缘,反之亦然;②Calculate the gradient magnitude and edge direction map: First, use the gradient operator to calculate the horizontal and vertical gradients of the pixel respectively, and then calculate the image gradient magnitude map. At the same time, compare the size of the horizontal and vertical gradients of the pixel to determine the pixel. The edge direction of the point, if the horizontal gradient is large, it is considered to be a vertical edge through the pixel, and vice versa;
③提取锚点:锚点可以被认为是边缘结束的地方,即在水平和垂直方向特征变化剧烈的像素点,这里选择局部梯度极值作为锚点,通过比较像素点与其相邻像素点的梯度值来判断该像素点是否是锚点,对于一个水平方向的像素点,将其与左右相邻的像素点比较,如果该像素点的梯度值比左右相邻像素梯度值大指定阈值,则认为该像素点为锚点;③Extract anchor points: An anchor point can be considered as the end of the edge, that is, a pixel point with drastic feature changes in the horizontal and vertical directions. Here, the local gradient extreme value is selected as the anchor point, and the gradient between the pixel point and its adjacent pixels is compared. value to determine whether the pixel is an anchor point. For a horizontal pixel, compare it with the left and right adjacent pixels. If the gradient value of the pixel is greater than the gradient value of the left and right adjacent pixels by a specified threshold, it is considered that The pixel is the anchor point;
④连接锚点形成线段:根据梯度幅值和边缘方向图来连接相邻锚点,每次从还未被检测过的锚点开始,观察穿过该锚点的边缘方向,如果是水平边缘,通过向左和向右行进开始连接过程,如果垂直边缘通过锚点,通过向上和向下行进进行连接过程,在移动期间,仅考虑三个直接邻居像素,并且选择具有最大梯度值的那个邻居像素,当遇到梯度幅值为0的像素点或遇到之前已经检测过的边缘像素时,该次处理过程停止;④ Connect anchor points to form line segments: Connect adjacent anchor points according to the gradient amplitude and edge direction map, starting from the anchor point that has not been detected each time, observe the edge direction passing through the anchor point, if it is a horizontal edge, The connection process is started by traveling left and right, if the vertical edge passes the anchor point, the connection process is performed by traveling up and down, during the movement, only three immediate neighbor pixels are considered, and the one with the largest gradient value is selected , when encountering a pixel with a gradient amplitude of 0 or encountering an edge pixel that has been detected before, the processing stops;
2)构造基于图像特征的初始网格,并在网格中标记图像特征2) Construct an initial grid based on image features, and label image features in the grid
在2D图像平面上建立像素分辨率的初始三角网格M。首先建立初始网格顶点,图像中的每个像素点对应网格中的一个顶点,并在顶点的属性中记录像素点的颜色值;然后以行和列的方式连接网格顶点形成矩形网格,根据图像特征线将网格中的每个矩形网格划分成两个三角网格。Build an initial triangular mesh M of pixel resolution on the 2D image plane. First establish the initial grid vertex, each pixel in the image corresponds to a vertex in the grid, and record the color value of the pixel in the vertex attribute; then connect the grid vertices in rows and columns to form a rectangular grid , which divides each rectangular grid in the grid into two triangular grids according to the image feature lines.
图像颜色不连续性与至少两个具有非常不同颜色强度的相邻像素相关联,单独的图像边缘线不足以表示图像颜色的不连续性。因此本发明提出使用双特征线来表示图像颜色的不连续。首先使用等值线追踪算法找出图像特征线两侧的距离一像素的平行线段,然后通过比较两侧的图像梯度选择平均梯度大的线段作为另一特征线,并对受影响的三角网格进行重新三角化。Image color discontinuities are associated with at least two adjacent pixels with very different color intensities, and image edge lines alone are not sufficient to represent image color discontinuities. Therefore, the present invention proposes to use a double characteristic line to represent the discontinuity of the color of the image. First, use the contour tracing algorithm to find the parallel line segments with a distance of one pixel on both sides of the image feature line, and then select the line segment with the larger average gradient as another feature line by comparing the image gradients on both sides. Retriangulate.
接下来,对初始网格的边和顶点的类型进行标记,从而在后续的网格简化、细分等操作中对不同的类型进行不同的处理以保持重要的图像特征。本发明将网格的边分为三种类型:边界边、平滑边、折痕边,将网格的顶点分为四种类型:边界点、平滑点、折痕点、角点。将图像的双特征线标记为折痕边,将图像矩阵边界的边标记为边界边,其他边为平滑边。对于网格顶点,如果顶点只与平滑边缘连接,则该顶点标记为平滑点;折痕顶点与两条邻接的折痕边连接;边界点与两条邻接的边界边连接;图像特征线端点、特征线交叉点标记为角点。为了固定矩形图像边界,四个角被标记为角点。Next, the types of edges and vertices of the initial mesh are marked, so that different types are processed differently in subsequent operations such as mesh simplification, subdivision, etc. to maintain important image features. The invention divides the edges of the mesh into three types: boundary edge, smooth edge and crease edge, and divides the vertices of the mesh into four types: boundary point, smooth point, crease point and corner point. Label the double feature lines of the image as crease edges, the edges of the image matrix boundary as boundary edges, and the other edges as smooth edges. For mesh vertices, if the vertex is only connected with smooth edges, the vertex is marked as a smooth point; a crease vertex is connected with two adjacent crease edges; a boundary point is connected with two adjacent boundary edges; image feature line endpoints, Breakpoint intersections are marked as corners. To fix the rectangular image boundary, the four corners are marked as corner points.
3)简化初始网格,构造保持图像特征的基网格3) Simplify the initial grid and construct a base grid that preserves image features
采用QEM简化算法来简化图像初始网格,得到基网格MB,将网格的颜色属性看成高度场来计算二次误差代价,并且在简化过程中使用细分曲线来拟合图像特征线段来保持图像特征;The QEM simplification algorithm is used to simplify the initial grid of the image, and the base grid MB is obtained. The color attribute of the grid is regarded as a height field to calculate the quadratic error cost, and the subdivision curve is used to fit the image feature line during the simplification process. to preserve image features;
在上一步骤中,根据图像特征对网格的顶点和边做了分类。为了保持图像的形状和特征,对于不同的特征采取不同的处理方式:①角点不允许被折叠;②边界点只能与其邻接的同边界的两个边界点折叠;③折痕点只能与其邻接的同折痕边的两个折痕点折叠;④平滑点可以折叠到特征点。In the previous step, the vertices and edges of the mesh were classified according to the image features. In order to maintain the shape and characteristics of the image, different processing methods are adopted for different features: ① the corner points are not allowed to be folded; ② the boundary point can only be folded with two adjacent boundary points of the same boundary; ③ the crease point can only be folded with the same boundary The two adjacent crease points on the same crease edge are folded; ④The smooth point can be folded to the feature point.
此外,为了得到一个高质量的保持图像特征的基网格,改进QEM算法的边折叠代价,在边折叠代价中加入特征边形变代价Qfeature、三角形正则性代价Qre、面积代价Qarea,并赋予它们相应的权重,用Qqem表示QEM代价,则能够把边折叠的代价表示为:In addition, in order to obtain a high-quality base mesh that preserves image features, the edge folding cost of the QEM algorithm is improved, and the feature edge deformation cost Q feature , the triangle regularity cost Q re , and the area cost Q area are added to the edge folding cost, and Give them corresponding weights, and use Q qem to represent the QEM cost, then the edges can be folded The cost is expressed as:
Cost(v1,v2)=αQqem(v1,v2)+βQfeature(v1,v2)+γQre(v1,v2)+δQarea(v1,v2) (1)Cost(v 1 ,v 2 )=αQ qem (v 1 ,v 2 )+βQ feature (v 1 ,v 2 )+γQ re (v 1 ,v 2 )+δQ area (v 1 ,v 2 )(1 )
式中,权重α,β,γ,δ由用户指定,边折叠顺序按照Cost(v1,v2)从小到大进行。需要特别说明的是,为了保证简化后二维网格的质量,除了在计算QEM代价时,将网格M的颜色属性看成高度场,在计算其他代价时,考虑的都只是二维图像网格,不考虑颜色属性。其中QEM代价Qqem、特征边形变代价Qfeature、三角形正则性代价Qre、面积代价Qarea的定义如下:In the formula, the weights α, β, γ, and δ are specified by the user, and the order of edge folding is carried out according to Cost(v 1 , v 2 ) from small to large. It should be noted that, in order to ensure the quality of the simplified two-dimensional grid, except when calculating the QEM cost, the color attribute of the grid M is regarded as a height field, and when calculating other costs, only the two-dimensional image network is considered. grid, regardless of color properties. The definition of the QEM cost Q qem , the characteristic edge deformation cost Q feature , the triangle regularity cost Q re , and the area cost Q area are as follows:
QEM代价Qqem:用二次误差代价来计算边的二次误差代价,其衡量的是三维空间点到平面的距离,而网格M是个二维网格,所以将网格M的颜色属性看成高度场,分别用RGB的值作为高度,则每条边可计算出三个代价,将其和作为该边的二次误差代价Qqem;QEM cost Q qem : The quadratic error cost is used to calculate the quadratic error cost of the edge, which measures the distance from the point in the three-dimensional space to the plane, and the grid M is a two-dimensional grid, so the color attribute of the grid M is viewed form a height field, and use the RGB value as the height respectively, then each edge can calculate three costs, and use the sum as the quadratic error cost Q qem of the edge;
特征边形变代价Qfeature:QEM代价没有考虑到模型的尖锐特征,不能反映图像的特征,定义Qfeature为折叠前的特征点到其邻接的两个特征点连线的距离,用来衡量特征边折叠结果与折叠点的偏离程度,Qfeature值越小,表明偏离越小,如果折叠的边是非特征边,则Qfeature值为0;Feature edge deformation cost Q feature : The QEM cost does not take into account the sharp features of the model and cannot reflect the features of the image. Q feature is defined as the distance between the feature point before folding and the line connecting the two adjacent feature points, which is used to measure the feature edge. The degree of deviation between the folding result and the folding point. The smaller the Q feature value, the smaller the deviation. If the folded edge is a non-feature edge, the Q feature value is 0;
三角形正则性代价Qre:在边折叠代价中加入三角形正则性代价是为了减少狭长的三角面片的出现,三角形的正则性被用来表示其接近正三角形的程度,能够用R(t)=cos(∠A)+cos(∠B)+cos(∠C)来度量三角形t=ΔABC的正则性,令Re(t)=3-2R(t),则0≤Re(t)≤1,Re(t)的值越小,表明该三角形的正则性越高,则定义三角面片集合T的正则性为:Triangle regularity cost Q re : The triangle regularity cost is added to the edge folding cost in order to reduce the appearance of long and narrow triangular patches. The regularity of a triangle is used to indicate the degree to which it is close to an equilateral triangle, which can be expressed by R(t)= cos(∠A)+cos(∠B)+cos(∠C) to measure the regularity of triangle t=ΔABC, let Re(t)=3-2R(t), then 0≤Re(t)≤1, The smaller the value of Re(t) is, the higher the regularity of the triangle is, and the regularity of the triangular patch set T is defined as:
Re(T)=max{Re(t)|t∈T} (2)Re(T)=max{Re(t)|t∈T} (2)
把Qre定义为边折叠前后,相关三角面片的正则性增量,则边折叠的正则性代价定义为:Define Q re as the regularity increment of the relevant triangular patches before and after the edge is folded, then the edge is folded The regularity cost of is defined as:
其中,表示顶点的邻接三角面片;in, represents a vertex The adjoining triangular patch of ;
面积代价Qarea:三角形正则性代价Qre反映了三角面片的形状,没有反映面片大小,因此,在总代价中加入面积代价来约束面片的面积,把面积代价Qarea定义为边折叠后新顶点所有邻接面的面积总和,则边折叠的面积代价定义为:Area cost Q area : The triangle regularity cost Q re reflects the shape of the triangle patch, but not the size of the patch. Therefore, the area cost is added to the total cost to constrain the area of the patch, and the area cost Q area is defined as edge folding After the sum of the areas of all adjacent faces of the new vertex, the edge is collapsed The area cost of is defined as:
其中,area(t)表示三角形t的面积。where area(t) represents the area of the triangle t.
其中,网格简化算法的步骤如下:Among them, the steps of the mesh simplification algorithm are as follows:
①设置边折叠代价公式(1)中的各项权值;①Set the weights in the edge folding cost formula (1);
②将网格M的颜色属性看成高度场,计算网格所有边的QEM代价Qqem;② Consider the color attribute of the grid M as a height field, and calculate the QEM cost Q qem of all edges of the grid;
③计算所有可折叠边的折叠代价,根据折叠代价将其放入最小堆中,根据公式(1)计算出每条边对应的两条半边的折叠代价,则边的折叠代价取两个半边代价的小值,并记录折叠方向;③ Calculate the folding cost of all foldable edges, put them into the minimum heap according to the folding cost, and calculate the folding cost of the two half-edges corresponding to each edge according to formula (1), then the folding cost of the edge takes two half-edge costs The small value of , and record the folding direction;
④从堆中取出最小折叠代价的边,判断其折叠后相关面是否会反生翻转,若会,则给该边的代价加一个惩罚值,更新其在堆中的位置;若不会反生翻转,则判断该边是否是特征边,若是特征边,拟合调整特征点的位置并判断其折叠后拟合误差是否符合要求,若不符合,则不折叠该边,将其从堆中删除;否则就完成该边的折叠操作,重新计算相关边的折叠代价并更新它们在堆中的位置;4. Take the edge with the smallest folding cost from the heap, and judge whether the relevant face will be flipped after it is folded. If so, add a penalty value to the cost of the edge and update its position in the heap; if it will not be reversed Flip, judge whether the edge is a feature edge, if it is a feature edge, fit and adjust the position of the feature point and judge whether the fitting error after folding meets the requirements, if not, do not fold the edge and delete it from the heap ; otherwise, complete the collapsing operation of the edge, recalculate the collapsing cost of the relevant edge and update their position in the heap;
⑤若达到简化的要求或最小堆为空,则转到⑥,否则转到④;⑤ If the simplified requirements are met or the minimum heap is empty, go to ⑥, otherwise go to ④;
⑥删除网格中的独立顶点,更新网格,输出基网格。⑥ Delete independent vertices in the mesh, update the mesh, and output the base mesh.
虽然在网格简化过程中考虑了面片正则性、面积因素,但是仍不能保证能得到一个高质量基网格,因此使用Laplacian算子对网格进行几何优化:Although the patch regularity and area factors are considered in the mesh simplification process, a high-quality base mesh cannot be guaranteed, so the Laplacian operator is used to optimize the mesh geometry:
其中N(v)和|N(v)|分别表示顶点v的1邻域的所有顶点集合和个数。网格中顶点的新位置由vnew=v+λΔv迭代式给出,其中λ取值为0.3。where N(v) and |N(v)| represent the set and number of all vertices in the 1-neighborhood of vertex v, respectively. The new positions of the vertices in the mesh are given iteratively by vnew = v+ λΔv , where λ takes the value 0.3.
为了保持图像的特征,对网格特征顶点进行特殊处理:首先,角点不进行移动,对于边界顶点和特征点v,设(va,v)和(v,vb)为v所在的两条特征边,则v只根据va和vb的位置进行调整,即Laplacian算子定义为:In order to maintain the characteristics of the image, special processing is performed on the mesh feature vertices: first, the corners do not move. For the boundary vertex and feature point v, let (v a , v ) and (v, v b ) be the two locations where v is located. feature edges, then v is only adjusted according to the positions of v a and v b , that is, the Laplacian operator is defined as:
需要说明的是,网格优化能够在网格简化的过程中进行,也能够在网格简化结束后进行,如果网格优化会造成面片翻转,则暂时不进行优化。It should be noted that the mesh optimization can be performed during the mesh simplification process or after the mesh simplification is completed. If the mesh optimization will cause the patches to be flipped, the optimization will not be performed for the time being.
4)误差可控的Loop细分曲面拟合求得控制网格4) Control mesh obtained by loop subdivision surface fitting with controllable error
经过网格的简化和优化得到反映图像特征的基网格后,提出带误差控制的Loop细分曲面拟合来对图像颜色进行拟合,在计算控制网格的过程中进行误差控制,用户可以通过指定重构图像的误差来获得满足需求的矢量图像。该过程主要包括三个部分:控制网格的计算、误差控制以及自适应细分,具体如下:After grid simplification and optimization, the base grid reflecting the image features is obtained, and loop subdivision surface fitting with error control is proposed to fit the image color. In the process of calculating the control grid, the user can control the error. Obtain a vector image that meets your needs by specifying the error of the reconstructed image. The process mainly includes three parts: control grid calculation, error control and adaptive subdivision, as follows:
4.1)控制网格的计算。4.1) Control the calculation of the mesh.
为了增加拟合目标的数据量,我们首先对基网格MB进行一次1-4细分得到网格然后使用网格对原图像进行采样得到MR,将MR作为我们拟合的目标。像素点的颜色值在图像特征区域有着显著的变化,为了采样到准确的颜色值,我们对不同的网格特征采用不同的采样方式得到顶点的颜色值:对于折痕顶点,它的目标颜色为它所在的图像特征线上和它位置最接近的像素点的颜色值;对于角点,它在简化过程和细分过程中的位置都没有移动,所以它的目标颜色为顶点坐标确定的图像像素点的颜色值;对于平滑顶点,其颜色由其周围的像素点进行双线性插值得到。In order to increase the amount of data to fit the target, we first perform a 1-4 subdivision on the base grid MB to obtain a grid then use grid Sampling the original image to get MR , and take MR as our fitting target. The color value of the pixel has a significant change in the image feature area. In order to sample the accurate color value, we use different sampling methods for different mesh features to obtain the color value of the vertex: for the crease vertex, its target color is The color value of the pixel point closest to its position on the image feature line where it is located; for corner points, its position has not moved during the simplification process and the subdivision process, so its target color is the image pixel determined by the vertex coordinates The color value of the point; for smooth vertices, the color is bilinearly interpolated from the surrounding pixels.
在网格简化过程中已经拟合了网格的特征顶点位置,为了计算方便,这里只拟合网格顶点的颜色。因此所要计算的控制网格MC和基网格MB具有相同的拓扑结构。因此,对控制网格MC进行一次Loop细分后获得的网格和MR具有相同的拓扑关系。根据Loop极限模版求网格的极限得到细分极限曲面MS,拟合目标就是:In the process of mesh simplification, the feature vertex positions of the mesh have been fitted. For the convenience of calculation, only the colors of the mesh vertices are fitted here. Therefore, the control mesh M C to be calculated and the base mesh MB have the same topology. Therefore, the mesh obtained after a loop subdivision of the control mesh M C and MR have the same topological relationship. Grid based on Loop limit template The limit of the subdivision limit surface M S is obtained, and the fitting objective is:
MR=MS (7)M R = M S (7)
设基网格MB和目标网格MC的顶点数分别为n和m,分别用表示网格MC、MR、MS的顶点颜色构成的向量,则根据带尖锐特征的Loop细分模版和极限模版,存在有细分矩阵Sm×n和极限矩阵Lm×m使得: 所以可以将Loop细分拟合方程(7)表示为:Let the number of vertices of the base mesh MB and the target mesh M C be n and m, respectively. Represents meshes M C , MR , The vector formed by the vertex colors of M S , according to the Loop subdivision template and limit template with sharp features, there are subdivision matrix S m×n and limit matrix L m×m such that: So the Loop subdivision fitting equation (7) can be expressed as:
令Zm×n=Lm×mSm×n,方程组(8)变换为:Let Z m×n =L m×m S m×n , the equation system (8) is transformed into:
通过求解线性方程组(9)就能够得到控制网格MC,因为这里拟合的是网格顶点的颜色,所以和的大小分别为n×3和m×3,RGB三种颜色能够分开求解。The control mesh M C can be obtained by solving the linear equation system (9), because the color of the mesh vertices is fitted here, so and The sizes are n×3 and m×3, respectively, and the three colors of RGB can be solved separately.
4.2)误差控制。4.2) Error control.
将每个像素点的重构误差定义为重构图像与原图像对应像素点颜色值的欧式距离,而将整个图像的重构误差e定义为所有像素点重构误差的均值,每个基网格面片的重构误差ef定义为该面片光栅化后所对应的所有像素点重构误差的均值。The reconstruction error of each pixel is defined as the Euclidean distance between the reconstructed image and the color value of the corresponding pixel of the original image, and the reconstruction error e of the entire image is defined as the mean of the reconstruction errors of all pixels. The reconstruction error ef of a grid patch is defined as the mean of reconstruction errors of all pixel points corresponding to the patch after rasterization.
在上一步骤中,通过Loop细分曲面拟合求得控制网格,使其对应的细分曲面尽可能接近原图像。但是控制网格的顶点数目依赖于网格简化,如果简化过度,使得控制网格顶点数目过少,自由度过大,就可能导致重构图像与原图像在某些区域存在较大的重构误差,因此本发明通过对误差较大的区域进行自适应细分来控制图像的重构误差,使得用户可以得到指定误差的重构图像。In the previous step, the control mesh is obtained by fitting the loop subdivision surface, so that the corresponding subdivision surface is as close to the original image as possible. However, the number of vertices of the control grid depends on the simplification of the grid. If the simplification is excessive, the number of vertices of the control grid is too small and the freedom is too large, which may lead to large reconstruction of the reconstructed image and the original image in some areas. Therefore, the present invention controls the reconstruction error of the image by adaptively subdividing the area with large error, so that the user can obtain the reconstructed image with the specified error.
对于重构误差的计算,首先根据带尖锐特征的Loop细分规则和极限规则估计控制网格的极限曲面,计算出极限曲面上每个像素点的颜色值,即光栅化矢量表示。然后根据每个像素点所在的基网格面片,计算基网格每个面片的重构误差ef。最后计算整个重构图像的误差e。通过以上分析,本发明的误差可控的控制网格的求取的流程如下:For the calculation of the reconstruction error, the limit surface of the control grid is first estimated according to the Loop subdivision rule with sharp features and the limit rule, and the color value of each pixel on the limit surface is calculated, that is, the rasterized vector representation. Then, according to the base grid patch where each pixel point is located, the reconstruction error ef of each patch of the base grid is calculated. Finally, the error e of the entire reconstructed image is calculated. Through the above analysis, the process of obtaining the control grid with controllable error of the present invention is as follows:
①备份基网格MB,使用Loop曲面拟合方法计算控制网格MC;① Backup the base mesh M B , and use the Loop surface fitting method to calculate the control mesh M C ;
②根据细Loop分规则和极限规则估计控制网格MC的极限曲面MS;② Estimating the limit surface M S of the control grid M C according to the fine loop division rule and the limit rule;
③对于原光栅图像每个像素点的颜色值I(i),根据重心坐标计算出极限曲面MS上对应像素点的颜色值I′(i),计算像素点误差ei,并找到该像素点对应的基网格面片。然后计算基网格MB每个面片内所有像素点的平均误差ef,最后计算整个图像的平均重构误差e;③ For the color value I(i) of each pixel point of the original raster image, calculate the color value I′(i) of the corresponding pixel point on the limit surface MS according to the barycentric coordinates, calculate the pixel point error e i , and find the pixel Point to the corresponding base mesh patch. Then calculate the average error ef of all pixels in each patch of the base grid MB , and finally calculate the average reconstruction error e of the entire image;
④如果平均重构误差e小于用户指定的平均误差阈值ε,则终止算法,输出控制网格MC;否则找出基网格中MB前k个最大平均误差的面片集合,并标记这些面片为需要进行自适应细分;其中k≥1由用户指定,一般来说,k越大,平均误差下降越快。④If the average reconstruction error e is less than the average error threshold ε specified by the user, terminate the algorithm and output the control grid M C ; otherwise, find out the top k largest average error patch sets in the base grid M B , and mark these The patch needs to be adaptively subdivided; where k ≥ 1 is specified by the user, in general, the larger the k, the faster the average error decreases.
⑤对被标记的基网格面片进行自适应细化求得新的基网格MB,然后再转到步骤①,继续整个过程,直到得到指定误差的重构图像。⑤ Perform adaptive refinement on the marked base mesh to obtain a new base mesh MB , then go to
4.3)自适应细分4.3) Adaptive subdivision
自适应细分允许只对感兴趣的区域进行细分。在误差控制中,我们需要对被标记为不满足误差要求的面片进行自适应细分来局部增加控制顶点的数目,从而减少误差。为了避免新网格产生裂缝,我们必须对被标记的面片和其邻面都进行细分。对于被标记的网格面片,我们对其进行1-4细分,对于没被标记的面片,我们根据其邻面被标记的情况来进行细分:①如果该面片具有0个被标记的邻面,则不对其进行细分;②如果该面片具有1个被标记的邻面,则对其进行1-2细分;③如果该面片具有2个被标记的邻面,则对其进行1-3细分;④如果该面片具有3个被标记的邻面,则对其进行1-4细分。我们对基网格的所有面片用上述细分模式进行细分后,就完成一次自适应细分,形成新的基网格。Adaptive subdivision allows subdividing only the area of interest. In error control, we need to locally increase the number of control vertices by adaptively subdividing the patches marked as not meeting the error requirements, thereby reducing the error. To avoid cracks in the new mesh, we must subdivide both the marked patch and its neighbors. For the marked mesh patch, we subdivide it 1-4. For the unmarked patch, we subdivide it according to the situation of its adjacent faces being marked: ① If the patch has 0 If the adjacent face is marked, it will not be subdivided; ② If the patch has 1 marked adjacent face, it will be subdivided by 1-2; ③ If the patch has 2 marked adjacent faces, Then subdivide it 1-3; ④ If the patch has 3 marked adjacent faces, subdivide it 1-4. After we subdivide all the patches of the base mesh with the above-mentioned subdivision mode, an adaptive subdivision is completed to form a new base mesh.
5)光栅化矢量表示5) Rasterized vector representation
由于目前的显示设备大多数只支持光栅图像的显示,为了在这些显示设备中显示前面步骤得到的矢量表示我们需要渲染控制网格MC面片和它们相关的颜色信息到一个离散的光栅图像,也将该过程称为矢量表示光栅化。Since most of the current display devices only support the display of raster images, in order to display the vector representation obtained in the previous steps in these display devices We need to render the control mesh MC patches and their associated color information into a discrete raster image, a process also known as vector representation rasterization.
矢量表示是基于细分曲面,所以要先求得对应的细分曲面,再将其离散化成光栅图像。本发明的光栅化流程为:The vector representation is based on subdivision surfaces, so the corresponding subdivision surfaces must be obtained first, and then discretized into raster images. The rasterization process of the present invention is:
①根据带尖锐特征的Loop细分规则对控制网格MC做r次细分得一个细化的网格Mr,r=2,3…;①According to the loop subdivision rule with sharp features, subdivide the control grid M C for r times to obtain a refined grid M r , r=2,3...;
②根据带尖锐特征的Loop极限规则将Mr的顶点都移到对应的极限位置,从而得到逼近的分段细分曲面MS;② Move all the vertices of Mr to the corresponding limit positions according to the Loop limit rule with sharp features, so as to obtain the approximate segmented subdivision surface MS;
③由于MS是个分段线性曲面,曲面上的任一点颜色值都可以用该点所在三角面片的三个顶点颜色值进行线性表示。本发明使用重心坐标来计算三个顶点的权重。对于整个极限曲面网格MS,渲染流程:循环遍历MS的每个面片;对于每个三角面片,找出这个面片的包围盒;对于包围盒里面的每个整数像素点,判断该点是否属于该三角面片,如果是,求出它的重心坐标;最后根据重心坐标算该像素点的颜色值。在遍历网格全部三角面之后,即可以将对应的光栅图像素点的颜色全部填满,从而实现光栅图像的生成。③ Since MS is a piecewise linear surface, the color value of any point on the surface can be linearly represented by the color values of the three vertices of the triangular patch where the point is located. The present invention uses the barycentric coordinates to calculate the weights of the three vertices. For the entire limit surface mesh MS , the rendering process: loop through each patch of MS; for each triangular patch, find the bounding box of the patch; for each integer pixel in the bounding box, judge Whether the point belongs to the triangle patch, if so, find its barycentric coordinates; finally calculate the color value of the pixel point according to the barycentric coordinates. After traversing all the triangular surfaces of the grid, the colors of the corresponding raster image pixels can be filled, thereby realizing the generation of the raster image.
本发明与现有技术相比,具有如下优点与有益效果:Compared with the prior art, the present invention has the following advantages and beneficial effects:
1.本发明提出采用等值线追踪算法得到初始特征线段其中一侧的线段,然后和初始特征线形成双特征线,进而使用双特征线来建模图像特征两侧颜色的不连续,可以较好地捕捉到两侧的颜色值。1. The present invention proposes to use the contour tracking algorithm to obtain the line segment on one side of the initial feature line segment, then form a double feature line with the initial feature line, and then use the double feature line to model the discontinuity of the colors on both sides of the image feature, which can be compared. Nicely captures the color values on both sides.
2.针对图像网格的特点,本发明改进了QEM简化算法的代价的计算方法,对简化后的网格进行拓扑和几何上的优化,得到更能反映图像特征的基网格,且网格质量比较好。2. According to the characteristics of the image grid, the present invention improves the calculation method of the cost of the QEM simplification algorithm, and optimizes the topology and geometry of the simplified grid to obtain a base grid that can better reflect the image features. The quality is better.
3.对于矢量表示的初始重构结果的误差不能满足用户需求,本发明可以衡量出矢量化的重构图像与原图像误差,通过对基网格进行自适应细分以达到一定范围内的指定误差,做到误差可控,具有实际应用价值。3. For the error of the initial reconstruction result represented by the vector can not meet the needs of the user, the present invention can measure the error between the vectorized reconstructed image and the original image, and achieve the specified range within a certain range by adaptively subdividing the base grid. The error is controllable and has practical application value.
附图说明Description of drawings
图1为本发明的整个方法流程图。FIG. 1 is a flow chart of the entire method of the present invention.
图2为本发明的初始网格构造示意图。FIG. 2 is a schematic diagram of the initial grid structure of the present invention.
图3为本发明的等值线追踪示意图。FIG. 3 is a schematic diagram of contour tracing of the present invention.
图4为本发明的网格简化流程图。FIG. 4 is a simplified flow chart of the grid of the present invention.
图5为本发明的误差可控的Loop细分曲面拟合流程图。FIG. 5 is a flowchart of the loop subdivision surface fitting with controllable error according to the present invention.
图6为本发明的自适应细分模式示意图。FIG. 6 is a schematic diagram of an adaptive subdivision mode of the present invention.
图7为本发明的一个实例Lena的矢量化过程及结果:(a)原始图像;(b)图像特征;(c)双特征线;(d)-(f)分别表示1%、2%、3%顶点数的控制网格;(g)-(i)分别表示(d)-(f)的重构结果。Fig. 7 is the vectorization process and result of Lena, an example of the present invention: (a) original image; (b) image features; (c) double feature lines; (d)-(f) represent 1%, 2%, Control mesh with 3% vertex count; (g)-(i) represent the reconstruction results of (d)-(f), respectively.
图8为本发明的更多的实例的矢量化结果展示图,从左到右分别表示原始图像、2%顶点数的控制网格、重构图像。FIG. 8 is a diagram showing the vectorization results of more examples of the present invention, from left to right, the original image, the control mesh with 2% vertex count, and the reconstructed image are respectively shown.
图9为本发明的两个实例在不同的重构误差下的重构结果:第一行分别为原图像和2%顶点比例的基网格,第二、三、四行分别为不同的重构误差下得到重构图像和重构误差。Figure 9 shows the reconstruction results of two examples of the present invention under different reconstruction errors: the first row is the original image and the base mesh with a vertex ratio of 2%, and the second, third, and fourth rows are different reconstructions. The reconstructed image and reconstruction error are obtained under the reconstruction error.
图10为本发明的图9(a)例子的误差控制过程平均误差变化趋势图。Fig. 10 is a change trend diagram of the average error in the error control process of the example of Fig. 9(a) of the present invention.
图11为本发明的图9(b)例子的误差控制过程平均误差变化趋势图。Fig. 11 is a change trend diagram of the average error in the error control process of the example of Fig. 9(b) of the present invention.
具体实施方式Detailed ways
下面结合具体实施例对本发明作进一步说明。The present invention will be further described below in conjunction with specific embodiments.
如图1所示,对于一张给定的要进行矢量化的光栅图像I,本实施例所述的细分曲面的图像矢量化方法的步骤如下:As shown in FIG. 1, for a given raster image I to be vectorized, the steps of the image vectorization method for subdivision surfaces described in this embodiment are as follows:
1)检测图像边缘特征,得到一个像素宽的特征线段1) Detect the edge features of the image and get a pixel-wide feature line segment
1)检测图像边缘特征1) Detect image edge features
图像边缘是最显著的图像特征,为了在构造保持图像特征的基网格,使用图像边缘线段检测方法来提取图像的一个像素宽的特征线,其步骤为:The image edge is the most significant image feature. In order to construct the base grid that maintains the image features, the image edge line segment detection method is used to extract the one-pixel-wide feature line of the image. The steps are:
①高斯滤波:用高斯核卷积图像来抑制图像噪声和平滑图像;①Gaussian filtering: Convolve the image with a Gaussian kernel to suppress image noise and smooth the image;
②计算梯度幅值和边缘方向图:首先使用梯度算子分别计算出像素点的水平和垂直梯度,然后算出图像梯度幅值图,与此同时,比较像素水平和垂直梯度的大小,确定该像素点的边缘方向,如果水平梯度较大,则认为通过该像素是个垂直方向边缘,反之亦然;②Calculate the gradient magnitude and edge direction map: First, use the gradient operator to calculate the horizontal and vertical gradients of the pixel respectively, and then calculate the image gradient magnitude map. At the same time, compare the size of the horizontal and vertical gradients of the pixel to determine the pixel. The edge direction of the point, if the horizontal gradient is large, it is considered to be a vertical edge through the pixel, and vice versa;
③提取锚点:锚点可以被认为是边缘结束的地方,即在水平和垂直方向特征变化剧烈的像素点,这里选择局部梯度极值作为锚点,通过比较像素点与其相邻像素点的梯度值来判断该像素点是否是锚点,对于一个水平方向的像素点,将其与左右相邻的像素点比较,如果该像素点的梯度值比左右相邻像素梯度值大指定阈值,则认为该像素点为锚点;③Extract anchor points: An anchor point can be considered as the end of the edge, that is, a pixel point with drastic feature changes in the horizontal and vertical directions. Here, the local gradient extreme value is selected as the anchor point, and the gradient between the pixel point and its adjacent pixels is compared. value to determine whether the pixel is an anchor point. For a horizontal pixel, compare it with the left and right adjacent pixels. If the gradient value of the pixel is greater than the gradient value of the left and right adjacent pixels by a specified threshold, it is considered that The pixel is the anchor point;
④连接锚点形成线段:根据梯度幅值和边缘方向图来连接相邻锚点,每次从还未被检测过的锚点开始,观察穿过该锚点的边缘方向,如果是水平边缘,通过向左和向右行进开始连接过程,如果垂直边缘通过锚点,通过向上和向下行进进行连接过程,在移动期间,仅考虑三个直接邻居像素,并且选择具有最大梯度值的那个邻居像素,当遇到梯度幅值为0的像素点或遇到之前已经检测过的边缘像素时,该次处理过程停止。④ Connect anchor points to form line segments: Connect adjacent anchor points according to the gradient amplitude and edge direction map, starting from the anchor point that has not been detected each time, observe the edge direction passing through the anchor point, if it is a horizontal edge, The connection process is started by traveling left and right, if the vertical edge passes the anchor point, the connection process is performed by traveling up and down, during the movement, only three immediate neighbor pixels are considered, and the one with the largest gradient value is selected , when encountering a pixel with a gradient magnitude of 0 or encountering an edge pixel that has been detected before, the processing stops.
2)构造基于图像特征的初始网格,并在网格中标记图像特征2) Construct an initial grid based on image features, and label image features in the grid
在2D图像平面上建立像素分辨率的初始三角网格M。首先建立初始网格顶点,图像中的每个像素点对应网格中的一个顶点,并在顶点的属性中记录像素点的颜色值;然后以行和列的方式连接网格顶点形成矩形网格,根据图像特征线将网格中的每个矩形网格划分成两个三角网格,如图2的(a)所示。Build an initial triangular mesh M of pixel resolution on the 2D image plane. First establish the initial grid vertex, each pixel in the image corresponds to a vertex in the grid, and record the color value of the pixel in the vertex attribute; then connect the grid vertices in rows and columns to form a rectangular grid , each rectangular grid in the grid is divided into two triangular grids according to the image feature lines, as shown in (a) of Figure 2.
图像颜色不连续性与至少两个具有非常不同颜色强度的相邻像素相关联,单独的图像边缘线不足以表示图像颜色的不连续性。因此本发明提出使用双特征线来表示图像颜色的不连续。该策略首先使用等值线追踪算法找出图像特征线两侧的距离一像素的平行线段,如图2的(b)所示。然后通过比较两侧的图像梯度选择平均梯度大的线段作为另一特征线,并对受影响的三角网格进行重新三角化,如图2的(c)所示。Image color discontinuities are associated with at least two adjacent pixels with very different color intensities, and image edge lines alone are not sufficient to represent image color discontinuities. Therefore, the present invention proposes to use a double characteristic line to represent the discontinuity of the color of the image. The strategy first uses the contour tracing algorithm to find parallel line segments with a distance of one pixel on both sides of the image feature line, as shown in (b) of Figure 2. Then, by comparing the image gradients on both sides, a line segment with a large average gradient is selected as another feature line, and the affected triangular mesh is re-triangulated, as shown in (c) of Figure 2.
寻找图像特征线的等值线,首先在网格上对图像的特征边和特征顶点进行标记。对于每条特征线,将特征线上的顶点标为+,非特征线上的顶点标为-。如果一条边的两个顶点标号相异,则等值线会穿过这条边。我们使用半边结构来进行三角网格的等值线追踪,该过程与二维的行进三角形算法类似,如图3所示,对于每条特征线一侧的一像素等值线追踪的过程描述如下:To find the contours of the image feature lines, first mark the feature edges and feature vertices of the image on the grid. For each breakline, label the vertices on the breakline as + and the vertices on the non-breakline as -. If the two vertex labels of an edge are different, the contour will pass through the edge. We use the half-edge structure to trace the contour of the triangular mesh. The process is similar to the two-dimensional marching triangle algorithm, as shown in Figure 3. The process of contour tracing for one pixel on one side of each feature line is described as follows :
①首先根据特征线的前两个顶点找到其中一侧的第一个等值点,将其添加进等值线段中,如图3的v1顶点,进而找到对应的第一条半边he1,然后判断当前的半边是否属于第一个面,根据第二条半边与特征线第一个点和第二个点连线的夹角判断当前半边的方向是否是正确的,进而确定第一个搜索三角形f1;①First, find the first equivalent point on one side according to the first two vertices of the characteristic line, and add it to the contour segment, as shown in the v 1 vertex in Figure 3, and then find the corresponding first half-edge he 1 , Then judge whether the current half edge belongs to the first face, and judge whether the direction of the current half edge is correct according to the angle between the second half edge and the line connecting the first point and the second point of the feature line, and then determine the first search triangle f 1 ;
②在三角形的相关边上寻找第二条存在等值点的半边,即边的两个顶点标号相异。如图3的半边he2,从而找到第二个等值点,如果该等值点和前一个等值点一样,则不添加进等值线段中,如果不一样,则添加。② Find the second half-edge with an equivalent point on the relevant edge of the triangle, that is, the two vertices of the edge have different labels. As shown in the half-side he 2 of Figure 3, the second iso-point is found. If the iso-point is the same as the previous iso-point, it will not be added to the iso-segment. If it is different, it will be added.
③根据半边结构和当前半边he2找到下一个搜索三角形的第一条存在等值点的半边he3,进而确定下一个搜索三角形f2;③ According to the half-side structure and the current half-side he 2 , find the first half-side he 3 of the next search triangle with an equivalent point, and then determine the next search triangle f 2 ;
④递归执行②和③,直至搜索三角形中不包含等值点。④ Execute ② and ③ recursively until no equivalent points are included in the search triangle.
接下来,对初始网格的边和顶点的类型进行标记,从而在后续的网格简化、细分等操作中对不同的类型进行不同的处理以保持重要的图像特征。本发明将网格的边分为三种类型:边界边、平滑边、折痕边,将网格的顶点分为四种类型:边界点、平滑点、折痕点、角点。将图像的双特征线标记为折痕边,将图像矩阵边界的边标记为边界边,其他边为平滑边。对于网格顶点,如果顶点只与平滑边缘连接,则该顶点标记为平滑点;折痕顶点与两条邻接的折痕边连接;边界点与两条邻接的边界边连接;图像特征线端点、特征线交叉点标记为角点。为了固定矩形图像边界,四个角被标记为角点。Next, the types of edges and vertices of the initial mesh are marked, so that different types are processed differently in subsequent operations such as mesh simplification, subdivision, etc. to maintain important image features. The invention divides the edges of the mesh into three types: boundary edge, smooth edge and crease edge, and divides the vertices of the mesh into four types: boundary point, smooth point, crease point and corner point. Label the double feature lines of the image as crease edges, the edges of the image matrix boundary as boundary edges, and the other edges as smooth edges. For mesh vertices, if the vertex is only connected with smooth edges, the vertex is marked as a smooth point; a crease vertex is connected with two adjacent crease edges; a boundary point is connected with two adjacent boundary edges; image feature line endpoints, Breakpoint intersections are marked as corners. To fix the rectangular image boundary, the four corners are marked as corner points.
3)简化初始网格,构造保持图像特征的基网格3) Simplify the initial grid and construct a base grid that preserves image features
主要采用QEM简化算法来简化图像初始网格,得到基网格MB。将网格的颜色属性看成高度场来计算二次误差代价,并且在简化过程中使用细分曲线来拟合图像特征线段来保持图像特征。The QEM simplification algorithm is mainly used to simplify the initial grid of the image to obtain the base grid MB . The quadratic error cost is calculated by considering the color properties of the grid as a height field, and the image features are preserved using subdivision curves to fit image feature line segments during the simplification process.
在上一步骤中,我们根据图像特征对网格的顶点和边做了分类。为了保持图像的形状和特征,对于不同的特征采取不同的处理方式:①角点不允许被折叠;②边界点只能与其邻接的同边界的两个边界点折叠;③折痕点只能与其邻接的同折痕边的两个折痕点折叠;④平滑点可以折叠到特征点。In the previous step, we classified the vertices and edges of the mesh based on image features. In order to maintain the shape and characteristics of the image, different processing methods are adopted for different features: ① the corner points are not allowed to be folded; ② the boundary point can only be folded with two adjacent boundary points of the same boundary; ③ the crease point can only be folded with the same boundary The two adjacent crease points on the same crease edge are folded; ④The smooth point can be folded to the feature point.
此外,为了得到一个高质量的保持图像特征的基网格,改进了QEM算法的边折叠代价。在边折叠代价中加入了特征边形变代价Qfeature、三角形正则性代价Qre、面积代价Qarea,并赋予它们相应的权重。用Qqem表示QEM代价,则可以把边折叠的总折叠代价表示为:Furthermore, in order to obtain a high-quality base mesh that preserves image features, the edge-folding cost of the QEM algorithm is improved. The characteristic edge deformation cost Q feature , the triangle regularity cost Q re , and the area cost Q area are added to the edge folding cost, and they are given corresponding weights. Using Q qem to represent the QEM cost, the edges can be folded The total folding cost of is expressed as:
Cost(v1,v2)=αQqem(v1,v2)+βQfeature(v1,v2)+γQre(v1,v2)+δQarea(v1,v2) (1)Cost(v 1 ,v 2 )=αQ qem (v 1 ,v 2 )+βQ feature (v 1 ,v 2 )+γQ re (v 1 ,v 2 )+δQ area (v 1 ,v 2 )(1 )
其中,权重α,β,γ,δ由用户指定,边折叠顺序按照Cost(v1,v2)从小到大进行。Among them, the weights α, β, γ, and δ are specified by the user, and the order of edge folding is carried out according to Cost(v 1 , v 2 ) from small to large.
需要说明的是,为了保证简化后二维网格的质量,除了在计算QEM代价时,将网格M的颜色属性看成高度场,在计算其他代价时,考虑的都只是二维图像网格,不考虑颜色属性。在实验中权重α,β,γ,δ分别取1、10、3、10。计算出各项的代价:It should be noted that, in order to ensure the quality of the simplified two-dimensional grid, except when calculating the QEM cost, the color attribute of the grid M is regarded as a height field, and when calculating other costs, only the two-dimensional image grid is considered. , regardless of color properties. In the experiment, the weights α, β, γ, and δ are taken as 1, 10, 3, and 10, respectively. Calculate the cost of each item:
QEM代价Qqem:将网格M的颜色属性看成高度场,分别用RGB的值作为高度,则每条边可计算出三个代价,将其和作为该边的二次误差代价Qqem。QEM cost Q qem : The color attribute of the grid M is regarded as a height field, and the RGB value is used as the height, then three costs can be calculated for each edge, and the sum is used as the quadratic error cost Q qem of the edge.
特征边形变代价Qfeature:定义Qfeature为折叠前的特征点到其邻接的两个特征点连线的距离,用来衡量特征边折叠结果与折叠点的偏离程度,Qfeature值越小,表明偏离越小。如果折叠的边是非特征边,则Qfeature值为0。Feature edge deformation cost Q feature : Define Q feature as the distance between the feature point before folding and the line connecting its two adjacent feature points, which is used to measure the degree of deviation between the feature edge folding result and the folding point. The smaller the deviation. If the collapsed edge is a non-feature edge, the Q feature value is 0.
三角形正则性代价Qre:在边折叠代价中加入三角形正则性代价是为了减少狭长的三角面片的出现。三角形的正则性被用来表示其接近正三角形的程度,可以用R(t)=cos(∠A)+cos(∠B)+cos(∠C)来度量三角形t=ΔABC的正则性。令Re(t)=3-2R(t),则0≤Re(t)≤1,Re(t)的值越小,表明该三角形的正则性越高。则可以定义三角面片集合T的正则性为:Triangle regularity cost Q re : The triangle regularity cost is added to the edge folding cost in order to reduce the appearance of long and narrow triangle patches. The regularity of a triangle is used to indicate how close it is to an equilateral triangle. R(t)=cos(∠A)+cos(∠B)+cos(∠C) can be used to measure the regularity of triangle t=ΔABC. Let Re(t)=3-2R(t), then 0≤Re(t)≤1, the smaller the value of Re(t), the higher the regularity of the triangle. Then the regularity of the triangular patch set T can be defined as:
Re(T)=max{Re(t)|t∈T} (2)Re(T)=max{Re(t)|t∈T} (2)
把Qre定义为边折叠前后,相关三角面片的正则性增量。则边折叠的正则性代价定义为:Q re is defined as the regularity increment of related triangular patches before and after edge folding. then the side is folded The regularity cost of is defined as:
其中,表示顶点的邻接三角面片。in, represents a vertex of adjacent triangles.
面积代价Qarea:三角形正则性代价Qre反映了三角面片的形状,没有反映面片大小。如果Qre的权重γ比较大时,可能导致网格面片的大小相差很大。因此,在总代价中加入面积代价来约束面片的面积。把面积代价Qarea定义为边折叠后新顶点所有邻接面的面积总和。则边折叠的面积代价定义为:Area cost Q area : The triangle regularity cost Q re reflects the shape of the triangular patch, not the size of the patch. If the weight γ of Q re is relatively large, the size of the grid patches may vary greatly. Therefore, an area cost is added to the total cost to constrain the area of the patch. The area cost Q area is defined as the sum of the areas of all adjacent faces of the new vertex after the edge is collapsed. then the side is folded The area cost of is defined as:
其中,area(t)表示三角形t的面积;Among them, area(t) represents the area of triangle t;
根据以上分析,如图4所示,网格简化算法的主要步骤为:According to the above analysis, as shown in Figure 4, the main steps of the grid simplification algorithm are:
①设置边折叠代价公式(1)中的各项权值;①Set the weights in the edge folding cost formula (1);
②将网格M的颜色属性看成高度场,计算网格所有边的QEM代价Qqem;② Consider the color attribute of the grid M as a height field, and calculate the QEM cost Q qem of all edges of the grid;
③计算所有可折叠边的折叠代价,根据折叠代价将其放入最小堆中。根据公式(1)计算出每条边对应的两条半边的折叠代价,则边的折叠代价取两个半边代价的小值,并记录折叠方向;③ Calculate the folding cost of all foldable edges and put them into the minimum heap according to the folding cost. Calculate the folding cost of the two half-edges corresponding to each edge according to formula (1).
④从堆中取出最小折叠代价的边,首先判断其折叠后相关面是否会反生翻转,若会,则给该边的代价加一个惩罚值,更新其在堆中的位置;若不会反生翻转,则判断该边是否是特征边,若是特征边,拟合调整特征点的位置并判断其折叠后拟合误差是否符合要求,若不符合,则不折叠该边,将其从堆中删除;否则就完成该边的折叠操作,重新计算相关边的折叠代价并更新它们在堆中的位置。④ Take the edge with the minimum folding cost from the heap, and first determine whether the relevant surface will be reversed after it is folded. If so, add a penalty value to the cost of the edge, and update its position in the heap; if it does not reverse. If it is flipped, judge whether the edge is a feature edge. If it is a feature edge, fit and adjust the position of the feature point and judge whether the fitting error after folding meets the requirements. If not, the edge is not folded, and it is removed from the stack. Delete; otherwise, complete the collapsing operation for the edge, recalculate the collapsing cost of the relevant edge and update their position in the heap.
⑤若达到简化的要求或最小堆为空,则转到⑥,否则转到④。⑤ If the simplified requirements are met or the minimum heap is empty, go to ⑥, otherwise go to ④.
⑥删除网格中的独立顶点,更新网格,输出基网格。⑥ Delete independent vertices in the mesh, update the mesh, and output the base mesh.
虽然在网格简化过程中考虑了面片正则性、面积等因素,但是仍不能保证能得到一个高质量基网格。因此本发明使用最简单的Laplacian算子对网格进行几何优化:Although factors such as patch regularity and area are considered in the mesh simplification process, it is still not guaranteed that a high-quality base mesh can be obtained. Therefore, the present invention uses the simplest Laplacian operator to optimize the mesh geometry:
网格中顶点的新位置由vnew=v+λΔv迭代式给出,其中λ取值为0.3。The new positions of the vertices in the mesh are given iteratively by vnew = v+ λΔv , where λ takes the value 0.3.
为了保持图像的特征,对网格特征顶点进行特殊处理。首先,角点不进行移动;对于边界顶点和特征点v,设(va,v)和(v,vb)为v所在的两条特征边,则v只根据va和vb的位置进行调整,即Laplacian算子定义为:In order to preserve the characteristics of the image, the mesh feature vertices are treated specially. First, the corners do not move; for boundary vertices and feature points v, let (v a , v ) and (v, v b ) be the two characteristic edges where v is located, then v is only based on the positions of v a and v b Adjusted, that is, the Laplacian operator is defined as:
需要说明的是,网格优化可以在网格简化的过程中进行,也可以在网格简化结束后进行。如果网格优化会造成面片翻转,则暂时不进行优化。It should be noted that the mesh optimization can be carried out during the mesh simplification process, or can be carried out after the mesh simplification is completed. If the mesh optimization will cause the patch to flip, do not optimize it for now.
4)误差可控的Loop细分曲面拟合求得控制网格4) Control mesh obtained by loop subdivision surface fitting with controllable error
经过网格的简化和优化得到反映图像特征的基网格后,本发明提出带误差控制的Loop细分曲面拟合来对图像颜色进行拟合,在计算控制网格的过程中进行误差控制,用户可以通过指定重构图像的误差来获得满足需求的矢量图像。该过程主要包括三个部分:控制网格的计算、误差控制以及自适应细分。After simplification and optimization of the grid to obtain the base grid reflecting the image features, the present invention proposes the loop subdivision surface fitting with error control to fit the image color, and performs error control in the process of calculating the control grid, The user can obtain a vector image that meets the needs by specifying the error of the reconstructed image. The process mainly includes three parts: calculation of control grid, error control and adaptive subdivision.
4.1)控制网格的计算4.1) Calculation of control grid
为了增加拟合目标的数据量,我们首先对基网格MB进行一次1-4细分得到网格然后使用网格对原图像进行采样得到MR,将MR作为我们拟合的目标。像素点的颜色值在图像特征区域有着显著的变化,为了采样到准确的颜色值,我们对不同的网格特征采用不同的采样方式得到顶点的颜色值:对于折痕顶点,它的目标颜色为它所在的图像特征线上和它位置最接近的像素点的颜色值;对于角点,它在简化过程和细分过程中的位置都没有移动,所以它的目标颜色为顶点坐标确定的图像像素点的颜色值;对于平滑顶点,其颜色由其周围的像素点进行双线性插值得到。In order to increase the amount of data to fit the target, we first perform a 1-4 subdivision on the base grid MB to obtain a grid then use grid Sampling the original image to get MR , and take MR as our fitting target. The color value of the pixel has a significant change in the image feature area. In order to sample the accurate color value, we use different sampling methods for different mesh features to obtain the color value of the vertex: for the crease vertex, its target color is The color value of the pixel point closest to its position on the image feature line where it is located; for corner points, its position has not moved during the simplification process and the subdivision process, so its target color is the image pixel determined by the vertex coordinates The color value of the point; for smooth vertices, the color is bilinearly interpolated from the surrounding pixels.
在网格简化过程中已经拟合了网格的特征顶点位置,为了计算方便,这里只拟合网格顶点的颜色。因此所要计算的控制网格MC和基网格MB具有相同的拓扑结构。因此,对控制网格MC进行一次Loop细分后获得的网格和MR具有相同的拓扑关系。根据Loop极限模版求网格的极限得到细分极限曲面MS,拟合目标就是:In the process of mesh simplification, the feature vertex positions of the mesh have been fitted. For the convenience of calculation, only the colors of the mesh vertices are fitted here. Therefore, the control mesh M C to be calculated and the base mesh MB have the same topology. Therefore, the mesh obtained after a loop subdivision of the control mesh M C and MR have the same topological relationship. Grid based on Loop limit template The limit of the subdivision limit surface M S is obtained, and the fitting objective is:
MR=MS (7)M R = M S (7)
设基网格MB和目标网格MC的顶点数分别为n和m,分别用表示网格MC、MR、MS的顶点颜色构成的向量。则根据带尖锐特征的Loop细分模版和极限模版,存在有细分矩阵Sm×n和极限矩阵Lm×m使得:: 所以可以将Loop细分拟合方程(7)表示为:Let the number of vertices of the base mesh MB and the target mesh M C be n and m, respectively. Represents meshes M C , MR , A vector of vertex colors for MS. Then according to the loop subdivision template and limit template with sharp features, there are subdivision matrix S m×n and limit matrix L m×m such that: So the Loop subdivision fitting equation (7) can be expressed as:
令Zm×n=Lm×mSm×n,方程组(8)可以变换为:Let Z m×n =L m×m S m×n , the equation system (8) can be transformed into:
通过求解线性方程组(9)就可以得到控制网格MC。因为这里拟合的是网格顶点的颜色,所以和的大小分别为n×3和m×3,RGB三种颜色可以分开求解。The control grid M C can be obtained by solving the system of linear equations (9). Because the color of the mesh vertices is fitted here, so and The sizes are n×3 and m×3, respectively, and the three colors of RGB can be solved separately.
4.2)误差控制4.2) Error control
将每个像素点的重构误差定义为重构图像与原图像对应像素点颜色值的欧式距离,而将整个图像的重构误差e定义为所有像素点重构误差的均值,每个基网格面片的重构误差ef定义为该面片光栅化后所对应的所有像素点重构误差的均值。The reconstruction error of each pixel is defined as the Euclidean distance between the reconstructed image and the color value of the corresponding pixel of the original image, and the reconstruction error e of the entire image is defined as the mean of the reconstruction errors of all pixels. The reconstruction error ef of a grid patch is defined as the mean of reconstruction errors of all pixel points corresponding to the patch after rasterization.
在上一步骤中,通过Loop细分曲面拟合求得控制网格,使其对应的细分曲面尽可能接近原图像。但是控制网格的顶点数目依赖于网格简化,如果简化过度,使得控制网格顶点数目过少,自由度过大,就可能导致重构图像与原图像在某些区域存在较大的重构误差,因此本发明通过对误差较大的区域进行自适应细分来控制图像的重构误差,使得用户可以得到指定误差的重构图像。In the previous step, the control mesh is obtained by fitting the loop subdivision surface, so that the corresponding subdivision surface is as close to the original image as possible. However, the number of vertices of the control grid depends on the simplification of the grid. If the simplification is excessive, the number of vertices of the control grid is too small and the freedom is too large, which may lead to large reconstruction of the reconstructed image and the original image in some areas. Therefore, the present invention controls the reconstruction error of the image by adaptively subdividing the area with large error, so that the user can obtain the reconstructed image with the specified error.
对于重构误差的计算,首先根据带尖锐特征的Loop细分规则和极限规则估计控制网格的极限曲面,计算出极限曲面上每个像素点的颜色值,即光栅化矢量表示。然后根据每个像素点所在的基网格面片,计算基网格每个面片的重构误差ef。最后计算整个重构图像的误差e。通过以上分析,如图5所示,本发明的误差可控的控制网格的求取的主要流程如下:For the calculation of the reconstruction error, the limit surface of the control grid is first estimated according to the Loop subdivision rule with sharp features and the limit rule, and the color value of each pixel on the limit surface is calculated, that is, the rasterized vector representation. Then, according to the base grid patch where each pixel point is located, the reconstruction error ef of each patch of the base grid is calculated. Finally, the error e of the entire reconstructed image is calculated. Through the above analysis, as shown in FIG. 5 , the main process of obtaining the control grid with controllable error of the present invention is as follows:
①备份基网格MB,使用Loop曲面拟合方法计算控制网格MC;① Backup the base mesh M B , and use the Loop surface fitting method to calculate the control mesh M C ;
②根据细Loop分规则和极限规则估计控制网格MC的极限曲面MS;② Estimating the limit surface M S of the control grid M C according to the fine loop division rule and the limit rule;
③对于原光栅图像每个像素点的颜色值I(i),根据重心坐标计算出极限曲面MS上对应像素点的颜色值I′(i),计算像素点误差ei,并找到该像素点对应的基网格面片。然后计算基网格MB每个面片内所有像素点的平均误差ef,最后计算整个图像的平均重构误差e;③ For the color value I(i) of each pixel point of the original raster image, calculate the color value I′(i) of the corresponding pixel point on the limit surface MS according to the barycentric coordinates, calculate the pixel point error e i , and find the pixel Point to the corresponding base mesh patch. Then calculate the average error ef of all pixels in each patch of the base grid MB , and finally calculate the average reconstruction error e of the entire image;
④如果平均重构误差e小于用户指定的平均误差阈值ε,则终止算法,输出控制网格MC;否则找出基网格中MB前k个最大平均误差的面片集合,并标记这些面片为需要进行自适应细分;其中k≥1由用户指定,一般来说,k越大,平均误差下降越快。④If the average reconstruction error e is less than the average error threshold ε specified by the user, terminate the algorithm and output the control grid M C ; otherwise, find out the top k largest average error patch sets in the base grid M B , and mark these The patch needs to be adaptively subdivided; where k ≥ 1 is specified by the user, in general, the larger the k, the faster the average error decreases.
⑤对被标记的基网格面片进行自适应细化求得新的基网格MB,然后再转到步骤①,继续整个过程,直到得到指定误差的重构图像。⑤ Perform adaptive refinement on the marked base mesh to obtain a new base mesh MB , then go to
4.3)自适应细分4.3) Adaptive subdivision
自适应细分允许只对感兴趣的区域进行细分。在误差控制中,我们需要对被标记为不满足误差要求的面片进行自适应细分来局部增加控制顶点的数目,从而减少误差。为了避免新网格产生裂缝,我们必须对被标记的面片和其邻面都进行细分。对于被标记的网格面片,我们对其进行1-4细分,如图6中标记为1的面片所示。对于没被标记的面片,我们根据其邻面被标记的情况来进行细分:①如果该面片具有0个被标记的邻面,如图6中标记为5的面片所示,则不对其进行细分;②如果该面片具有1个被标记的邻面,如图6中标记为4的面片所示,则对其进行1-2细分;③如果该面片具有2个被标记的邻面,如图6中标记为3的面片所示,则对其进行1-3细分;④如果该面片具有3个被标记的邻面,如图6中标记为2的面片所示,则对其进行1-4细分。我们对基网格的所有面片用上述细分模式进行细分后,就完成一次自适应细分,形成新的基网格。Adaptive subdivision allows subdividing only the area of interest. In error control, we need to locally increase the number of control vertices by adaptively subdividing the patches marked as not meeting the error requirements, thereby reducing the error. To avoid cracks in the new mesh, we must subdivide both the marked patch and its neighbors. For the marked mesh patch, we subdivide it 1-4, as shown in the patch marked 1 in Figure 6. For the unmarked patch, we subdivide it according to the condition of its adjacent faces being marked: ① If the patch has 0 marked adjacent faces, as shown in the patch marked 5 in Figure 6, then do not subdivide it; ② if the patch has 1 adjacent face that is marked, as shown in the patch marked 4 in Figure 6, it is subdivided 1-2; ③ if the patch has 2 There are marked adjacent faces, as shown in the patch marked 3 in Figure 6, it is subdivided by 1-3; ④ If the patch has 3 marked adjacent faces, as shown in Figure 6, it is marked as 2, then subdivide it 1-4. After we subdivide all the patches of the base mesh with the above-mentioned subdivision mode, an adaptive subdivision is completed to form a new base mesh.
5)光栅化矢量表示5) Rasterized vector representation
由于目前的显示设备大多数只支持光栅图像的显示,为了在这些显示设备中显示前面步骤得到的矢量表示我们需要渲染控制网格MC面片和它们相关的颜色信息到一个离散的光栅图像,也将该过程称为矢量表示光栅化。Since most of the current display devices only support the display of raster images, in order to display the vector representation obtained in the previous steps in these display devices We need to render the control mesh MC patches and their associated color information into a discrete raster image, a process also known as vector representation rasterization.
我们先求得对应的细分曲面,再将其离散化成光栅图像。光栅化流程为:We first obtain the corresponding subdivision surface, and then discretize it into a raster image. The rasterization process is:
①根据带尖锐特征的Loop细分规则对控制网格MC做r次细分得一个细化的网格Mr,r=2,3…;①According to the loop subdivision rule with sharp features, subdivide the control grid M C for r times to obtain a refined grid M r , r=2,3...;
②根据带尖锐特征的Loop极限规则将Mr的顶点都移到对应的极限位置,从而得到逼近的分段细分曲面MS。② Move the vertices of Mr to the corresponding limit positions according to the Loop limit rule with sharp features, so as to obtain the approximate segmented subdivision surface MS.
③由于MS是个分段线性曲面,曲面上的任一点颜色值都可以用该点所在三角面片的三个顶点颜色值进行线性表示。本发明使用重心坐标来计算三个顶点的权重。对于整个极限曲面网格MS,渲染流程:循环遍历MS的每个面片;对于每个三角面片,找出这个面片的包围盒;对于包围盒里面的每个整数像素点,判断该点是否属于该三角面片,如果是,求出它的重心坐标;最后根据重心坐标算该像素点的颜色值。在遍历网格全部三角面之后,即可以将对应的光栅图像素点的颜色全部填满,从而实现光栅图像的生成。③ Since MS is a piecewise linear surface, the color value of any point on the surface can be linearly represented by the color values of the three vertices of the triangular patch where the point is located. The present invention uses the barycentric coordinates to calculate the weights of the three vertices. For the entire limit surface mesh MS , the rendering process: loop through each patch of MS; for each triangular patch, find the bounding box of the patch; for each integer pixel in the bounding box, judge Whether the point belongs to the triangle patch, if so, find its barycentric coordinates; finally calculate the color value of the pixel point according to the barycentric coordinates. After traversing all the triangular surfaces of the grid, the colors of the corresponding raster image pixels can be filled, thereby realizing the generation of the raster image.
综上所述,本发明方法对于给定的要进行矢量化的光栅图像,可以得到质量良好且保持原图像特征的矢量表示。图7为本发明的一个实例Lena的矢量化过程及结果:(a)为原始图像;(b)为检测出的图像特征;(c)为使用等值线追踪算法得到的双特征线;(d)-(f)分别表示1%、2%、3%顶点数的控制网格;(g)-(i)分别表示(d)-(f)的重构结果。图8为本发明的更多的实例的矢量化结果展示图,从左到右分别表示原始图像、2%顶点数的控制网格、重构图像。从图中可以本发明方法可以得到质量良好的矢量表示,且网格的顶点数目越多,得到的矢量表示越接近原图像。To sum up, for a given raster image to be vectorized, the method of the present invention can obtain a vector representation with good quality and maintaining the characteristics of the original image. 7 is the vectorization process and result of an example Lena of the present invention: (a) is the original image; (b) is the detected image feature; (c) is the double feature line obtained using the contour tracking algorithm; ( d)-(f) represent the control meshes with 1%, 2%, and 3% vertex counts, respectively; (g)-(i) represent the reconstruction results of (d)-(f), respectively. FIG. 8 is a diagram showing the vectorization results of more examples of the present invention, from left to right, the original image, the control mesh with 2% vertex count, and the reconstructed image are respectively shown. It can be seen from the figure that the method of the present invention can obtain a vector representation of good quality, and the more the number of vertices of the mesh, the closer the obtained vector representation is to the original image.
本发明方法对于矢量表示的初始重构结果误差不能满足用户需求的情况,可以衡量出矢量化的重构图像与原图像误差,通过对基网格进行自适应细分以达到一定范围内的指定误差,做到误差可控,具有实际应用价值。图9为本发明的两个实例在不同的重构误差下的重构结果:第一行分别为原图像和2%顶点比例的基网格,第二、三、四行分别为不同的重构误差下得到重构图像和重构误差。从图中可以看出,第二行的重构图像在图像的边缘存在较大的误差,通过本发明方法的迭代地自适应细分误差控制后,图像较大误差的区域得到了改善,从而得到满足平均误差需求的重构结果,能够很好地表示原图像。说明了对于同一简化比例的基网格,本发明方法能矢量化出满足一定范围内不同误差需求的结果。The method of the present invention can measure the error between the vectorized reconstructed image and the original image when the error of the initial reconstruction result represented by the vector cannot meet the needs of the user, and the base grid can be adaptively subdivided to achieve the specified range within a certain range. The error is controllable and has practical application value. Figure 9 shows the reconstruction results of two examples of the present invention under different reconstruction errors: the first row is the original image and the base mesh with a vertex ratio of 2%, and the second, third, and fourth rows are different reconstructions. The reconstructed image and reconstruction error are obtained under the reconstruction error. It can be seen from the figure that the reconstructed image of the second row has a large error at the edge of the image. After the iterative adaptive subdivision error control of the method of the present invention, the area with large error in the image is improved, so that A reconstruction result that meets the average error requirement is obtained, which can well represent the original image. It is illustrated that for the base grid of the same simplified scale, the method of the present invention can vectorize the results that meet different error requirements within a certain range.
本发明的误差控制算法具有收敛性。如果重构图像不满足误差需求,本发明方法每次迭代选择前k个平均误差最大的基网格面片进行自适应细分,从而增加最终控制网格上的顶点数目。理论上,随着控制网格上顶点数目的增加,重构误差会越来越小,最终收敛于某个小值。图10、图11分别为本发明的图9(a)例子和图9(b)例子的误差控制过程平均误差变化趋势图。从图中可以看出:①随着迭代次数的增加,重构图像的误差整体上逐渐减少,说明了本发明的误差控制算法具有收敛性;②随着每次迭代细分的面片数量k的增加,平均误差减少的速度也随之增加,可以在越少的迭代次数中达到指定误差阈值。但是如果k过大,一些误差小的基网格面片也会被细化,使得面片、顶点数量增加迅速,造成冗余。因此,用户可以根据能接受的误差指定相应的每次迭代细分的面片数量k,减少迭代次数。The error control algorithm of the present invention has convergence properties. If the reconstructed image does not meet the error requirement, the method of the present invention selects the first k base mesh patches with the largest average error for adaptive subdivision in each iteration, thereby increasing the number of vertices on the final control mesh. Theoretically, as the number of vertices on the control mesh increases, the reconstruction error will become smaller and smaller, and eventually converge to a small value. FIG. 10 and FIG. 11 are the average error change trend diagrams in the error control process of the example of FIG. 9( a ) and the example of FIG. 9( b ) of the present invention, respectively. It can be seen from the figure: (1) With the increase of the number of iterations, the error of the reconstructed image gradually decreases as a whole, indicating that the error control algorithm of the present invention has convergence; (2) With the number of subdivided patches k in each iteration As , the rate at which the average error decreases increases, and the specified error threshold can be reached in fewer iterations. However, if k is too large, some base mesh patches with small errors will also be refined, making the number of patches and vertices increase rapidly, resulting in redundancy. Therefore, the user can specify the corresponding number of patches k subdivided in each iteration according to the acceptable error to reduce the number of iterations.
以上所述之实施例子只为本发明之较佳实施例,并非以此限制本发明的实施范围,故凡依本发明之形状、原理所作的变化,均应涵盖在本发明的保护范围内。The above-mentioned embodiments are only preferred embodiments of the present invention, and are not intended to limit the scope of implementation of the present invention. Therefore, any changes made according to the shape and principle of the present invention should be included within the protection scope of the present invention.
Claims (1)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710304102.6A CN107256557B (en) | 2017-05-03 | 2017-05-03 | Error-controllable subdivision surface image vectorization method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710304102.6A CN107256557B (en) | 2017-05-03 | 2017-05-03 | Error-controllable subdivision surface image vectorization method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107256557A CN107256557A (en) | 2017-10-17 |
CN107256557B true CN107256557B (en) | 2020-05-22 |
Family
ID=60028161
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710304102.6A Expired - Fee Related CN107256557B (en) | 2017-05-03 | 2017-05-03 | Error-controllable subdivision surface image vectorization method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107256557B (en) |
Families Citing this family (20)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107978004A (en) * | 2017-11-14 | 2018-05-01 | 天津科技大学 | Sinking shaft mural painting archaeology drawing Fast Generation based on heuristic route |
CN108280863A (en) * | 2018-01-12 | 2018-07-13 | 武汉智博创享科技股份有限公司 | TIN model equivalence line search methods based on bilateral structure |
CN108460733B (en) * | 2018-01-31 | 2022-04-22 | 北京大学深圳研究生院 | Gradually refined image denoising method and system |
CN108428256B (en) * | 2018-04-03 | 2021-12-21 | 福建师范大学福清分校 | Soft tissue deformation simulation method based on self-adaptive grid refinement of softness |
CN109005411B (en) * | 2018-07-27 | 2021-11-30 | 广州中国科学院工业技术研究院 | Image compression method and electronic equipment |
CN109670206B (en) * | 2018-11-21 | 2022-12-06 | 杭州电子科技大学 | Simplification Method of Hexahedral Mesh Structure for Mechanical Casting Model |
CN109544577B (en) * | 2018-11-27 | 2022-10-14 | 辽宁工程技术大学 | Improved straight line extraction method based on edge point grouping |
CN109671039B (en) * | 2018-12-27 | 2023-05-30 | 北京邮电大学世纪学院 | Image vectorization method based on layering characteristics |
CN109859322B (en) * | 2019-01-22 | 2022-12-06 | 广西大学 | Spectral attitude migration method based on deformation graph |
CN110796693B (en) * | 2019-09-11 | 2023-03-21 | 重庆大学 | Method for directly generating two-dimensional finite element model from industrial CT slice image |
CN111369577B (en) * | 2020-03-03 | 2023-02-17 | 浙江大学城市学院 | A way to convert a bitmap to a vector image |
CN111462332A (en) * | 2020-03-31 | 2020-07-28 | 上海大学 | A system and method for image vectorization based on redirected subdivision surface |
CN111751211B (en) * | 2020-06-30 | 2021-05-28 | 中国科学院地质与地球物理研究所 | A method for characterization of topological structure of rock fracture network |
CN111859763B (en) * | 2020-07-27 | 2024-08-30 | 上海圣之尧智能科技有限公司 | Finite element simulation method, system and medium |
CN111950045B (en) * | 2020-08-03 | 2022-11-01 | 大连理工大学 | A kind of lens design method without light energy loss |
CN112819961B (en) * | 2021-02-18 | 2023-08-22 | 桂林电子科技大学 | Simplified Mesh Deformation Method and Device Based on Differentiable Computation |
CN114373022B (en) * | 2022-01-11 | 2024-09-06 | 青岛科技大学 | Image vectorization processing method based on boundary extraction and color reconstruction |
CN114549790A (en) * | 2022-03-03 | 2022-05-27 | 重庆邮电大学 | A Quadrilateral Mesh Generation Method Based on Normal Filtering |
CN114756944A (en) * | 2022-05-10 | 2022-07-15 | 天津天河云筑工科技有限公司 | Lightweight system, method, computer equipment and storage medium for BIM model |
CN115359209B (en) * | 2022-07-14 | 2024-01-19 | 安徽九韶信息科技有限公司 | Image processing apparatus and method |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2012238042A (en) * | 2011-05-09 | 2012-12-06 | Canon Inc | Image processing device, image processing method, and program |
CN105427360A (en) * | 2015-11-11 | 2016-03-23 | 华南理工大学 | Error-controllable CAGE sequence representation algorithm for dynamic grid |
CN105427354A (en) * | 2015-11-20 | 2016-03-23 | 浙江大学 | Planar block set based image vectorization expression method |
CN105844711A (en) * | 2015-02-02 | 2016-08-10 | 达索系统公司 | Engraving a 2D image on a subdivision surface |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
GB2366108A (en) * | 2000-07-14 | 2002-02-27 | Vhsoft Technologies Company Lt | Vectorization of raster images |
-
2017
- 2017-05-03 CN CN201710304102.6A patent/CN107256557B/en not_active Expired - Fee Related
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2012238042A (en) * | 2011-05-09 | 2012-12-06 | Canon Inc | Image processing device, image processing method, and program |
CN105844711A (en) * | 2015-02-02 | 2016-08-10 | 达索系统公司 | Engraving a 2D image on a subdivision surface |
CN105427360A (en) * | 2015-11-11 | 2016-03-23 | 华南理工大学 | Error-controllable CAGE sequence representation algorithm for dynamic grid |
CN105427354A (en) * | 2015-11-20 | 2016-03-23 | 浙江大学 | Planar block set based image vectorization expression method |
Also Published As
Publication number | Publication date |
---|---|
CN107256557A (en) | 2017-10-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107256557B (en) | Error-controllable subdivision surface image vectorization method | |
Gao et al. | Learning deformable tetrahedral meshes for 3d reconstruction | |
Litwinowicz et al. | Animating images with drawings | |
CN108765550A (en) | A kind of three-dimensional facial reconstruction method based on single picture | |
CN101877148B (en) | Method for repairing three-dimensional grid model based on global structure | |
CN101599181B (en) | A real-time rendering method of algebraic B-spline surface | |
JP6463625B2 (en) | Image resizing | |
CN101853525B (en) | Mesh segmentation based simplification method for preserving details of textured model | |
Binninger et al. | Developable approximation via gauss image thinning | |
CN103810729B (en) | A kind of based on isocontour raster image vector quantized method | |
CN103632394B (en) | The Model Simplification Method that a kind of feature keeps | |
CN101231761A (en) | A Mesh Model Simplification Method Preserving Appearance Features | |
CN102521869A (en) | Three-dimensional model surface texture empty filling method guided by geometrical characteristic | |
CN114707388B (en) | A 3D CAD reconstruction method for pixel-based topology optimization results | |
CN115984441A (en) | Method for rapidly reconstructing textured three-dimensional model based on nerve shader | |
CN102024268A (en) | Model simplification method for keeping appearance characteristics | |
CN114298181A (en) | Vector font generation method based on bimodal learning | |
CN116363290A (en) | Texture map generation method for large-scale scene three-dimensional reconstruction | |
CN108230452A (en) | A kind of model filling-up hole method based on textures synthesis | |
Chen et al. | Content-aware image resizing by quadratic programming | |
Vaitkus et al. | Parameterizing and extending trimmed regions for tensor-product surface fitting | |
CN104166992A (en) | Content perception binocular image zooming method based on grid deformation | |
CN104933754B (en) | A Linear Shadow Map Method for Depixelated Contour Reconstruction | |
Lyu et al. | Laplacian-based 3D mesh simplification with feature preservation | |
CN112116710B (en) | Curved surface reconstruction method based on trend constraint |
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 | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20200522 |
|
CF01 | Termination of patent right due to non-payment of annual fee |