Graphics morphology recognition method, graphics edge optimization method and system

Through graphic form recognition and expansion filling technology, the image processing problem of elongated or pixel blocks in pictures is solved, reducing the difficulty of small graphics and sharp details in lettering machines or painting machines, and achieving smoothing of the edges of the graphics.

CN118570285BActive Publication Date: 2024-12-06HUNAN SIJIU TECH CO LTD

Patent Information

Application Number
CN202411060377.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-05
Publication Date
2024-12-06
Estimated Expiration
2044-08-05

AI Technical Summary

Technical Problem

The prior art is difficult to process images with elongated or protruding pixel blocks in pictures, resulting in increased difficulty and recognition difficulties in engraving and painting processes in a lettering machine or a painting machine.

Method used

Through the graphic morphology recognition method, the pixel sets of elongated or convex edges in the image are identified and judged, and they are optimized using expansion filling operations to smooth the graphic edges, and the expansion processing and ring filling are combined with the nine-grid structure.

Benefits of technology

It reduces the difficulty of processing small and sharp graphics in a lettering machine or painting machine, improves the smoothness of the edges of the graphics, reduces the difficulty of operation, and does not affect the aesthetics of the graphics.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570285B_ABST
    Figure CN118570285B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of graphic edge processing technology, and in particular to a graphic morphology recognition method, a graphic edge optimization method and a system, wherein the graphic morphology recognition method comprises the steps of: performing pixel set recognition, including: traversing the pixel points in the image, classifying each pixel point according to color and establishing a pixel set of a single color, so as to divide the same color blocks in the image that are the same and connected into a single graphic; judging the morphology of the pixel set, including: judging whether it meets the conditions for performing special-shaped graphic processing, and finding a pixel set that meets the conditions; the conditions include that the morphology of the pixel set is slender or has a convex edge or a concave edge. The graphic edge optimization method and system perform expansion and filling operations on the graphics corresponding to the pixel set identified by the graphic morphology recognition method. The present invention can perform smooth optimization on sharper long strip graphics and parts with more convex and concave edges.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of graphic edge processing technology, and in particular to a graphic morphology recognition method, a graphic edge optimization method and a system. Background Art

[0002] When processing images, after color reduction and color aggregation, some thin and long images or protruding pixel blocks exist. Although these images are part of the information contained in the original image and can better reproduce the shape details of the original image, in some scenes that require color normalization and physical reproduction of color blocks, such as engraving machines and painting machines, these thin and long images or protruding pixel blocks will increase the difficulty of processing and reproduction.

[0003] In order to make the edges of graphics smoother, reduce image details and reduce the difficulty of physical processing, graphics that do not meet the requirements need to be further processed to solve the problem of difficulty in engraving and user recognition caused by very small graphics and sharp details during engraving and painting by engraving machines or painting machines. Summary of the invention

[0004] 1. Technical issues to be resolved

[0005] In view of the above-mentioned shortcomings and deficiencies of the prior art, the present invention provides a graphic morphology recognition method, a graphic edge optimization method and a system, which solve the technical problems of how to identify images with partially slender parts or protruding pixel blocks in pictures, and how to smooth images with very small graphics and relatively sharp details in pictures.

[0006] (II) Technical solution

[0007] In order to achieve the above object, the main technical solutions adopted by the present invention include:

[0008] In a first aspect, an embodiment of the present invention provides a method for identifying a graphic form, comprising the following steps:

[0009] Perform pixel set recognition, including: traversing the pixel points in the image, classifying each pixel point according to color and establishing a pixel set of a single color, so as to divide the same color blocks in the image that are the same and connected into a single graphic;

[0010] Determining the morphology of a pixel set includes: determining whether the pixel set meets the conditions for performing special-shaped graphics processing according to the morphological characteristics of the pixel set, and finding a pixel set that meets the conditions; the conditions for performing special-shaped graphics processing include that the pixel set is slender or has protruding edges or concave edges.

[0011] The graphic morphology recognition method provided in the embodiment of the present invention can recognize relatively sharp long strip graphics, as well as relatively convex and concave parts inside the graphics and at the edges of the graphics.

[0012] Optionally, judging whether the condition for performing special-shaped graphics processing is met according to the morphological features of the pixel set is performed according to the following rules:

[0013] Get the number of pixels on the edge of the pixel set , the total number of pixels in the pixel set , calculate the ratio of the two as the shape value:

[0014] ;

