Thangka color image vectorization method and system based on micro renderer
By optimizing the Bézier curve parameters through color quantization and a differentiable renderer, the problems of high reconstruction error and computational complexity in the vectorization of Thangka color images are solved, achieving a high-precision and lightweight vectorized representation.
Patent Information
- Application Number
- CN202511397400.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-28
- Publication Date
- 2025-12-19
AI Technical Summary
In the process of vectorizing Thangka color images, existing technologies are susceptible to noise and threshold selection during edge detection, resulting in significant reconstruction errors and high computational complexity, making it difficult to guarantee reconstruction accuracy and editability.
Color quantization is used to condense the pixel distribution of a color Thangka image into several color clusters. A set of Bézier curves is generated by a differentiable renderer, and gradient information is used to iteratively optimize geometric and color parameters. The number of curves is optimized by combining pixel connectivity analysis and loss function, so as to achieve the topological correspondence between regions and curves.
It significantly improves the accuracy of vectorized reconstruction of Thangka color images, reduces computational complexity, ensures the accuracy and integrity of region boundaries, reduces the number of vector graph elements, and achieves lightweight representation and high-quality reconstruction.
Smart Images

Figure CN121170037A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of digital image processing technology, and in particular to a method and system for vectorizing Thangka color images based on a differentiable renderer. Background Technology
[0002] In color image vectorization, a suitable color quantization algorithm plays a crucial role in reducing the complexity and computational cost of subsequent vectorization processes. Images may contain tens of thousands of colors, and directly vectorizing them would significantly increase computational complexity. The main task of color quantization is to map the large number of colors in an image to a smaller, fixed set of colors. Especially in vector graphics, more colors mean more color blocks, which directly affects the editability of the vector image.
[0003] Chinese Patent CN113706648B discloses a method for vectorizing Thangka elements based on diffusion curves. The method includes: 1) inputting a Thangka element image and waiting for processing; 2) performing image preprocessing; 3) performing Canny edge extraction; 4) fitting Bézier curves to the binary edge information of the Thangka element image; 5) performing color sampling on the Bézier curve; 6) selectively adjusting the curve control points and color sampling information of the Bézier curve manually; 7) solving the Poisson equation with the colors on the Bézier curve as constraints to obtain the vector result; and 8) storing the Bézier curve control points and color sampling information in a file to save the vector information of the Thangka elements. However, the above scheme relies on Canny edge detection with a fixed threshold, which is easily affected by noise and threshold selection, resulting in edge loss or severe false edges, leading to significant reconstruction errors. Therefore, it is necessary to provide a Thangka color image vectorization method and system based on a differentiable renderer to improve the accuracy of Thangka color image vectorization reconstruction. Summary of the Invention
[0004] In view of this, the present invention proposes a method and system for vectorizing Thangka color images based on a differentiable renderer. By using color quantization, the pixel distribution in the original color Thangka image is condensed into several color clusters, achieving a one-to-one topological correspondence between regions and curves. Simultaneously, the generated set of Bézier curves is rendered into a raster image using a differentiable renderer, and the geometric and color parameters of each curve are iteratively optimized using gradient information, thereby improving the accuracy of Thangka color image vectorization reconstruction.
[0005] This invention provides a method for vectorizing Thangka color images based on a differentiable renderer, the method comprising: A color Thangka raster image to be processed is acquired, and the color of the color Thangka raster image is quantized to obtain multiple color clusters corresponding to the color Thangka raster image; Based on pixel connectivity analysis of each color cluster, independent connected regions in each color cluster are extracted, and the centroid and area of the independent connected regions are calculated. Based on the centroid and the diameter proportional to the area of the region, a Bézier curve corresponding to the independent connected region is generated, and the Bézier curves corresponding to all independent connected regions are integrated to obtain a set of Bézier curve shapes. The geometric and color parameters of each Bézier curve in the set of Bézier curve shapes are iteratively optimized using a differentiable renderer to obtain an optimized set of Bézier curve shapes. The Bézier curve shape optimization set is sorted by importance based on the loss function, and the curve with the lowest importance in the Bézier curve shape optimization set is removed until the number of curves in the Bézier curve shape optimization set reaches a predetermined threshold. The target Bézier curve set is then output to form a colored Thangka raster vector image.
[0006] Based on the above technical solutions, preferably, the acquisition of the color Thangka raster image to be processed and the color quantization of the color Thangka raster image specifically includes: Perform any one of the following on the color Thangka raster image: k-means clustering, DBSCAN clustering, spectral clustering, and median segmentation quantization.
[0007] Based on the above technical solutions, preferably, the k-means clustering of the color Thangka raster image specifically includes: Multiple pixels are randomly selected from all pixels in the color Thangka raster image as initial cluster centers, wherein the number of initial color cluster centers is equal to the number of preset color clusters; For each pixel in the color Thangka raster image, calculate the Euclidean distance between each pixel and each initial cluster center, and assign the current pixel to the color cluster that is closest to the current pixel. For each color cluster in the color Thangka raster image, the color cluster center of the corresponding color cluster is recalculated based on the pixels contained in each color cluster. The color cluster center is repeatedly iterated until the update magnitude of all color cluster centers is less than a preset threshold. The multiple color cluster centers obtained at the end of the iteration are used as the color quantization result, and each pixel in the color Thangka raster image is mapped to the color cluster center corresponding to the pixel to complete the color quantization.
[0008] More preferably, the DBSCAN clustering of the color Thangka raster image specifically includes: All pixels of the color Thangka raster image are added to the unvisited point set, and one unvisited point is selected from the unvisited point set in turn; The unvisited points are marked as visited points, and the neighborhood point set of the visited points within a preset radius is calculated, wherein the neighborhood point set includes multiple pixels. If the number of pixels in the neighborhood point set is greater than or equal to the minimum number of samples, then the visited point and all pixels in the neighborhood point set corresponding to the visited point are used as initial members to generate an initial color cluster. The initial color cluster is iterated until the number of pixels in the initial color cluster no longer increases, then the initial color cluster is identified as the target color cluster; Until all unvisited points in the set of unvisited points have been visited, the average RGB value of all pixels in each target color cluster is determined as the center color of the color cluster, and the color of each pixel in the color Thangka raster image is replaced with the color of the target color cluster to which the pixel belongs, so as to complete the color quantization.
[0009] More preferably, the spectral clustering of the color Thangka raster image specifically includes: Based on all pixels in the color Thangka raster image, calculate the degree matrix and similarity matrix corresponding to the color Thangka raster image respectively; Based on the degree matrix and the similarity matrix, a Laplacian matrix is constructed, and the Laplacian matrix is standardized to obtain a standardized Laplacian matrix. The normalized Laplacian matrix is subjected to eigenvalue decomposition. From all the eigenvalues and eigenvectors corresponding to the eigenvalues obtained by the decomposition of the normalized Laplacian matrix, multiple standard eigenvalues and eigenvectors corresponding to the standard eigenvalues are selected. The number of standard eigenvalues is equal to the number of preset color clusters. The standard eigenvalues are combined column-wise to form a first standard matrix, and each row of the first standard matrix is standardized to obtain a second standard matrix. The row vectors of the second standard matrix are clustered based on the k-means algorithm to obtain the divided color clusters. The average RGB value of all pixels in each color cluster is calculated and the average RGB value is used as the center color of the color cluster. The color of each pixel in the color Thangka raster image is replaced with the center color of the color cluster to which the pixel belongs, so as to complete the color quantization.
[0010] More preferably, the spectral clustering of the color Thangka raster image specifically includes: Based on all pixels in the color Thangka raster image, calculate the degree matrix and similarity matrix corresponding to the color Thangka raster image respectively; Based on the degree matrix and the similarity matrix, a Laplacian matrix is constructed, and the Laplacian matrix is standardized to obtain a standardized Laplacian matrix. The normalized Laplacian matrix is subjected to eigenvalue decomposition. From all the eigenvalues and eigenvectors corresponding to the eigenvalues obtained by the decomposition of the normalized Laplacian matrix, multiple standard eigenvalues and eigenvectors corresponding to the standard eigenvalues are selected. The number of standard eigenvalues is equal to the number of preset color clusters. The standard eigenvalues are combined column-wise to form a first standard matrix, and each row of the first standard matrix is standardized to obtain a second standard matrix. The row vectors of the second standard matrix are clustered based on the k-means algorithm to obtain the divided color clusters. The average RGB value of all pixels in each color cluster is calculated and the average RGB value is used as the center color of the color cluster. The color of each pixel in the color Thangka raster image is replaced with the center color of the color cluster to which the pixel belongs, so as to complete the color quantization.
[0011] More preferably, the loss function includes one or more of the following: reconstruction loss function, geometric loss function, ranking loss function, and simplified loss function.
[0012] A second aspect of this application provides a Thangka color image vectorization system based on a differentiable renderer, the Thangka color image vectorization system including a color quantization module, a shape optimization module, and an image vectorization module, wherein, The color quantization module is used to acquire a color Thangka raster image to be processed and to perform color quantization on the color Thangka raster image to obtain multiple color clusters corresponding to the color Thangka raster image; The shape optimization module is used to perform pixel connectivity analysis on each color cluster to extract independent connected regions in each color cluster, calculate the centroid and area of the independent connected regions, generate Bézier curves corresponding to the independent connected regions based on the centroid and the diameter proportional to the area, integrate the Bézier curves corresponding to all independent connected regions to obtain a set of Bézier curve shapes, and iteratively optimize the geometric and color parameters of each Bézier curve in the set of Bézier curve shapes based on a differentiable renderer to obtain an optimized set of Bézier curve shapes. The image vectorization module is used to sort the Bézier curve shape optimization set by importance based on the loss function, and remove the curve with the lowest importance in the Bézier curve shape optimization set until the number of curves in the Bézier curve shape optimization set reaches a predetermined threshold, and output the target Bézier curve set to form a color Thangka raster vector image.
[0013] A third aspect of this application provides an electronic device including a processor, a memory, a user interface, and a network interface, wherein the memory is used to store instructions, the user interface and the network interface are used to communicate with other devices, and the processor is used to execute the instructions stored in the memory.
[0014] A fourth aspect of this application provides a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the steps of a method for vectorizing Thangka color images based on a differentiable renderer.
[0015] The vectorization method and system for Thangka color images based on a differentiable renderer provided by this invention has the following advantages over existing technologies: (1) By color quantization, the pixel distribution in the original color Thangka image is condensed into several color clusters, which significantly reduces the color complexity of subsequent processing. Based on pixel connectivity analysis, independent connected regions in each color cluster are automatically extracted to ensure the accuracy and integrity of the region boundary. Furthermore, with the centroid of each connected region as the anchor point and the equivalent diameter corresponding to the region area as the scale, a Bézier curve matching the region shape is quickly generated to achieve a topological one-to-one correspondence between the region and the curve. The generated Bézier curve set is rendered into a raster image by a differentiable renderer, and the geometric and color parameters of each curve are iteratively optimized using gradient information, which significantly reduces the reconstruction error and improves the accuracy of vector reconstruction of Thangka color images. At the same time, the importance of each curve is scored according to the rendering loss, and the curves that contribute the least to the overall reconstruction are automatically removed until the total number of curves reaches the preset threshold. Under the premise of ensuring reconstruction quality, the number of vector image elements is greatly reduced to achieve lightweight representation.
[0016] (2) DBSCAN clustering can extract irregular, curved or long strip color regions based on the real distribution of pixels in RGB space, which is more in line with the natural distribution of color patches in traditional Thangka. Pixels with less than the threshold of sample number in the field are regarded as noise and are not included in any cluster. This avoids forced grouping of a small amount of noise or scanning defects, improves the purity of the quantized region, and does not make hard allocation to sparse regions, which helps to preserve color transition bands. This reduces obvious step, virtual edge or discontinuity phenomena in subsequent connected component extraction and curve fitting. At the same time, the output color clusters correspond to real and structured color blocks inside the image. This not only makes pixel connectivity analysis more coherent, but also provides a more accurate initial geometric and topological basis for the generation of Bézier curves based on centroid and equivalent diameter. After effectively removing a small number of noise clusters, the total number of clusters is closer to the actual color category. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 A flowchart illustrating a method for vectorizing Thangka color images based on a differentiable renderer, provided by the present invention; Figure 2 This is a schematic diagram illustrating the process of vectorizing Thangka color images provided by the present invention; Figure 3 This is a schematic diagram of the Thangka color image vectorization system provided by the present invention; Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention.
[0019] Explanation of reference numerals in the attached diagram: 1. Thangka color image vectorization system; 11. Color quantization module; 12. Shape optimization module; 13. Image vectorization module; 2. Electronic device; 21. Processor; 22. Communication bus; 23. User interface; 24. Network interface; 25. Memory. Detailed Implementation
[0020] The technical solutions of the present invention will be clearly and completely described below with reference to the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0021] In the field of color image vectorization research, traditional mathematical methods, such as triangular mesh-based vectorization methods, typically rely on pixel segmentation and geometric fitting. These algorithms generate a large number of shapes that are difficult to edit, or have poor generalization capabilities. In recent years, machine learning methods have brought new directions to color image vectorization. LIVE uses a bottom-up hierarchical approach to generate semantically consistent vector images through layer-by-layer optimization, but the algorithm has a large computational load and long running time. DiffVG directly optimizes Bézier curve parameters to match the target image through a differentiable renderer, but it is highly sensitive to initialization and easily gets trapped in local optima. O&R improves upon DiffVG by adopting a top-down vectorization strategy that significantly reduces the number of shapes and running time, but its computational cost is high and it is sensitive to image noise, which may lead to uneven shape distribution after initialization. Based on O&R, this paper discusses the selection of color quantization algorithms and introduces a new loss function to improve the optimization and simplification strategies, resulting in vectorized graphics with better editability.
[0022] This invention discloses a method for vectorizing Thangka color images based on a differentiable renderer, with reference to... Figure 1 The steps of this method include S1 to S5.
[0023] Step S1: Acquire the color Thangka raster image to be processed, and perform color quantization on the color Thangka raster image to obtain multiple color clusters corresponding to the color Thangka raster image.
[0024] In this step, a color Thangka raster image to be processed is acquired, and color quantization is performed on the color Thangka raster image. Specifically, this includes any one of the following: k-means clustering, DBSCAN clustering, spectral clustering, and median segmentation quantization of the color Thangka raster image.
[0025] Furthermore, traditional vector graphics rasterization is a discrete process that cannot compute gradients, while the core of DiffVG is differentiable rasterization, which establishes gradient connections between the parameter space of vector graphics and the image space, allowing us to optimize the parameters of vector graphics through gradient descent.
[0026] For color Thangka raster images I target The image edges are extracted using an edge detection algorithm, generating a binary map of the boundaries. These boundaries are then approximated as multiple Bézier curves, with the color attribute of each curve initialized to the average color of the region containing that curve. The output of this step is the initial vector parameter Θ, which includes the geometric parameter Θ. geo (Control point location) and color description Θ color(Color, transparency, gradients, etc.). Vector graphics are rendered using rasterization formulas, for pixels ( x , y ) color I ( x , y This is calculated by weighting the colors of the graphics within the small area covering this pixel. I ( x , y )=∫∫ A k ( u , v ) f ( x - u , yv ;Θ) dudv in, k ( u , v ) represents the anti-aliasing filter kernel. f ( xu , yv ;Θ) represents the color function for vector graphics, which is usually not continuous. A This represents the supporting domain of the kernel.
[0027] The above integral formula is difficult to solve directly, especially the contribution of the graph boundary is difficult to integrate accurately. Therefore, DiffVG provides two anti-aliasing methods: Monte Carlo sampling based on random sampling integration region and Analytical Prefiltering based on Signed Distance Field (SDF).
[0028] The Monte Carlo sampling method discretizes the pixel integral and sets the number of sampling points to 1. N ,for A Random sampling points in u i , v i ):
[0029] Accurately process gradient information of boundary changes based on Reynolds transport theorem:
[0030] The first term represents the derivative with respect to changes in color and transparency, and the second term is the boundary integral, which handles the contribution changes caused by boundary variations.
[0031] The pre-filtering analysis approximates the rasterization formula analytically, transforming the two-dimensional integral into a one-dimensional integral based on the curve boundary. It does not directly calculate this complex integral, but instead focuses on the "distance" between the pixel center and the graphic boundary, using the distance to indirectly estimate the pixel color. Its core assumptions are two: (1) the distance from the pixel center to the graphic boundary. It can reflect the contribution of the graphic to the pixel color (2) The distant boundary has a small impact, while the near boundary has a large impact.
[0032] Overriding function K ( d This is used to quantify the contribution:
[0033] in, C 0 and C 1 represents the normalization constant, used to ensure K (1) = 0 and K (-1)=1, k ( r ) is a radially symmetric filter kernel. When d> At time 1, the graphic is too far from the pixel center, having almost no effect on the pixel color. d<- At time 1, the center of the pixel is completely inside the graphic, and the graphic completely covers the pixel.
[0034] The analytical pre-filter handles the two cases separately: For filled regions, if the center of a pixel is inside the shape or near the shape boundary, then use directly. K ( d ):
[0035] For strokes, if the line width is w Therefore, the color of a pixel is determined by both the line thickness and its position. K ( d )= K ( d+w )- K ( d - w ) For practical calculation K ( d ), a filter kernel needs to be defined. k ( r Typically, a parabolic kernel is used.
[0036] at this time:
[0037] The final pixel color is simplified to:
[0038] This simplified formula allows for quick calculation of pixel colors.
[0039] In the first example, k-means clustering is performed on the color Thangka raster image, specifically including: Multiple pixels are randomly selected from all pixels in the color Thangka raster image as initial cluster centers, wherein the number of initial color cluster centers is equal to the number of preset color clusters; For each pixel in the color Thangka raster image, calculate the Euclidean distance between each pixel and the center of each initial cluster, and assign the current pixel to the color cluster that is closest to the current pixel. For each color cluster in the color Thangka raster image, the color cluster center of the corresponding color cluster is recalculated based on the pixels contained in each color cluster. The color cluster center is repeatedly calculated iteratively until the update magnitude of all color cluster centers is less than the preset threshold. The multiple color cluster centers obtained at the end of the iteration are used as the color quantization result, and each pixel in the color Thangka raster image is mapped to the color cluster center corresponding to the pixel to complete the color quantization.
[0040] In this embodiment, k-means clustering is an unsupervised learning algorithm that divides the pixels in the color Thangka raster image into... k There are several color clusters, such that the average error between a pixel within a color cluster and its center is minimized. In other words, the goal is to minimize the following function:
[0041] in, x Indicates the first x Each pixel represents a specific color information of that pixel. C i Representing the i A color cluster, m i Indicates the first i The center of each color cluster, || x-m i || represents the Euclidean distance, which is the distance from a pixel to the center of a color cluster. Table 1 shows the algorithm flow of k-means.
[0042] Table 1
[0043] In the second example, DBSCAN clustering is performed on the color Thangka raster image, specifically including: Add all pixels of the color Thangka raster image to the unvisited point set, and then select one unvisited point from the unvisited point set in turn; Unvisited points are marked as visited points, and the neighborhood point set of the visited points within a preset neighborhood radius is calculated, where the neighborhood point set includes multiple pixels; If the number of pixels in the neighborhood point set is greater than or equal to the minimum number of samples, then the visited point and all pixels in the neighborhood point set corresponding to the visited point are used as initial members to generate an initial color cluster. The initial color cluster is iterated until the number of pixels in the initial color cluster no longer increases, then the initial color cluster is identified as the target color cluster; The process continues until all unvisited points in the set of unvisited points have been visited. The average RGB value of all pixels in each target color cluster is determined as the center color of the color cluster. The color of each pixel in the color Thangka raster image is then replaced with the color of the target color cluster to which the pixel belongs, thus completing the color quantization.
[0044] In this embodiment, DBSCAN (Density-Based Spatial Clustering of Applications with Noise) is a density-based clustering algorithm that can effectively identify clusters of arbitrary shapes and handle noisy data. Unlike K-means, DBSCAN does not require pre-specifying the number of clusters; it can group pixels of similar colors together to form smaller color clusters, thereby reducing the number of colors in the image. The neighborhood is defined as follows:
[0045]
[0046] in, distance ( ) represents the distance function. P Indicates unvisited points. Represents a point within a neighborhood set. R P Indicates unvisited points P The R channel value, G P Indicates unvisited points P The G channel value, B P Indicates unvisited points P The B channel value, Represents points within a neighborhood set. The R channel value, Represents points within a neighborhood set. The G channel value, Represents points within a neighborhood set. The B channel value. This method is quite sensitive to parameters and requires continuous adjustment. Inappropriate parameters may lead to "oversegmentation" and "cluster disconnection". On the other hand, it has certain requirements for the uniformity of image color density distribution. If the color distribution difference is large, small density areas may be classified as noise. Table 2 shows the algorithm flow of DBSCAN.
[0047] Table 2
[0048] In this embodiment, color quantization condenses the pixel distribution in the original color Thangka image into several color clusters, significantly reducing the color complexity of subsequent processing. Based on pixel connectivity analysis, independent connected regions within each color cluster are automatically extracted, ensuring the accuracy and integrity of region boundaries. Using the centroid of each connected region as an anchor point and the equivalent diameter corresponding to the region area as a scale, Bézier curves matching the region shape are quickly generated, achieving a topological one-to-one correspondence between regions and curves. Simultaneously, a differentiable renderer renders the generated Bézier curve set into a raster image, and gradient information is used to iteratively optimize the geometric and color parameters of each curve, significantly reducing reconstruction errors. The importance of each curve is scored based on rendering loss, and curves contributing the least to the overall reconstruction are automatically removed until the total number of curves reaches a preset threshold. This significantly reduces the number of vector graph elements while ensuring reconstruction quality, achieving a lightweight representation.
[0049] In the third example, spectral clustering is performed on a color Thangka raster image, specifically including: Based on all pixels in the color Thangka raster image, calculate the degree matrix and similarity matrix corresponding to the color Thangka raster image respectively; Based on the degree matrix and similarity matrix, construct the Laplacian matrix and standardize it to obtain the standardized Laplacian matrix; Eigenvalue decomposition is performed on the standardized Laplacian matrix. From all the eigenvalues and corresponding eigenvectors obtained by the decomposition of the standardized Laplacian matrix, multiple standard eigenvalues and corresponding eigenvectors are selected. The number of standard eigenvalues is equal to the number of preset color clusters. The first standard matrix is formed by combining the standard eigenvalues column by column, and each row of the first standard matrix is standardized to obtain the second standard matrix. The k-means algorithm is used to cluster the row vectors of the second standard matrix to obtain the divided color clusters. The average RGB value of all pixels in each color cluster is calculated and the average RGB value is used as the center color of the color cluster. The color of each pixel in the color Thangka raster image is replaced with the center color of the color cluster to which the pixel belongs, so as to complete the color quantization.
[0050] In this embodiment, spectral clustering is a clustering method based on graph theory and linear algebra, which uses the similarity between data points to perform clustering. Compared with the k-means algorithm, spectral clustering is more adaptable to data distribution, can effectively handle non-convex datasets, and has a much smaller computational cost. Table 3 shows the algorithm flow of spectral clustering.
[0051] The Gaussian similarity formula is used when constructing the similarity matrix:
[0052] Degree matrix D It is a diagonal matrix, whose diagonal elements D ii Represents a node i The degree, that is, the degree with the node i The sum of all similarity values for the connections: .
[0053] Table 3
[0054] In the fourth example, median segmentation quantization is performed on the color Thangka raster image, specifically including: The RGB color values corresponding to all pixels in the color Thangka raster image are used as the initial color set, and the boundary range of the initial color set in RGB three-dimensional space is calculated. Select the channel axis with the largest span among the R, G, and B channels, sort all color values in the initial color set along the selected channel axis, and divide the initial color set into a first color subset and a second color subset according to the preset median in the direction of the selected channel axis. The first and second color subsets are iterated successively until multiple target color subsets are obtained, wherein the number of target color subsets is equal to the number of preset color clusters; Calculate the representative color for each target color subset, and replace the color value of each pixel in the color Thangka raster image with the representative color of the target color subset to which the pixel belongs to complete the color quantization. The representative color is the mean or median of all color values in the target color subset.
[0055] In this embodiment, the Median-Cut algorithm is a color quantization technique that reduces the number of colors and preserves the visual quality of the image as much as possible by continuously dividing the color space of the image into multiple different regions. Table 4 shows the general algorithm flow of Median-Cut.
[0056] Table 4
[0057] Step S2 involves performing pixel connectivity analysis on each color cluster to extract independent connected regions in each color cluster, and calculating the centroid and area of each independent connected region.
[0058] Step S3: Based on the centroid and the diameter proportional to the area of the region, generate Bézier curves corresponding to the independent connected regions, and integrate the Bézier curves corresponding to all independent connected regions to obtain a set of Bézier curve shapes.
[0059] In this step, such as Figure 2 As shown, while DiffVG introduces differentiable rasterization to solve the problem of gradient computation in traditional vectorization methods, its sensitivity to initial values makes it prone to getting trapped in local optima. Clustering the image using color quantization to generate the initial shape is more effective than random initialization. For the input image... I The pixel colors of the image are clustered using a color quantization algorithm to obtain cluster partitions. C =( C 1, ... , C K ).
[0060] For each cluster of pixels, connected component analysis is performed to extract each independent part of the image separately, which facilitates subsequent Bézier curve fitting.
[0061] R i , k Clustering k The first in i For each connected region, calculate its centroid:
[0062] For each connected region, an initial circular shape also needs to be generated, with the centroid at its center. x c , y c Its diameter is related to the area of the region. R i , k |Proportional:
[0063] in, d i The diameter is the radius of the circle. The initial control points of the Bézier curve are distributed in a circular pattern. Let the number of control points be 1. K The generated control points are: P k =( x c + d i ·cos( i k ), y c + d i sin( i k )) i k =2 πk / K Ultimately, each region is initialized as a Bézier curve: P i ={ p 1,..., p K , c i The initialization phase is now complete, and the color Thangka raster image is ready. I It is transformed into a set of N Bézier curves.
[0064] Step S4: Iteratively optimize the geometric and color parameters of each Bézier curve in the set of Bézier curve shapes using a differentiable renderer to obtain an optimized set of Bézier curve shapes.
[0065] In this step, the goal of the optimization phase is to minimize the error between the vectorized image and the input raster image by adjusting the control points and color parameters of each Bézier curve. Therefore, the objective function is given as follows: L optimize = L reconstruction + l geometric L geometric in, L reconstruction To reconstruct the loss function, L geometric This is the geometric loss function. When optimizing the parameters of the Bézier curves using gradient descent, the DiffVG renderer continues to calculate the relevant gradients, thereby updating the control points and colors of each Bézier curve:
[0066]
[0067] To further optimize image editability, it is necessary to evaluate the contribution of each Bézier curve to the image reconstruction quality and remove curves with lower importance. The task at this stage is to minimize the number of redundant shapes while maintaining image quality.
[0068] For the set of Bézier curves obtained in the previous step P Select one of the Bézier curves P i After removing it, calculate the simplified loss. L ruduce Then, rank the curves, remove the lowest-scoring Bézier curves based on the ranking results, and repeat this process until the number of remaining curves reaches the target number. N target。 Once the target number is reached, the remaining Bézier curve parameter set will serve as input for the next optimization stage. P optimize = P ruduced。
[0069] Step S5: Sort the Bézier curve shape optimization set by importance based on the loss function, and remove the curve with the lowest importance in the Bézier curve shape optimization set until the number of curves in the Bézier curve shape optimization set reaches a predetermined threshold. Output the target Bézier curve set to form a colored Thangka raster vector image.
[0070] In this step, the loss function includes one or more of the following: reconstruction loss function, geometric loss function, ranking loss function, and simplified loss function.
[0071] Reconstruction loss measures the difference between the generated image and the target image. It is defined as follows: I i For the first part of the original image i pixel value, For generating the first image i pixel value, N The total number of pixels in the image is calculated using the following formula: ( L 1) ( MSE ) ( MSE ) ( L 1) ( ) ( ) in, PyrDown Gaussian pyramids are image processing techniques used to create images. They reduce the image resolution by downsampling layer by layer while preserving its main features. The formula is as follows:
[0072]
[0073]
[0074]
[0075] Furthermore, the geometric loss is calculated in three parts: Intersect Loss, Orient Loss, and Angle Loss. These losses are designed to ensure that the generated Bézier curve is geometrically sound.
[0076] For line segments AB and CD Its direction vector is:
[0077] Determine whether line segments intersect by calculating values in four directions: orientation ( P 1, P 2, P 3)=tanh(( P 2y - P 1y )·( P 3x - P 2x )-( P 2x - P 1x )·( P 3y - P 2y )) o 1= orientation ( A , B , C ) o 2= orientation ( A , B , D ) o 3= orientation ( C , D , A ) o 4= orientation ( C , D , B ) o 5= orientation ( B , CD ) intersect ( AB , CD )=( o 1≠ o 2)·( o 3≠ o 4) orient ( AB , CD )= o 1· o 5 Intersection loss: If two curve segments intersect, the angle between them should be kept as small as possible; if they do not intersect, the angle between them should be increased. The calculation formula is as follows: i =atan2( cross ( AB , CD ), dot ( AB , CD )) L intersect = intersect ·( l geometric_punish -1)· cos ( i ) in, l geometric_punish Represents the geometric penalty coefficient. i This indicates the angle between line segments.
[0078] Directional loss: Directional loss measures whether two line segments maintain the same direction. The calculation formula is as follows: L orient = orient · l geometric_punish Angle loss: Angle loss is used to encourage good angular relationships in the connecting parts of the generated Bézier curves. The calculation formula is as follows:
[0079] The total loss of geometric loss is defined as follows: L geometrict = L intersect + L orient + L angle Furthermore, Ranking Loss is used to calculate the importance of each shape, measuring the impact of removing that shape on the reconstruction quality, thus generating an importance score for each shape. Histogram Loss, defined using Bach distance, measures the color histogram similarity between the target image and the rendered image after removing a certain shape, for each color cluster in the histogram. k Color probability distribution p ( k )and q ( k ) represents the probability of each color cluster, defined as follows:
[0080] in, H p ( k ) is the color cluster in the generated image. k frequency, H q ( k ) is a color cluster in the target image k The frequency of.
[0081] Histogram loss is defined as follows:
[0082] Contrast loss measures the impact of removing a certain graphic element on the overall image contrast characteristics. Contrast entropy is defined to quantify the complexity of the image contrast distribution and can be expressed as:
[0083] in, p ( k (contrast) kThe probability distribution and contrast values are calculated using a local window (sliding window):
[0084] Contrast loss is defined as:
[0085] Finally, remove the graphics. p i The ranking loss is defined as:
[0086] Reduce Loss focuses on the impact of the filtering process on the overall reconstruction effect, and is used to measure the overall reconstruction error after shape reduction. It is defined as follows:
[0087] in, P ruduced This represents the set of shapes remaining after filtering. I ruduced ( P ruduced () represents the rendering result of the filtered shape set. I target Represents the target image, || || p To represent L1 norm or L2 norm, this article directly uses L ranking Related losses.
[0088] In one example, other losses are also included. The following loss functions are used in the DiffVG optimization process to guide gradient calculation and optimization direction: Perceptual loss extracts high-level features of an image through a deep neural network, thereby comparing the differences between the optimized image and the target image in the feature space.
[0089] The structural loss is based on superpixel segmentation and is used to optimize the local structural consistency of an image. In the code implementation, the SLIC algorithm is used for superpixel segmentation. The structural loss includes the following components: region color distribution similarity loss (based on color histogram), region texture distribution similarity loss (based on LBP feature histogram), superpixel boundary consistency loss (preserving boundary consistency), superpixel region size similarity loss (constraining superpixel region size), and region similarity loss (combining color, texture, size, and fill characteristics).
[0090] Edge loss minimizes the difference between the gradient maps (edge information) of the optimization image and the target image by comparing them, and is defined as follows:
[0091] in, For image I The gradient.
[0092] The control point arrangement loss imposes constraints on the geometric relationships of Bézier curves in vector graphics, penalizing unreasonable control point arrangements, and is defined as follows:
[0093] in, M This indicates the number of segments in the Bézier curve. i i Indicates the first i The angle of the curve segment.
[0094] The symbolic distance loss, which represents shape information through a symbolic distance field (SDF), optimizes the structure of vector graphics and is defined as follows:
[0095] in, SDF ( I ) represents an image I The sign distance field.
[0096] In this embodiment, color quantization condenses the pixel distribution in the original color Thangka image into several color clusters, significantly reducing the color complexity of subsequent processing. Based on pixel connectivity analysis, independent connected regions within each color cluster are automatically extracted, ensuring the accuracy and integrity of region boundaries. Using the centroid of each connected region as an anchor point and the equivalent diameter corresponding to the region area as a scale, Bézier curves matching the region shape are quickly generated, achieving a topological one-to-one correspondence between regions and curves. Simultaneously, a differentiable renderer renders the generated Bézier curve set into a raster image, and gradient information is used to iteratively optimize the geometric and color parameters of each curve, significantly reducing reconstruction errors. The importance of each curve is scored based on rendering loss, and curves contributing the least to the overall reconstruction are automatically removed until the total number of curves reaches a preset threshold. This significantly reduces the number of vector graph elements while ensuring reconstruction quality, achieving a lightweight representation.
[0097] Based on the above method, this application discloses a vectorization system for Thangka color images based on a differentiable renderer, referencing... Figure 3 The Thangka color image vectorization system 1 includes a color quantization module 11, a shape optimization module 12, and an image vectorization module 13, wherein... The color quantization module 11 is used to acquire the color Thangka raster image to be processed and to perform color quantization on the color Thangka raster image to obtain multiple color clusters corresponding to the color Thangka raster image; The shape optimization module 12 is used to perform pixel connectivity analysis on each color cluster to extract independent connected regions in each color cluster, calculate the centroid and area of the independent connected regions, generate Bézier curves corresponding to the independent connected regions based on the centroid and the diameter proportional to the area, integrate the Bézier curves corresponding to all independent connected regions to obtain a set of Bézier curve shapes, and iteratively optimize the geometric and color parameters of each Bézier curve in the set of Bézier curve shapes based on a differentiable renderer to obtain a set of optimized Bézier curve shapes. The image vectorization module 13 is used to sort the Bézier curve shape optimization set by importance based on the loss function, and remove the curve with the lowest importance in the Bézier curve shape optimization set until the number of curves in the Bézier curve shape optimization set reaches a predetermined threshold, and output the target Bézier curve set to form a color Thangka raster vector image.
[0098] In one example, the color quantization module 11 is used to perform any one of the following on the color Thangka raster image: k-means clustering, DBSCAN clustering, spectral clustering, and median segmentation quantization.
[0099] In one example, k-means clustering is performed on a color Thangka raster image, specifically including: Multiple pixels are randomly selected from all pixels in the color Thangka raster image as initial cluster centers, wherein the number of initial color cluster centers is equal to the number of preset color clusters; For each pixel in the color Thangka raster image, calculate the Euclidean distance between each pixel and the center of each initial cluster, and assign the current pixel to the color cluster that is closest to the current pixel. For each color cluster in the color Thangka raster image, the color cluster center is recalculated based on the pixels contained in each color cluster. This process is repeated iteratively until the update magnitude of all color cluster centers is less than a preset threshold. The multiple color cluster centers obtained at the end of the iteration are used as the color quantization result, and each pixel in the color Thangka raster image is mapped to the color cluster center corresponding to the pixel to complete the color quantization.
[0100] In one example, DBSCAN clustering is performed on a color Thangka raster image, specifically including: Add all pixels of the color Thangka raster image to the unvisited point set, and then select one unvisited point from the unvisited point set in turn; Unvisited points are marked as visited points, and the neighborhood point set of the visited points within a preset neighborhood radius is calculated, where the neighborhood point set includes multiple pixels; If the number of pixels in the neighborhood point set is greater than or equal to the minimum number of samples, then the visited point and all pixels in the neighborhood point set corresponding to the visited point are used as initial members to generate an initial color cluster. The initial color cluster is iterated until the number of pixels in the initial color cluster no longer increases, then the initial color cluster is identified as the target color cluster; The process continues until all unvisited points in the set of unvisited points have been visited. The average RGB value of all pixels in each target color cluster is determined as the center color of the color cluster. The color of each pixel in the color Thangka raster image is then replaced with the color of the target color cluster to which the pixel belongs, thus completing the color quantization.
[0101] In one example, spectral clustering is performed on a color Thangka raster image, specifically including: Based on all pixels in the color Thangka raster image, calculate the degree matrix and similarity matrix corresponding to the color Thangka raster image respectively; Based on the degree matrix and similarity matrix, construct the Laplacian matrix and standardize it to obtain the standardized Laplacian matrix; Eigenvalue decomposition is performed on the standardized Laplacian matrix. From all the eigenvalues and corresponding eigenvectors obtained by the decomposition of the standardized Laplacian matrix, multiple standard eigenvalues and corresponding eigenvectors are selected. The number of standard eigenvalues is equal to the number of preset color clusters. The first standard matrix is formed by combining the standard eigenvalues column by column, and each row of the first standard matrix is standardized to obtain the second standard matrix. The k-means algorithm is used to cluster the row vectors of the second standard matrix to obtain the divided color clusters. The average RGB value of all pixels in each color cluster is calculated and the average RGB value is used as the center color of the color cluster. The color of each pixel in the color Thangka raster image is replaced with the center color of the color cluster to which the pixel belongs, so as to complete the color quantization.
[0102] In one example, median segmentation quantization is performed on a color Thangka raster image, specifically including: The RGB color values corresponding to all pixels in the color Thangka raster image are used as the initial color set, and the boundary range of the initial color set in RGB three-dimensional space is calculated. Select the channel axis with the largest span among the R, G, and B channels, sort all color values in the initial color set along the selected channel axis, and divide the initial color set into a first color subset and a second color subset according to the preset median in the direction of the selected channel axis. The first and second color subsets are iterated successively until multiple target color subsets are obtained, wherein the number of target color subsets is equal to the number of preset color clusters; Calculate the representative color for each target color subset, and replace the color value of each pixel in the color Thangka raster image with the representative color of the target color subset to which the pixel belongs to complete the color quantization. The representative color is the mean or median of all color values in the target color subset.
[0103] In one example, the loss function includes one or more of the following: reconstruction loss function, geometric loss function, ranking loss function, and simplified loss function.
[0104] Please see Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 4 As shown, the electronic device 2 may include: at least one processor 21, at least one network interface 24, user interface 23, memory 25, and at least one communication bus 22.
[0105] The communication bus 22 is used to enable communication between these components.
[0106] The user interface 23 may include a display screen and a camera. Optionally, the user interface 23 may also include a standard wired interface and a wireless interface.
[0107] The network interface 24 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface).
[0108] The processor 21 may include one or more processing cores. The processor 21 connects to various parts of the server using various interfaces and lines, and performs various server functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 25, and by calling data stored in the memory 25. Optionally, the processor 21 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 21 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required for display; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 21 and may be implemented as a separate chip.
[0109] The memory 25 may include random access memory (RAM) or read-only memory. Optionally, the memory 25 may include non-transitory computer-readable storage medium. The memory 25 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 25 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 25 may also be at least one storage device located remotely from the aforementioned processor 21. Figure 4 As shown, the memory 25, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and an application program for vectorizing Thangka color images based on a differentiable renderer.
[0110] exist Figure 4In the electronic device 2 shown, the user interface 23 is mainly used to provide an input interface for the user and to obtain the user input data; while the processor 21 can be used to call an application stored in the memory 25 for a vectorization method of Thangka color pictures based on a differentiable renderer. When executed by one or more processors, the electronic device executes one or more methods as described in the above embodiments.
[0111] A computer-readable storage medium storing instructions that, when executed by one or more processors, cause a computer to perform one or more methods as described in the embodiments above.
[0112] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0113] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0114] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the shown or discussed mutual couplings or direct couplings or communication connections may be through some service interfaces; indirect couplings or communication connections between apparatuses or units may be electrical or other forms.
[0115] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0116] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0117] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, portable hard drives, magnetic disks, or optical disks.
[0118] The above are merely exemplary embodiments of this disclosure and should not be construed as limiting the scope of this disclosure. Any equivalent changes and modifications made in accordance with the teachings of this disclosure shall still fall within the scope of this disclosure. Those skilled in the art will readily conceive of other embodiments of this disclosure upon considering the specification and the disclosure of practical truths. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not described in this disclosure.
[0119] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for vectorizing Thangka color images based on a differentiable renderer, characterized in that, The method includes: A color Thangka raster image to be processed is acquired, and the color of the color Thangka raster image is quantized to obtain multiple color clusters corresponding to the color Thangka raster image; Based on pixel connectivity analysis of each color cluster, independent connected regions in each color cluster are extracted, and the centroid and area of the independent connected regions are calculated. Based on the centroid and the diameter proportional to the area of the region, a Bézier curve corresponding to the independent connected region is generated, and the Bézier curves corresponding to all independent connected regions are integrated to obtain a set of Bézier curve shapes. The geometric and color parameters of each Bézier curve in the set of Bézier curve shapes are iteratively optimized using a differentiable renderer to obtain an optimized set of Bézier curve shapes. The Bézier curve shape optimization set is sorted by importance based on the loss function, and the curve with the lowest importance in the Bézier curve shape optimization set is removed until the number of curves in the Bézier curve shape optimization set reaches a predetermined threshold. The target Bézier curve set is then output to form a colored Thangka raster vector image.
2. The method for vectorizing Thangka color images based on a differentiable renderer as described in claim 1, characterized in that, The process of acquiring and processing a color Thangka raster image, and performing color quantization on the color Thangka raster image, specifically includes: Perform any one of the following on the color Thangka raster image: k-means clustering, DBSCAN clustering, spectral clustering, and median segmentation quantization.
3. The method for vectorizing Thangka color images based on a differentiable renderer as described in claim 2, characterized in that, The k-means clustering of the color Thangka raster image specifically includes: Multiple pixels are randomly selected from all pixels in the color Thangka raster image as initial cluster centers, wherein the number of initial color cluster centers is equal to the number of preset color clusters; For each pixel in the color Thangka raster image, calculate the Euclidean distance between each pixel and each initial cluster center, and assign the current pixel to the color cluster that is closest to the current pixel. For each color cluster in the color Thangka raster image, the color cluster center of the corresponding color cluster is recalculated based on the pixels contained in each color cluster. The color cluster center is repeatedly iterated until the update magnitude of all color cluster centers is less than a preset threshold. The multiple color cluster centers obtained at the end of the iteration are used as the color quantization result, and each pixel in the color Thangka raster image is mapped to the color cluster center corresponding to the pixel to complete the color quantization.
4. The method for vectorizing Thangka color images based on a differentiable renderer as described in claim 2, characterized in that, The DBSCAN clustering of the color Thangka raster image specifically includes: All pixels of the color Thangka raster image are added to the unvisited point set, and one unvisited point is selected from the unvisited point set in turn; The unvisited points are marked as visited points, and the neighborhood point set of the visited points within a preset radius is calculated, wherein the neighborhood point set includes multiple pixels. If the number of pixels in the neighborhood point set is greater than or equal to the minimum number of samples, then the visited point and all pixels in the neighborhood point set corresponding to the visited point are used as initial members to generate an initial color cluster. The initial color cluster is iterated until the number of pixels in the initial color cluster no longer increases, then the initial color cluster is identified as the target color cluster; Until all unvisited points in the set of unvisited points have been visited, the average RGB value of all pixels in each target color cluster is determined as the center color of the color cluster, and the color of each pixel in the color Thangka raster image is replaced with the color of the target color cluster to which the pixel belongs, so as to complete the color quantization.
5. The method for vectorizing Thangka color images based on a differentiable renderer as described in claim 2, characterized in that, The spectral clustering of the color Thangka raster image specifically includes: Based on all pixels in the color Thangka raster image, calculate the degree matrix and similarity matrix corresponding to the color Thangka raster image respectively; Based on the degree matrix and the similarity matrix, a Laplacian matrix is constructed, and the Laplacian matrix is standardized to obtain a standardized Laplacian matrix. The normalized Laplacian matrix is subjected to eigenvalue decomposition. From all the eigenvalues and eigenvectors corresponding to the eigenvalues obtained by the decomposition of the normalized Laplacian matrix, multiple standard eigenvalues and eigenvectors corresponding to the standard eigenvalues are selected. The number of standard eigenvalues is equal to the number of preset color clusters. The standard eigenvalues are combined column-wise to form a first standard matrix, and each row of the first standard matrix is standardized to obtain a second standard matrix. The row vectors of the second standard matrix are clustered based on the k-means algorithm to obtain the divided color clusters. The average RGB value of all pixels in each color cluster is calculated and the average RGB value is used as the center color of the color cluster. The color of each pixel in the color Thangka raster image is replaced with the center color of the color cluster to which the pixel belongs, so as to complete the color quantization.
6. The method for vectorizing Thangka color images based on a differentiable renderer as described in claim 1, characterized in that, The median segmentation and quantization of the color Thangka raster image specifically includes: The RGB color values corresponding to all pixels in the color Thangka raster image are used as the initial color set, and the boundary range of the initial color set in the RGB three-dimensional space is calculated. Select the channel axis with the largest span among the R, G, and B channels, sort all color values in the initial color set along the selected channel axis, and divide the initial color set into a first color subset and a second color subset according to a preset median along the selected channel axis. The first color subset and the second color subset are iterated successively until multiple target color subsets are obtained, wherein the number of target color subsets is equal to the number of preset color clusters; Calculate the representative color for each target color subset, and replace the color value of each pixel in the color Thangka raster image with the representative color of the target color subset to which the pixel belongs, so as to complete color quantization. The representative color is the mean or median of all color values in the target color subset.
7. The method for vectorizing Thangka color images based on a differentiable renderer as described in claim 1, characterized in that, The loss function includes one or more of the following: reconstruction loss function, geometric loss function, ranking loss function, and simplified loss function.
8. A vectorization system for Thangka color images based on a differentiable renderer, characterized in that, The Thangka color image vectorization system (1) includes a color quantization module (11), a shape optimization module (12), and an image vectorization module (13), wherein, The color quantization module (11) is used to acquire the color Thangka raster image to be processed and to perform color quantization on the color Thangka raster image to obtain multiple color clusters corresponding to the color Thangka raster image; The shape optimization module (12) is used to perform pixel connectivity analysis on each color cluster to extract independent connected regions in each color cluster, calculate the centroid and area of the independent connected regions, generate Bézier curves corresponding to the independent connected regions based on the centroid and the diameter proportional to the area, integrate the Bézier curves corresponding to all independent connected regions to obtain a set of Bézier curve shapes, and iteratively optimize the geometric parameters and color parameters of each Bézier curve in the set of Bézier curve shapes based on a differentiable renderer to obtain a set of optimized Bézier curve shapes. The image vectorization module (13) is used to sort the importance of the Bézier curve shape optimization set based on the loss function, and remove the curve with the lowest importance in the Bézier curve shape optimization set until the number of curves in the Bézier curve shape optimization set reaches a predetermined threshold, and output the target Bézier curve set to form a color Thangka raster vector image.
Citation Information
Patent Citations
A vectorization method of thangka elements based on diffusion curve
CN113706648B
