A fast method for generating directional word clouds with shape constraints
By extracting the outer contour points of the figure to generate the central axis and direction field, guiding the position and direction of word placement, the problem of inefficiency and inconsistent word placement in the existing technology is solved, and the rapid generation of direction word clouds with shape constraints is achieved, and the visual effect is improved.
Patent Information
- Application Number
- CN202110254596.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-09
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2041-03-09
AI Technical Summary
The existing word cloud generation method requires calculating the distance field to generate spiral lines, resulting in inefficiency, and the direction of word placement cannot match the texture of the figure.
By extracting the outer contour points of the figure to generate the central axis, intelligent pruning is performed to obtain the main feature skeleton of the figure, solve the direction constraint points of the outer contour, and use the central axis and direction field interpolation technology to generate the direction field to guide the position and direction of the word placement.
It realizes rapid generation of spiral lines that do not rely on distance fields. The direction of word placement can match the texture characteristics of the figure, improving the visual effect.
Smart Images

Figure CN113033184B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of computer data visualization, and in particular to a method for quickly generating a directional word cloud constrained by a surface shape. Background Art
[0002] With the explosion of "big data", visualization application technology has also received increasing attention, and using visualization technology to display and analyze big data has become mainstream. Word cloud, or tag cloud, as a visualization tool has appeared more frequently in different applications. As a form of display and analysis tool for text analysis results, word cloud uses font size as a symbol of word importance. Relatively important words gain high attention with their larger space occupancy.
[0003] Although existing word cloud layout methods can achieve compact word clouds based on shape constraints within a specific shape, it is time-consuming because it is necessary to calculate the distance field of the graph and use the spiral generated by the distance field to guide the placement of words. Furthermore, the placement directions of words are only horizontal and vertical, which do not match the shape of the graph in terms of direction. Summary of the invention
[0004] The present invention provides a method for quickly generating a directional word cloud with shape constraints, aiming to solve the problems of low efficiency of the existing tag cloud generation method when it needs to calculate a distance field to generate a spiral line to guide the placement of words, and the direction of the placement of the generated tag cloud words cannot match the texture of the graphic.
[0005] The technical solution provided by the present invention includes:
[0006] Step a: extract the outer contour points of the figure, and generate the central axis of the figure according to the outer contour polygon of the figure;
[0007] Step b: Perform intelligent pruning of the central axis to obtain a skeleton that reflects the most important features of the figure;
[0008] Step c: solving the direction constraint points of the outer contour according to the pruned central axis;
[0009] Step d: Taking the direction of the central axis after pruning and the constraint direction of the corresponding outer contour point as known directions, interpolate the direction field of the entire figure;
[0010] Step e: Guide the position and direction of word placement according to the central axis and direction field.
[0011] The technical solution of the present invention also includes: in the step a, the central axis of the figure is generated according to the outer contour polygon of the figure, the outer contour points of the image are extracted and discretized into polygons by image processing methods, and the central axis of the entire figure is generated by solving the angle bisectors at the convex points of the contour polygon and the equidistant parabolas between the concave points and the angle bisectors of the convex points.
[0012] The technical solution of the present invention also includes: in the step b, the intelligent pruning of the central axis includes preliminary pruning and secondary pruning. In preliminary pruning, the first layer of the central axis of the tree structure is deleted from the complete central axis; the distances between the adjacent leaf nodes of the central axis are calculated and grouped according to the distances, and the outer contour vertices represented by each group of leaf nodes are fitted with circles. If the distances between these points and the fitting circle are small, they are merged, and the average position of the coordinates of the group of leaf nodes is calculated. The projection point of this position to the outer frame is the new leaf node after the group of nodes is merged; in secondary pruning, branches with large gradient changes on the central axis are deleted, and the central axis with a distance field greater than a threshold and an inclination angle greater than 45 degrees on the central axis is deleted.
[0013] The technology of the present invention also includes: in the step d, the direction field generation technology in the entire graphic uses the direction of the central axis after pruning and the tangential direction of the direction constraint point on the contour as the constraint direction, and uses the 2 rotational symmetric field interpolation technology to generate the direction at each point in the entire graphic.
[0014] Beneficial effects of the present invention:
[0015] The present invention does not need to calculate the distance field of the graphic to generate the spiral line of the graphic, but only needs to determine the direction of the next point under the spiral line according to the area divided by the central axis to generate the spiral line, thereby solving the problem of low efficiency when the existing tag cloud generation method needs to calculate the distance field to generate the spiral line to guide the placement of words. Moreover, because the central axis of the graphic is generated according to the outer contour of the graphic, the pruned central axis reflects the main features of the graphic, so the direction of placement of the tag cloud words generated by the technical solution can fit the characteristics of the texture of the graphic, can reflect the main features of the graphic, and is more beautiful in visual effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solution in the present invention, a brief description of the technology in the present invention is given below using the accompanying drawings, which will give people in the field a clearer understanding of the performance of the technology.
[0017] Figure 1 This is a flow chart of a technology for quickly generating a directional word cloud with shape constraints in the present invention.
[0018] Figure 2 A schematic diagram of the central axis of a graphic of a shape-constrained directional word cloud rapid generation technology in the present invention.
[0019] Figure 3 This is a schematic diagram of the first layer effect of deleting the tree structure from the central axis of a shape-constrained directional word cloud rapid generation technology in the present invention.
[0020] Figure 4This is a schematic diagram of the preliminary pruning effect of the central axis of a shape-constrained directional word cloud rapid generation technology in the present invention.
[0021] Figure 5 This is a schematic diagram of the secondary pruning effect of a shape-constrained directional word cloud rapid generation technology in the present invention.
[0022] Figure 6 A schematic diagram of a graphic direction field of a shape-constrained direction word cloud rapid generation technology in the present invention.
[0023] Figure 7 This is a demonstration of the word cloud layout effect of a shape-constrained directional word cloud rapid generation technology in the present invention. DETAILED DESCRIPTION
[0024] In order to further explain the present invention in detail, specific examples are described below with reference to the accompanying drawings.
[0025] refer to Figure 1 , Figure 1 This is a flow chart of a method for quickly generating a directional word cloud with shape constraints in the present invention, and the process includes:
[0026] The outer contour points of the image are extracted to generate the central axis of the image, the central axis is preliminarily pruned, the central axis is pruned again, and the direction field of the graphic is generated. The position and direction of the word are guided according to the initial central axis and direction field.
[0027] Among them, generating the central axis of the figure based on the outer contour polygon of the figure reveals the shape characteristics of the figure; pruning the central axis reveals the most important texture characteristics of the figure; solving the outer border constraint points reveals which outer border features of the figure need to be retained; interpolating the direction field of the entire figure reveals the texture trend characteristics of the entire figure; the central axis and direction field guide the position and direction of word placement, revealing the word placement rules.
[0028] Extract outer contour points from images: Input an image, use image processing methods to extract the outer contour points of the image and discretize them into polygons.
[0029] Generate the central axis of the image: Generate the central axis of the entire figure by solving the angle bisectors at the convex points of the contour polygon and the equidistant parabolas between the concave points and the angle bisectors of the convex points. Figure 2 It is the complete central axis of the figure.
[0030] Initial pruning center axis: Figure 2 On the basis of the complete central axis, delete the first layer of the tree structure, such as Figure 3Calculate the distance between the adjacent leaf nodes of the central axis and group them according to the distance. Fit the circle to the outer contour vertices represented by each group of leaf nodes. If the distance between these points and the fitting circle is small, merge them and calculate the average position of the coordinates of the group of leaf nodes. The projection point of this position to the outer frame is the new leaf node after the group of nodes is merged. The result is as follows Figure 4 shown.
[0031] Secondary pruning of the central axis: Starting from the leaf nodes of the central axis obtained in the previous step, select a series of equidistant scattered points along the central axis, draw vertical lines perpendicular to the central axis at these discrete points to intersect the contour of the figure, calculate the length L between the two intersection points of each vertical line with the contour, and calculate the change rate between the lengths L of two adjacent vertical lines in turn. When the change rate is greater than a given threshold, delete the central axis from this discrete point to the parent node of the branch; finally, delete the central axis with a distance field value greater than a certain threshold and a deflection angle greater than 45 degrees. So far, a graphic skeleton that can roughly depict the main features of the figure is obtained, such as Figure 5 shown.
[0032] Generate the direction field of the graph: based on Figure 5 The pruned central axis is obtained to solve the direction constraint points on the outer contour polygon. The specific principle is to select appropriate vertices so that their tangent directions are consistent with the direction of the central axis. These vertices are selected through the following steps:
[0033] Step 1: For any two visible vertices i and j of the outer contour, calculate
[0034]
[0035] a ij is the angle between the normals at two points.
[0036] Step 2: For any two visible vertices i and j of the outer contour, calculate
[0037]
[0038] d ij is the distance between point i and point j, d min is the shortest distance between all visible points, σ d =10.
[0039] Step 3: Calculation
[0040] w ij =F a (a ij )*F d (d ij )
[0041] Step 4: Minimize the following formula to solve the label value l of each point i on the outer border i , l i =1 means that the point is selected as the direction constraint point. W is the contour point corresponding to the central axis retained after clipping, cosθ is the angle between the tangent direction at the outer contour point and the central axis direction corresponding to the point, and k1, k2 are weights:
[0042]
[0043] Direction field generation technology in the entire graphic: The direction of the central axis after pruning and the tangent direction of the direction constraint point on the contour are used as the constraint direction, and the 2-rotational symmetric field interpolation technology is used to generate the direction of each point in the entire graphic. The specific steps are as follows:
[0044] Step 1: Triangulate the contour figure and input the triangulated coordinates and directions;
[0045] Step 2: Optimize the direction R of each vertex i after triangulation i , R′ is the direction of the point marked as 1 on the boundary and the point on the skeleton, and E is the set of all edges of the triangular mesh after triangulation.
[0046]
[0047]
[0048] Step 3: Use OpenGL's fragment interpolation to convert the direction R obtained in step 2 i Interpolate the direction field at each pixel in the entire graph, such as Figure 6 shown.
[0049] Guide the position and direction of words based on the initial central axis and direction field:
[0050] Step 1: Generate a spiral line based on the uncut central axis: The central axis divides the figure into multiple regions. These regions are divided into two categories. One category of regions contains a concave point of the outer contour. The direction of the distance field gradient at any point in such regions is the direction from this point to the concave point. The other category of regions contains an edge of the outer contour polygon. The direction of the distance field gradient at any point in such regions is the direction perpendicular to this contour edge. The spiral line is generated step by step from the center of the figure until the spiral line position exceeds the figure area. The formula for gradually generating the spiral line is as follows:
[0051]
[0052] Where N and T are the normal and tangent directions of the distance field, and dθ is the angle of each step. m is a constant set by the user. Since the normal N and tangent T in each area divided by the central axis can be quickly obtained, the spiral can be generated quickly.
[0053] Step 2: Use the spiral line to guide word placement. Extract keywords from the text and sort them according to their frequency of occurrence. Place words along the spiral line from large to small. The direction is the direction field of the point in the figure calculated above. When placing words, use ABB collision detection to quickly determine whether the current position has been placed. See Figure 7 .
[0054] In summary, the technical features of the present invention are: First, the existing word cloud layout method generates the spiral line of the graphic according to the graphic distance field, and the feature of the present invention is that the central axis of the graphic is generated by extracting the outer contour points of the graphic, and the direction of the spiral line is guided by the area divided by the central axis. Second, the existing word cloud layout method only allows words to be placed horizontally or vertically. Although the words are placed based on shape constraints, the direction of the words cannot be placed according to the texture of the graphic. The present invention can make the direction of word placement match the graphic texture characteristics by extracting the central axis.
Claims
1. A method for quickly generating a directional word cloud with shape constraints, characterized in that The method comprises the following steps: Step a: extract the outer contour points of the figure, and generate the central axis of the figure according to the outer contour polygon of the figure; Step b: Perform intelligent pruning of the central axis to obtain a skeleton that reflects the most important features of the figure; Step c: solving the direction constraint points of the outer contour according to the pruned central axis; Step d: Taking the direction of the central axis after pruning and the constraint direction of the corresponding outer contour point as known directions, interpolate the direction field of the entire figure; Step e: guiding the position and direction of word placement according to the central axis and the direction field; In the step a, the outer contour points of the image are extracted by image processing method and discretized into polygons, and the central axis of the entire figure is generated by solving the angle bisectors at the convex points of the contour polygon and the equidistant parabolas between the concave points and the convex point angle bisectors; In the step b, the intelligent pruning of the central axis includes primary pruning and secondary pruning; The preliminary pruning is to delete the first layer of the central axis of the tree structure on the complete central axis; calculate the distance between the adjacent leaf nodes of the central axis and group them according to the distance, and perform fitting circle calculation on the outer contour vertices represented by each group of leaf nodes. If the distance between these points and the fitting circle is less than a first threshold, they are merged, and the average position of the coordinates of the group of leaf nodes is calculated. The projection point of the average position to the outer frame is the new leaf node after the group of nodes is merged; The secondary pruning deletes branches whose central axis gradient change rate is greater than a second threshold, and deletes central axes whose distance fields are greater than a third threshold and whose inclination angles are greater than 45 degrees. In step d, the direction field generation technology in the entire graphic uses the direction of the central axis after pruning and the tangential direction of the direction constraint point on the contour as the constraint direction, and uses the 2-rotational symmetric field interpolation technology to generate the direction of each point in the entire graphic.
Citation Information
Patent Citations
Active contour method based on shape constraint and direction field, and system thereof
CN101833750A
Word cloud generation method and device
CN106469138A