[0015] The coordinates of the top pixel of the image are , the coordinates of the bottom pixel are , the coordinates of the leftmost pixel of the image are , the coordinates of the rightmost pixel are ; Calculate the upper and lower span values ​​of the graphics corresponding to the pixel set and left and right span values :

[0016] ;

[0017] ;

[0018] Get the coefficients of the graph :

[0019] ;

[0020] If the coefficients of the graph , which is less than the threshold of the graphics coefficient set , it is considered to meet the conditions for special-shaped graphics processing.

[0021] Threshold of graphics coefficients , calculated by the following formula: ;

[0022] Among them, Image.Cols is the height of the graphic, Image.Rows represents the width of the graphic, a is the middle value, and the value range of a is [0.0001, 0.001].

[0023] In a second aspect, an embodiment of the present invention provides a method for optimizing a graphic edge using the above-mentioned graphic morphology recognition method, comprising the following steps:

[0024] The above-mentioned graphic morphology recognition method is used to identify the pixel set that needs to be processed for special-shaped graphics;

[0025] The graphics corresponding to the pixel set are expanded and filled, including: using a structure to expand the edge of the graphics corresponding to the pixel set that meets the conditions, and performing annular filling on the newly generated target pixels around the expanded graphics.

[0026] The graphic edge optimization method proposed in the embodiment of the present invention can optimize sharp long strip graphics, as well as the protruding and concave parts inside and on the edges of graphics, and merge them with the surrounding graphics to smooth the edges of each graphic, thereby solving the problem of difficulty in engraving and user recognition caused by very small graphics and sharp details during the engraving and painting process of a plotter or a painting machine. The operation difficulty of the engraving and painting process of a plotter or a painting machine is reduced without affecting the beauty of the graphics.

[0027] Optionally, using a structure to dilate the edges of the set of pixels that meet the conditions, comprises the following steps:

[0028] Using a structure of a nine-square grid, the edges of each qualified pixel set are expanded separately, the central grid of the nine-square grid structure is overlapped and pushed along the edge of the graphic corresponding to the pixel set, and the edge of the graphic corresponding to each pixel set is expanded outward to a pixel block with a width of at least one sub-grid of the nine-square grid.

[0029] Optionally, performing annular filling on the newly generated target pixels around the expanded graphic includes the following steps:

[0030] Selecting a region to be filled from the newly generated target pixels around the expansion, at least one pixel block among eight pixel blocks around each pixel block in the region to be filled is not generated by the expansion;

[0031] Calculate the RGB mean of the pixel blocks that are not generated by expansion around each pixel block to be filled in the area to be filled, find the pixel block with the smallest difference between the RGB value and the RGB mean among the pixel blocks that are not generated by expansion around the pixel block to be filled as the reference pixel block, and fill the pixel block to be filled with the RGB value of the reference pixel block.

[0032] Optionally, when more than one reference pixel blocks are found and have different RGB values, pixel blocks with higher rankings are preferentially selected as reference pixel blocks according to the priority order of each sub-grid in the set nine-grid.

[0033] Optionally, the method further includes iterating the ring filling for more than two times until there is no pixel set in the image that needs to be processed with a special-shaped graphic, thereby completing the graphic edge optimization.

[0034] Optionally, the size of the structure is selected according to the following Table 1:

[0035] Table 1

[0036] .

[0037] Structures of different sizes can be expanded with different processing structures (3x3\5x5\7x7, etc.), which can achieve different degrees of expansion effects, so that the more convex and concave parts inside and around the graphics can be smoothed with different resolutions.

[0038] In a third aspect, an embodiment of the present invention provides a graphics edge optimization system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the above methods when executing the computer program.

[0039] (III) Beneficial effects

[0040] The beneficial effects of the present invention are as follows: the graphic morphology recognition method, graphic edge optimization method and system of the present invention can recognize and optimize relatively sharp long strip graphics, as well as relatively convex and concave parts inside and on the edges of graphics, and merge them with surrounding graphics to smooth the edges of each graphic, thereby solving the problem of difficulty in engraving and difficulty in user recognition caused by very small graphics and relatively sharp details during the engraving and painting process of a plotter or a painting machine. The operation difficulty of the engraving and painting process of a plotter or a painting machine can be reduced without affecting the beauty of the graphics. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 Schematic diagram of the flow of the graphic morphology recognition method according to the preferred embodiment 1 of the present invention;

[0042] Figure 2 Schematic diagram of the process of color reduction and noise processing in the preferred embodiment 1 of the present invention;

[0043] Figure 3 This is a flow chart of determining whether the conditions for performing special-shaped graphics processing are met according to the preferred embodiment 1 of the present invention;

[0044] Figure 4 This is an example graph of morphological recognition of a pixel set according to a preferred embodiment 1 of the present invention;

[0045] Figure 5 Schematic diagram of the flow of the method for optimizing the edge of a graphic according to the second preferred embodiment of the present invention;

[0046] Figure 6 A schematic diagram of the expansion of a structure of a first size according to a preferred embodiment 2 of the present invention;

[0047] Figure 7 A schematic diagram of the expansion of a structure of a second size according to a preferred embodiment 2 of the present invention;

[0048] Figure 8 It is a schematic diagram of the expansion of a structure of the third size according to the preferred embodiment 2 of the present invention;

[0049] Fig. 9 This is a schematic diagram of expanding the upper left corner gray pixel set and judging the filled color block in the preferred embodiment 3 of the present invention;

[0050] Fig.10 This is a schematic diagram of expanding the central gray pixel set and judging the filling of the filled color block in the preferred embodiment 3 of the present invention;

[0051] Fig.11 This is a schematic diagram of expanding the central white pixel set and judging the filling of the filled color block in the preferred embodiment 3 of the present invention;

[0052] Fig.12 A schematic diagram of determining an area that needs to be filled in accordance with a preferred embodiment 3 of the present invention;

[0053] Fig.13 This is a schematic diagram of the priority sorting of the nine-grid according to the preferred embodiment 3 of the present invention;

[0054] Fig.14 This is a schematic diagram of the first round of annular filling completed and the second round of pixel blocks to be filled in the preferred embodiment 3 of the present invention;

[0055] Fig.15 Schematic diagram of the second round of annular filling completed and the third round of pixel blocks to be filled in the preferred embodiment 3 of the present invention

[0056] Fig.16 It is a schematic diagram comparing the graphics before the annular filling and the graphics after the third round of annular filling in the preferred embodiment 3 of the present invention. DETAILED DESCRIPTION

[0057] In order to better explain the present invention and facilitate understanding, the present invention is described in detail below through specific implementation modes in conjunction with the accompanying drawings.

[0058] The graphic morphology recognition method, graphic edge optimization method and system proposed in the embodiments of the present invention can recognize and optimize relatively sharp long strip graphics, as well as relatively convex and concave parts inside and on the edges of graphics, and merge them with the surrounding graphics to smooth the edges of each graphic, thereby solving the problem of difficulty in engraving and difficulty in user recognition caused by very small graphics and relatively sharp details during the engraving and painting process of a plotter or a painting machine. The difficulty of operating the engraving and painting process of a plotter or a painting machine can be reduced without affecting the aesthetics of the graphics.

[0059] In order to better understand the above technical solution, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to enable a clearer and more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art.

[0060] Example 1

[0061] Figure 1 FIG. 1 is a flow chart of a method for recognizing a graphic form in Embodiment 1 of the present invention. Figure 1 The graphic morphology recognition method of the embodiment of the present invention comprises the following steps:

[0062] The image is first subjected to color reduction and noise processing. The color reduction and noise processing in this embodiment can adopt the common processing method in the prior art, or can also use Figure 2 's processing method.

[0063] Pixel set recognition includes: traversing the pixel points in the image, classifying each pixel point according to color and establishing a pixel set of a single color, so as to divide the same color blocks in the image that are connected and have the same color into a single figure. During traversal, a pixel set of a single color is established with the traversed pixel point (x, y) as the starting point.

[0064] Determining the morphology of a pixel set includes: determining whether the pixel set meets the conditions for performing special-shaped graphics processing according to the morphological characteristics of the pixel set, and finding a pixel set that meets the conditions; the conditions for performing special-shaped graphics processing include that the pixel set is slender or has protruding edges or concave edges.

[0065] In this embodiment, the following method is used to find a pixel set that meets the conditions:

[0066] See also Figure 3 , according to the morphological characteristics of the pixel set, determine whether it meets the conditions for special-shaped graphics processing, and proceed according to the following rules:

[0067] Get the number of pixels on the edge of the pixel set , the total number of pixels in the pixel set , calculate the ratio of the two as the shape value: .

[0068] See also Figure 4 , the coordinates of the top pixel of the image are , the coordinates of the bottom pixel are , the coordinates of the leftmost pixel of the image are , the coordinates of the rightmost pixel are ; Calculate the upper and lower span values ​​of the graphics corresponding to the pixel set and left and right span values : ;

[0069] ;

[0070] Get the coefficients of the graph :

[0071] ;

[0072] If the coefficients of the graph (i.e. Proportion value), is less than the threshold of the set graphics coefficient , it is considered that the conditions for special-shaped graphics processing are met. Otherwise, no processing is required.

[0073] In this embodiment, the threshold value of the graphic coefficient , calculated by the following formula: ;

[0074] Among them, Image.Cols is the height of the image, Image.Rows represents the width of the image, a is the middle value, and the value range of a is [0.0001, 0.001]. Adjusting the value of a can modify the threshold as needed. In this embodiment, the preferred value of a is 0.0005.

[0075] The pattern recognition method proposed in the embodiment of the present invention can recognize relatively sharp long strip patterns, as well as relatively convex and concave parts inside and at the edges of the patterns, so as to facilitate subsequent smoothing processing.

[0076] Example 2

[0077] See also Figure 5 The embodiment of the present invention provides a method for optimizing the edge of a graphic using the method for recognizing the graphic form of the above-mentioned embodiment 1, comprising the following steps:

[0078] The graphic morphology recognition method of Example 1 is used to identify the pixel set that needs to be processed for the special-shaped graphic; in order to make the expanded graphic undergo a smaller deformation while removing noise and smoothing, and to further improve the overall optimization effect of the image, a ring filling algorithm is required for the newly generated target pixels around the expanded graphic.

[0079] The graphics corresponding to the pixel set are expanded and filled, including: using a structure to expand the edge of the graphics corresponding to the pixel set that meets the conditions, and performing annular filling on the newly generated target pixels around the expanded graphics.

[0080] Through these steps, the sharp long strip graphics, as well as the protruding and concave parts inside and on the edges of the graphics can be optimized and merged with the surrounding graphics to make the edges of each graphic smooth, solving the problem of difficulty in engraving and user recognition caused by very small graphics and sharp details during the engraving and painting process of the engraving machine or the painting machine. The operation difficulty of the engraving and painting process of the engraving machine or the painting machine is reduced without affecting the beauty of the graphics.

[0081] In this embodiment, see Figures 6 to 8 , respectively using a first size (6*6), a second size (3*3) or a third size (5*5) structure to dilate the edge of a pixel set that meets the conditions, including the steps of: using a structure of a nine-square grid structure to dilate the edge of each pixel set that meets the conditions, overlapping and advancing the center grid of the nine-square grid structure along the edge of a graphic corresponding to the pixel set, and dilating the edge of the graphic corresponding to each pixel set outward by a pixel block with a width of at least one sub-grid of the nine-square grid.

[0082] The larger the size of the picture, the larger the structure is used to achieve the desired effect. The size of the structure is selected based on the user's choice. In this embodiment, some reference size suggestions are given, see Table 1.

[0083] Structures of different sizes can be expanded with different processing structures (3x3\5x5\6x6, etc.), which can achieve different degrees of expansion effects, so that the more convex and concave parts inside and around the graphics can be smoothed with different resolutions.

[0084] See also Fig. 9 In this embodiment, the newly generated target pixels around the expanded graphic are annularly filled, including the following steps:

[0085] Selecting a region to be filled from the newly generated target pixels around the expansion, at least one pixel block among eight pixel blocks around each pixel block in the region to be filled is not generated by the expansion;

[0086] Calculate the RGB mean of the pixel blocks that are not generated by expansion around each pixel block to be filled in the area to be filled, find the pixel block with the smallest difference between the RGB value and the RGB mean among the pixel blocks that are not generated by expansion around the pixel block to be filled as the reference pixel block, and fill the pixel block to be filled with the RGB value of the reference pixel block.

[0087] Judgment method:

[0088]

[0089]

[0090] in, , , is the target pixel to be calculated , The number of black pixels generated by non-dilation that are adjacent to the target pixel is extracted Value recorded. Calculated , , Calculate again: R1…R n is the R value of all pixel blocks around the pixel block to be filled that are not generated by dilation; G1…G n is the G value of all pixel blocks around the pixel block to be filled that are not generated by dilation; B1…B n is the B value of all pixel blocks around the pixel block to be filled that are not generated by dilation.

[0091] The sum of the RGB differences is obtained, and the RGB value of RGBn (RGBn is the RGB value of the nth pixel block) with the smallest difference is taken as the value of the target pixel.

[0092] + ;

[0093] The above formula is used to calculate the difference between the RGB value of the first pixel block and the RGB value of the reference pixel block. The above formulas are used to calculate in sequence to find the pixel block with the smallest difference.

[0094] When more than one reference pixel blocks are found and their RGB values ​​are different, the pixel blocks with the highest order are preferentially selected as reference pixel blocks according to the priority order of each sub-grid in the set nine-grid.

[0095] During implementation, the annular filling is iterated for more than two times until there is no pixel set in the image that needs to be processed with a special-shaped graphic, and the graphic edge optimization is completed.

[0096] Example 3

[0097] In this embodiment, a 16x16 image is used to expand and fill a 3*3 structure. The image has only two colors and by default both need to be expanded and filled (in actual implementation, the image may have multiple colors and some graphics do not need to be expanded and filled, and the specific situation can be used by analogy).

[0098] Inflate the graph using a structure:

[0099] Expansion method: For the pixel set that needs to be expanded, traverse the pixel set, take each pixel point (x, y) as the origin, that is, the center grid of the nine-square grid structure in the structure block, and Figures 9 to 11 The middle is red.

[0100] The sub-grids of the nine-grid structure except the central grid within the range covered by its structure, Figures 9 to 11 The orange grid is expanded and filled with the color of (x, y). If the pixel set where the expanded pixel block is located needs to be filled and its original color is different from (x, y), then this pixel is defined as the part that needs to be filled again, that is, the pixel block to be filled (marked in light blue in this embodiment), such as Figures 9 to 11 The light blue part is indicated in the figure, and the light blue part is the part that needs to be filled again. At this point, the expansion process of the three connected pixel sets has been completed. Fig. 9 Schematic diagram of the expansion of the gray pixel set in the upper left corner and the filling judgment of the filled color block; Fig.10 Schematic diagram of dilation of the central gray pixel set and filling judgment of the filled color block; Fig.11 The left side of the three figures are before expansion, and the right side are after expansion.

[0101] Ring filling:

[0102] Traverse the image and find the pixel (x, y) that is light blue and the surrounding pixels (x-1, y), (x+1, y), (x, y-1), (x, y+1), (x-1, y+1), (x-1, y-1), (x+1, y-1), (x+1, y+1) are not light blue. Mark it as the area to be filled, which is light orange in this example.

[0103] See also Fig.12 ,The first round of judgments on the areas that need to be filled are marked as areas to be filled - light orange, such as Fig.12 As shown, the pixel blocks adjacent to the center of the area are taken, and the original pixel values ​​of the area to be filled are removed to determine the color that the pixel block needs to be filled with. The judgment method is the same as that of Example 2 and will not be repeated here. When calculating, Fig.12 The light blue pixel block in the figure is not involved in the above calculation because it is just a marked pixel without color information (not belonging to the area to be filled).

[0104] In implementation, if there is only one color of pixels around the light orange pixel block, the color obtained will be the same as this color no matter how many times the calculation is performed. This calculation method can calculate the proportion of the surrounding pixel colors by averaging and select the color with the largest number of pixels of the same color, making the color filling transition more natural.

[0105] If the number of pixel blocks of different colors is the same, then Fig.13The priority order is shown. That is, the pixel block corresponding to the upper left corner of the sub-grid is the pixel block with the highest priority, and the priority order is arranged in a clockwise decreasing direction. When implemented, the priority order can also be arranged in the opposite direction or in other specified directions. Compared with the random filling method, this filling method can prevent the deformation of the figure and the emergence of new protruding figures.

[0106] During implementation, multiple ring fillings can generally be used to achieve a better smoothing effect. In this embodiment, three ring fillings are used for iteration. Figures 14 to 16 Until there are no sharp figures or obvious protruding or concave features in the figure. Fig.16 As can be seen from the comparison diagram, the annular filling method of the embodiment of the present invention can make the edges of each graphic smooth, solving the problem of difficulty in engraving and user recognition caused by very small graphics and sharp details during the engraving and painting process of the engraving machine or the painting machine. It can reduce the difficulty of the operation of the engraving and painting process of the engraving machine or the painting machine, and does not affect the beauty of the graphics.

[0107] Example 4

[0108] An embodiment of the present invention provides a graphics edge optimization system, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of any of the above embodiments are implemented.

[0109] In the description of the present invention, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0110] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium; it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0111] In the present invention, unless otherwise clearly specified and limited, when a first feature is “on” or “below” a second feature, it may be that the first and second features are in direct contact, or that the first and second features are in indirect contact through an intermediate medium. Moreover, when a first feature is “above”, “above” or “above” a second feature, it may be that the first feature is directly above or obliquely above the second feature, or it may simply mean that the first feature is higher in level than the second feature. When a first feature is “below”, “below” or “below” a second feature, it may be that the first feature is directly below or obliquely below the second feature, or it may simply mean that the first feature is lower in level than the second feature.

[0112] In the description of this specification, the description of the terms "one embodiment", "some embodiments", "embodiment", "example", "specific example" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.

[0113] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may alter, modify, replace and modify the above embodiments within the scope of the present invention.

Claims

1. A method for pattern recognition, characterized in that: The following steps are involved: Perform pixel set recognition, including: traversing the pixel points in the image, classifying each pixel point according to color and establishing a pixel set of a single color, so as to divide the same color blocks in the image that are the same and connected into a single graphic; Determining the morphology of the pixel set includes: determining whether the pixel set meets the condition of needing to perform special-shaped graphic processing according to the morphological characteristics of the pixel set, and finding the pixel set that meets the condition; the condition of needing to perform special-shaped graphic processing includes that the morphology of the pixel set is elongated or has a convex edge or a concave edge; The process of judging whether the pixel set meets the conditions for performing special-shaped graphics processing based on the morphological characteristics of the pixel set is performed according to the following rules: Get the number of pixels on the edge of the pixel set , the total number of pixels in the pixel set , calculate the ratio of the two as the shape value: ; The coordinates of the top pixel of the image are , the coordinates of the bottom pixel are , the coordinates of the leftmost pixel of the image are , the coordinates of the rightmost pixel are ; Calculate the upper and lower span values ​​of the graphics corresponding to the pixel set and left and right span values : ; ; Get the coefficients of the graph : ; If the coefficients of the graph , which is less than the threshold of the graphics coefficient set , it is considered to meet the conditions for special-shaped graphics processing.

2. The method for pattern recognition according to claim 1, wherein: The threshold value of the graphic coefficient , calculated by the following formula: ; Among them, Image.Cols is the height of the graphic, Image.Rows represents the width of the graphic, a is the middle value, and the value range of a is [0.0001, 0.001].

3. A method for optimizing a graphics edge, characterized in that: The following steps are involved: Using the graphic morphology recognition method as described in any one of claims 1 to 2 to identify a pixel set that needs to be processed into a special-shaped graphic; The graphics corresponding to the pixel set are expanded and filled, including: using a structure to expand the edge of the graphics corresponding to the pixel set that meets the conditions, and performing annular filling on the newly generated target pixels around the expanded graphics.

4. The method for optimizing the edge of a graphic according to claim 3, wherein: The use of the structure to dilate the edge of the pixel set that meets the conditions includes the following steps: Using a structure of a nine-square grid, the edges of each qualified pixel set are expanded separately, the central grid of the nine-square grid structure is overlapped and pushed along the edge of the graphic corresponding to the pixel set, and the edge of the graphic corresponding to each pixel set is expanded outward to a pixel block with a width of at least one sub-grid of the nine-square grid.

5. The method for optimizing the edge of a graphic according to claim 4, wherein: The method of performing annular filling on the newly generated target pixels around the expanded graphic includes the following steps: Selecting a region to be filled from the newly generated target pixels around the expansion, wherein at least one pixel block among eight pixel blocks around each pixel block in the region to be filled is not generated by the expansion; Calculate the RGB mean of pixel blocks that are not generated by expansion around each pixel block to be filled in the area to be filled, find the pixel block with the smallest difference between the RGB value of the pixel blocks that are not generated by expansion around the pixel block to be filled and the RGB mean as the reference pixel block, and fill the pixel block to be filled with the RGB value of the reference pixel block.

6. The method for optimizing the edge of a graphic according to claim 5, wherein: When more than one reference pixel blocks are found and their RGB values ​​are different, the pixel blocks with the highest order are preferentially selected as reference pixel blocks according to the priority order of each sub-grid in the set nine-grid.

7. The method for optimizing the edge of a graphic according to claim 6, wherein: The method further includes iterating the ring filling for more than two times until there is no pixel set in the image that needs to be processed with a special-shaped graphic, thereby completing the graphic edge optimization.

8. The method for optimizing the edge of a graphic according to any one of claims 3 to 7, characterized in that: The size of the structure is selected according to the following table: 。 9. A graphics edge optimization system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 3 to 8 are implemented.

Citation Information

Patent Citations

  • Fast continuous edge extraction method for image

    CN106504263A

  • Method for realizing automatic and uniform filling processing of circular holes in graph in laser numerical control system

    CN110900019A

Cited By

  • Real-time interactive graph optimization design method

    CN121033211A