Linear chart generation method and device, electronic equipment, medium and product

Through edge detection and edge curve construction techniques, the sample dependence and quality instability problems in the existing linear graph generation methods are solved, and high-quality smooth linear graphs are generated, suitable for design of complex patterns.

CN119068076AActive Publication Date: 2024-12-03LINGDI (ZHEJIANG) TECHNOLOGY CO LTD
View PDF 12 Cites 0 Cited by

Patent Information

Application Number
CN202410509262.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-25
Publication Date
2024-12-03
Estimated Expiration
2044-04-25

AI Technical Summary

Technical Problem

The existing linear graph generation methods are based on style transfers of neural networks and deep learning. Affected by sample examples, there are problems such as lack of sample instances and unstable quality, making it difficult to effectively generate linear graphs of complex patterns.

Method used

By performing edge detection on the image, the contour points of the pattern are obtained, and the edge curve is constructed based on the selected points with the lowest generation value in the edge curve, a smooth and smooth line graph is generated, and the contour points with the lowest generation value are added to build the edge curve , ensure that adjacent points are close to each other and avoid large angle bends.

Benefits of technology

The quality of the linear graph is improved, making the generated pattern outline smoother and smoother, supporting further geometric calculation and editing operations, and meeting the user's pattern style needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119068076A_ABST
    Figure CN119068076A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a linear diagram generation method and device, electronic equipment, a medium and a product. The method comprises the steps that edge detection is carried out on an image, contour points of a pattern in the image are obtained, an edge curve in the image is constructed based on selected points in the contour points, the selected points are contour points which are located in a specified range of the edge curve and have the minimum cost value, and according to the edge curve, the contour points of the pattern in the image are obtained. And generating a linear diagram corresponding to the image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of clothing production technology, and in particular to a method, device, electronic device, medium and product for generating a line graph. Background Art

[0002] In modern society, the demand for pattern generation in the field of clothing production is increasing. As an important part of clothing design, patterns not only affect the beauty of clothing, but are also closely related to brand image, cultural heritage and other aspects.

[0003] In pattern generation, the line drawing of a pattern is usually used to express the outline, texture or structure of the pattern, which is a widely used pattern design method. However, in reality, manually drawing the outline of a pattern requires the designer to independently identify the outline of the pattern and draw the edge shape. If the pattern is complex, it will take a lot of time and energy. Today, when the digitization of clothing has become a development trend, using computer technology to generate line drawings corresponding to patterns has become an important focus.

[0004] The current line graph generation method is based on neural networks and deep learning style transfer to simulate the line graph of the generated pattern. However, this line graph generation method is affected by sample examples and has problems such as lack of sample examples and unstable quality that are difficult to solve. Summary of the invention

[0005] To overcome the problems existing in the related art, this specification provides a line graph generation method, device, electronic device, medium and product.

[0006] According to a first aspect of any embodiment of this specification, a line graph generation method is provided, the method comprising: Performing edge detection on the image to obtain contour points of the pattern in the image; constructing an edge curve in the image based on a selected point among the contour points, wherein the selected point is a contour point located within a specified range of the edge curve and having a minimum cost value; A line graph corresponding to the image is generated according to the edge curve.

[0007] According to a second aspect of any embodiment of this specification, there is provided a line graph generating device, the device comprising: A contour point acquisition module, used to perform edge detection on an image and acquire contour points of a pattern in the image; An edge curve construction module, used to construct an edge curve in an image based on a selected point among the contour points, wherein the selected point is a contour point located within a specified range of the edge curve and having a minimum cost value; A line graph generating module is used to generate a line graph corresponding to the image according to the edge curve.

[0008] According to a third aspect of any embodiment of this specification, there is provided an electronic device, including: processor; a memory for storing processor-executable instructions; The processor implements the method described in any embodiment of this specification by running the executable instructions.

[0009] According to a fourth aspect of any embodiment of the present specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method described in any embodiment of the present specification are implemented.

[0010] According to the fifth aspect of any embodiment of the present specification, there is provided a computer program product having a computer program / instruction stored thereon, which, when executed by a processor, implements the steps of the method described in any embodiment of the present specification.

[0011] The technical solutions provided by the embodiments of this specification may have the following beneficial effects: According to the above embodiments, by performing edge detection on the image, the contour points of the pattern in the image are obtained, and the edge curve of the image is constructed based on the selected points in the edge curve that are located within the specified range of the edge curve and have the smallest cost value. According to the edge curve, a line graph corresponding to the image is generated, and the edge curve is constructed by continuously adding contour points that are close to the edge curve and have the smallest cost value, so that adjacent contour points in the edge curve are close to each other and do not bend at large angles, thereby displaying a smooth and rounded edge curve in the generated line graph, improving the quality of the line graph corresponding to the pattern, and supporting users to further perform geometric calculations and other operations on the curves in the line graph to obtain the pattern style effect required by users.

[0012] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0014] Figure 1 is a flow chart of a method for generating a line graph according to an exemplary embodiment of the present specification; Figure 2 is a schematic diagram of an image with a pattern according to an exemplary embodiment of the present specification; Figure 3is a schematic diagram of a grayscale image for removing a transparent area according to an exemplary embodiment of this specification; Figure 4 is a schematic diagram of a contour point image shown in this specification according to an exemplary embodiment; Figure 5 is a schematic diagram of an edge skeleton image according to an exemplary embodiment of the present specification; Figure 6 is a flow chart of a method for reducing points on an edge curve according to an exemplary embodiment of the present specification; Figure 7 is a schematic diagram of a line graph shown in this specification according to an exemplary embodiment; Figure 8 is a flow chart of an edge detection method shown in this specification according to an exemplary embodiment; Fig. 9 is a flow chart of a method for constructing an edge curve according to an exemplary embodiment of the present specification; Fig.10 is a flow chart of another method for generating a line graph according to an exemplary embodiment of the present specification; Fig.11 is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present specification; Fig.12 It is a block diagram of a line graph generating device according to an exemplary embodiment of the present specification. DETAILED DESCRIPTION

[0015] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this specification. Instead, they are merely examples of devices and methods consistent with some aspects of this specification as detailed in the appended claims.

[0016] The terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit this specification. The singular forms "a", "the" and "the" used in this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0017] It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0018] At present, the common line graph generation method is based on style transfer of neural networks and deep learning to simulate and generate line graphs of patterns. However, this line graph generation method is affected by sample examples and has problems that are difficult to solve, such as lack of sample examples and unstable quality.

[0019] In order to solve the above problems, the embodiments of this specification propose a method for generating a line graph. To further illustrate this specification, the following embodiments are provided: See also Figure 1 , Figure 1 This is a flowchart of a line graph generation method according to an exemplary embodiment of the present specification. The line graph generation method can be applied to terminal devices such as computers and tablet computers, and the line graph generation method may include the following steps: Step 102: Perform edge detection on the image to obtain contour points of the pattern in the image.

[0020] In this step, the terminal device may receive an image to be converted into a line graph input by a user.

[0021] The terminal device uses edge detection methods such as adaptive Canny edge detection and differential edge detection methods to perform edge detection on the input image, obtain the edge corresponding to the pattern in the image, and obtain the contour points constituting the edge in the image.

[0022] The image may include one or more patterns, and the edge is the contour line that constitutes the pattern. The contour point refers to the pixel point that constitutes the edge corresponding to the pattern in the image, and the contour point is used to clearly define the contour shape of the pattern.

[0023] Furthermore, there may be opaque areas and transparent areas in the image. Before the terminal device performs edge detection on the image and obtains the contour points of the pattern in the image, it can binarize the image according to a preset intermediate value to remove the transparent areas in the image.

[0024] Specifically, the terminal device binarizes the pixels in the transparent area into completely transparent and completely opaque according to the intermediate value, and then sets all the pixels in the completely transparent area to the same 0, thereby removing the transparent area.

[0025] The middle value is the middle value of the pixel value range of the transparent channel. For example, when the pixel value range of the transparent channel is 0 to 255, the middle value is 128; when the pixel value range of the transparent channel is 0 to 1, the middle value is 0.5.

[0026] The terminal device performs grayscale conversion on the pixels in the image with the transparent area removed, converts the RGB (Red, Green, Blue, three primary colors) channel values ​​of the image into grayscale values, reduces the dimension of the color information in the image, and obtains the grayscale image corresponding to the image.

[0027] To further illustrate the removal of transparent areas and grayscale conversion, Figure 2 A schematic diagram showing an image with a pattern, Figure 2 The image 201 shown is a colorful picture with a pattern and a transparent channel input by a user and received by the terminal device.

[0028] Figure 3 A schematic diagram of a grayscale image with a transparent area removed is shown. The terminal device performs binary division on the image 201, sets the pixels of the transparent area 2011 to 0, and removes the transparent area 2011 in the image 201. The image 201 is then grayscale converted to obtain a grayscale image 301 with the transparent area 2011 removed.

[0029] Figure 4 A schematic diagram of a contour point image is shown. The terminal device can perform edge detection on the grayscale image 301 with the transparent area 2011 removed to obtain a contour point image 401. The contour point image 401 is an image that only retains the contour points that constitute the pattern contour in the image 201.

[0030] As described above, by binarizing the image according to the preset intermediate value and removing the transparent area in the image, the visual consistency of the image can be ensured; by performing grayscale conversion on the pixels in the image and reducing the visual dimension of the image, the features can be calculated more efficiently in subsequent image processing.

[0031] Furthermore, after obtaining the contour points of the pattern in the image, the terminal device dilates the image according to the preset structural element and uses the preset search radius as the radius of the structural element to increase the width of the edge and connect the broken edges.

[0032] The structural element is used to cover and affect the neighborhood of the contour point, and can be in the form of an ellipse, rectangle, etc. The search radius can be the radius of the structural element pre-specified by the user.

[0033] The terminal device performs thinning processing on the expanded image based on contour thinning algorithms such as the Zhang-Suen thinning algorithm and the Hilditch thinning algorithm to obtain refined contour points.

[0034] Taking the Zhang-Suen thinning algorithm as an example, the terminal device iteratively deletes pixels in the dilated image until thinning is no longer possible, thereby extracting the skeleton or center line of the dilated image.

[0035] Figure 5 A schematic diagram of an edge skeleton image is shown. Figure 4 The contour points in the image shown are expanded and contour-refined to obtain an edge skeleton image 501 after expansion and contour-refining. The edge skeleton image 501 is an image that only retains the contour points in the contour point image 401 after expansion and contour-refining.

[0036] As described above, by dilating the image according to the preset structural elements, the width and edge of the contour points can be increased; based on the contour refinement algorithm, the refined contour points are obtained, and the skeleton of the contour points can be extracted to make the contour points more refined.

[0037] Step 104: construct an edge curve in the image based on a selected point in the contour points, wherein the selected point is a contour point located within a specified range of the edge curve and having a minimum cost value, and the cost value is calculated based on a cost function and the contour points in the edge curve.

[0038] In this step, the terminal device first randomly selects a contour point that does not belong to the edge curve from the contour points to create an edge curve, and selects contour points that are within the specified range of the edge curve and do not constitute the edge curve as adjacent points.

[0039] According to the cost function and the contour points in the edge curve, the cost value of each adjacent point is calculated, and the adjacent point with the smallest cost value is selected as the selected point. The selected point is added to the edge curve until no adjacent point is found within the specified range of the edge curve, and the edge curve is constructed.

[0040] The terminal device may also compare the cost value of the selected point with a preset cost threshold. If the cost value of the selected point is less than the cost threshold, the selected point is added to the edge curve. If the cost value of the selected point is greater than or equal to the cost threshold, the selected point is not added to the edge curve.

[0041] The selected point is a contour point that is within the specified range of the edge curve and has the smallest cost value. The adjacent point is a contour point that is within the specified range of the edge curve and does not constitute the edge curve.

[0042] The adjacent points include, but are not limited to, adjacent points corresponding to the first endpoint and adjacent points corresponding to the second endpoint. The adjacent points corresponding to the first endpoint are contour points located within the specified range corresponding to the first endpoint, and the adjacent points corresponding to the second endpoint are contour points located within the specified range corresponding to the second endpoint.

[0043] Exemplarily, the specified range of the edge curve may be a range centered on the first endpoint and having a specified adjacent point search radius as a radius, or may be a range centered on the second endpoint and having a specified adjacent point search radius as a radius.

[0044] An edge curve is a line that forms the outline of a pattern in an image and is composed of continuous outline pixel points. An edge curve can have two endpoints, namely a first endpoint and a second endpoint. If there is only one outline point in an edge curve, the first endpoint and the second endpoint can be the same outline point.

[0045] The cost value is calculated based on the cost function and the contour points in the edge curve. The cost function is used to ensure that the line segment formed by the selected point and the edge curve does not deviate from the direction formed by the edge curve. The cost threshold is used to filter out adjacent points that deviate from the direction formed by the edge curve. The cost threshold can be the square of the specified adjacent point search radius.

[0046] The cost value is calculated based on the cost function and the contour points in the edge curve, specifically using the vector formed by the second last point at the endpoint of the edge curve to the first last point, plus the first preset multiple of the vector formed by the third last point to the second last point, to obtain the unit vector in the new direction.

[0047] Get the adjacent point vector formed by the adjacent point and the last point. Subtract the second preset multiple of the adjacent point vector multiplied by the unit vector of the new direction from the square of the length of the adjacent point vector to get the cost value corresponding to the adjacent point.

[0048] The first preset multiple and the second preset multiple are preset through experiments. Preferably, the first preset multiple is 0.47 times, and the second preset multiple is 0.99 times.

[0049] Furthermore, after constructing the edge curve in the image, since the distance between pixels in the image is usually very close, there will be some redundant data in the edge curve, which is not conducive to geometric editing operations. The terminal device can use the Douglas-Peucker algorithm and the isolinear simplification algorithm to reduce the points of the edge curve.

[0050] See also Figure 6 , Figure 6 A flow chart of a method for reducing points on an edge curve is shown. The method for reducing points may include the following steps: Step 602: construct a line segment corresponding to the edge curve.

[0051] In this step, the terminal device constructs a line segment corresponding to the edge curve between the first endpoint and the second endpoint of the edge curve, wherein the line segment is a straight line between the first endpoint and the second endpoint of the edge curve.

[0052] Step 604: Obtain the distance from the fifth pixel point in the edge curve to the line segment.

[0053] In this step, the terminal device calculates the distance from each contour point in the edge curve to the line segment, and selects the contour point with the largest distance as the fifth pixel point.

[0054] The fifth pixel point is a contour point in the edge curve with the largest distance to the line segment, and may be an intermediate point between the first endpoint and the second endpoint, or any other contour point between the first endpoint and the second endpoint.

[0055] Step 606: If the distance is less than or equal to the distance threshold, delete the contour point between the first endpoint and the second endpoint.

[0056] In this step, if the distance is less than or equal to a preset distance threshold, the terminal device deletes the contour point between the first endpoint and the second endpoint.

[0057] Step 608: If the distance is greater than the distance threshold, retain the fifth pixel point in the edge curve, repeatedly divide the edge curve using the fifth pixel point as the boundary, and iterate the divided edge curve until there are no contour points in the edge curve that are less than or equal to the distance threshold.

[0058] In this step, if the distance is greater than the distance threshold, the terminal device retains the fifth pixel point in the edge curve. The edge curve is divided into two edge curves with the retained fifth pixel point as the boundary, and steps 602 to 608 are repeatedly performed to iteratively process each edge curve until there are no more contour points that can be discarded. The contour points whose distance to the line segment in the edge curve is less than or equal to the distance threshold are continuously deleted, and the contour points whose distance is greater than the distance threshold are retained, and finally a simplified edge curve is obtained.

[0059] As described above, by constructing a line segment between the first endpoint and the second endpoint in the edge curve, the distance from the fifth pixel point in the edge curve to the line segment is obtained. If the distance is less than or equal to the distance threshold, the contour point between the first endpoint and the second endpoint is deleted. If the distance is greater than the distance threshold, the fifth pixel point in the edge curve is retained, and a point reduction operation is performed on the edge curve to remove redundant data in the edge curve, thereby obtaining a simplified edge curve that is basically similar in shape to the original edge curve, which facilitates users to perform geometric editing of edge curves in line graphs.

[0060] Step 106: Generate a line graph corresponding to the image according to the edge curve.

[0061] In this step, the terminal device can repeatedly perform step 104 to construct the edge curve of the image based on the selected points in the contour points until all edge curves in the image are constructed and a line graph corresponding to the image is generated. The line graph is used to display all edge curves that constitute the pattern contour.

[0062] Figure 7 A schematic diagram of a line graph is shown. The terminal device constructs an edge curve in the image based on the contour points in the edge skeleton image 501, and obtains Figure 7 Shown is a line graph 701 including all edge curves that make up the pattern.

[0063] The line graph generation method of the present embodiment obtains the contour points of the pattern in the image by performing edge detection on the image, constructs the edge curve of the image based on the selected points in the edge curve that are within the specified range of the edge curve and have the smallest cost value, generates a line graph corresponding to the image according to the edge curve, and constructs the edge curve by continuously adding contour points that are close to the edge curve and have the smallest cost value, so that adjacent contour points in the edge curve are close to each other and do not bend at large angles, thereby displaying a smooth and rounded edge curve in the generated line graph, improving the quality of the line graph corresponding to the pattern, and supporting users to further perform geometric calculations and other operations on the curves in the line graph to obtain the pattern style effect required by users.

[0064] In the above-mentioned embodiments, edge detection of an image is introduced, contour points of a pattern are obtained, edge curves of an image are constructed, and a line graph corresponding to the image is generated. In the following embodiments, taking the adaptive Canny edge detection algorithm as an example, a more detailed description will be given on how to perform edge detection on an image, and it can be applied to any of the above embodiments.

[0065] In one embodiment, see Figure 8 , Figure 8 FIG. 1 is a flow chart of an edge detection method according to an exemplary embodiment of the present specification. The edge detection method may include the following steps: Step 802: Perform convolution calculation on the image to obtain a filtered image.

[0066] In this step, the terminal device can perform convolution calculation on the grayscale converted image to obtain a filtered image.

[0067] Exemplarily, the terminal device performs a 5th-order Gaussian filter on the grayscale converted image. Since images usually contain noise, such as compression noise, ambient light changes, etc., Gaussian filtering can reduce noise and smooth the image. Based on the principle of Gaussian distribution (normal distribution), a 5x5 Gaussian filter template operator is created, and image smoothing is achieved by weighted averaging the image through convolution.

[0068] By performing Gaussian filtering on an image, the image can be made smoother, the effect of noise on edge detection can be reduced, and the computational complexity of the edge detection algorithm can be reduced. Since operations such as gradient calculation and non-maximum suppression on pixels in an image are sensitive to high-frequency information, unstable results will occur when the image boundary is too sharp or complex. Gaussian filters can make the image boundary smoother and more blurred, reduce high-frequency information in the image, avoid false positive edges on noise points, and help improve the accuracy of edge detection.

[0069] Step 804: Calculate the gradient magnitude and gradient direction of each pixel in the filtered image to obtain a gradient map corresponding to the filtered image.

[0070] In this step, the terminal device uses image gradient operators such as Sobel, Prewitt, and Roberts to perform a convolution operation on the filtered image, calculate the gradient amplitude and gradient direction of each pixel in the filtered image, and obtain a gradient map corresponding to the filtered image.

[0071] Taking the Sobel operator as an example, the terminal device creates 3x3 Sobel operators in the horizontal and vertical directions respectively, and uses two sets of 3x3 matrices in the horizontal and vertical directions to perform convolution calculations on the filtered image. The approximate brightness difference of the filtered image in the horizontal and vertical directions is detected, and the gradient amplitude and gradient direction of each pixel are calculated based on this, and the gradient map in the horizontal and vertical directions is obtained.

[0072] The gradient magnitude is the square root of the sum of the squares of the gradients in two directions, which is used to represent the rate of change of the grayscale value of each pixel in the image in the corresponding direction. The gradient direction is used to represent the trend or direction of the grayscale value change. The Sobel operator is a discrete differential operator used to detect edges.

[0073] Since the edges of patterns in images usually have large grayscale value changes, the gradient represents the rate of change of the image. The image intensity at the edge changes greatly, so the gradient amplitude at the edge is higher. By calculating the gradient amplitude, the positions with larger gradients in the image can be determined. These positions often correspond to the positions of the edges. Using the gradient map can more accurately locate the edges of the image.

[0074] Step 806: Determine the gradient direction area of ​​the first pixel point based on the gradient ratio of the first pixel point in the gradient map and the preset tangent value.

[0075] In this step, after obtaining the gradient map corresponding to the filtered image, the terminal device determines the gradient direction area where each pixel point in the gradient map is located.

[0076] Taking determining the gradient direction area of ​​the first pixel point as an example, the terminal device calculates the gradient ratio of the longitudinal and lateral gradient amplitudes of the first pixel point, compares the gradient ratio with the preset tangent value, determines the gradient direction area of ​​the first pixel point, avoids using the longitudinal and lateral gradient amplitudes as xy coordinates, and calculates the corresponding coordinates in the polar coordinate system: angle and distance. Using the gradient ratio to directly compare with the preset tangent value can calculate the gradient direction area more quickly without the need for complex angle calculation.

[0077] The preset tangent value is the tangent value of a specific angle, which is used to classify pixels in the same gradient direction area. Taking the specific angles of 22.5° and 67.5° as an example, the gradient ratio corresponding to the first pixel point is compared with the tangent values ​​of 22.5° and 67.5° respectively, and the gradient direction area of ​​the first pixel point can be quickly determined.

[0078] When the gradient ratio corresponding to the first pixel point is less than or equal to the tangent value of 22.5°, the gradient direction area of ​​the first pixel point is determined to be a horizontal area; when the gradient ratio corresponding to the first pixel point is greater than or equal to the tangent value of 67.5°, the gradient direction area of ​​the first pixel point is determined to be a longitudinal area; when the gradient ratio corresponding to the first pixel point is greater than the tangent value of 22.5° and less than the tangent value of 67.5°, the gradient direction area of ​​the first pixel point is determined to be a diagonal area.

[0079] The first pixel is a pixel in the gradient map, which is used to characterize the degree of change of the local intensity in the image, that is, the rate of change of the gray value. The first pixel has two attributes: gradient amplitude and gradient direction. The gradient ratio is the ratio of the vertical and horizontal gradient amplitudes of the pixel in the gradient map.

[0080] The gradient direction region refers to the region composed of pixels with similar or consistent gradient directions in the gradient map. The gradient direction region includes: horizontal region, vertical region and diagonal region.

[0081] By calculating the gradient direction area of ​​the pixel points in the gradient map, the direction of the pixel points in the gradient map can be determined, which helps the non-maximum suppression in the subsequent steps to obtain more accurate edges.

[0082] Step 808: Determine a second pixel point corresponding to the first pixel point according to the gradient direction area.

[0083] In this step, the terminal device searches for pixel points adjacent to the first pixel point in the gradient direction area according to the gradient direction area of ​​the first pixel point, and determines the second pixel point corresponding to the first pixel point.

[0084] The second pixel point is a pixel point adjacent to the first pixel point in the direction corresponding to the gradient direction area. If the gradient direction area of ​​the first pixel point is a horizontal area, the second pixel point is two pixel points adjacent to the first pixel point in the horizontal direction corresponding to the horizontal area.

[0085] If the gradient direction region of the first pixel point is a longitudinal region, the second pixel points are two pixel points adjacent to the first pixel point in the longitudinal direction corresponding to the longitudinal region.

[0086] If the gradient direction area of ​​the first pixel point is a diagonal area, it is necessary to further determine whether the first pixel point is located in a 45° diagonal area or a 135° diagonal area.

[0087] If the horizontal gradient amplitude and the vertical gradient amplitude of the first pixel point are both greater than 0 or less than 0 at the same time, the first pixel point is located in the 45° diagonal area, and the second pixel point is the two pixel points located in the upper right and lower left directions adjacent to the first pixel point.

[0088] If the horizontal gradient amplitude and the vertical gradient amplitude of the first pixel point are not greater than 0 or less than 0 at the same time, the first pixel point is located in the 135° diagonal area, and the second pixel point is the two pixel points located in the upper left and lower right adjacent to the first pixel point in the 135° direction.

[0089] Step 810: retain or delete the first pixel in the gradient map based on the gradient magnitude of the first pixel and the gradient magnitude of the second pixel.

[0090] In this step, the terminal device compares the gradient amplitude of the first pixel with the gradient amplitude of the second pixel. Since the local position of the edge contour in the image may have a large gradient amplitude, the most visually obvious position is generally the position of the local maximum gradient amplitude.

[0091] If the gradient magnitude of the first pixel is greater than the gradient magnitude of the second pixel, the first pixel in the gradient map is retained. If the gradient magnitude of the first pixel is less than or equal to the gradient magnitude of the second pixel, the first pixel in the gradient map is deleted.

[0092] As described above, by calculating the gradient direction area of ​​the first pixel point based on the gradient ratio of the first pixel point in the gradient map and the preset tangent value, it is only necessary to calculate the gradient ratio of the longitudinal gradient amplitude and the transverse gradient amplitude to quickly determine the gradient direction area of ​​the pixel point.

[0093] Furthermore, according to the gradient direction area, a second pixel point adjacent to the first pixel point in the direction corresponding to the gradient direction area is determined. If the gradient amplitude of the first pixel point is greater than the gradient amplitude of the second pixel point, the first pixel point in the gradient map is retained. If the gradient amplitude of the first pixel point is less than or equal to the gradient amplitude of the second pixel point, the first pixel point in the gradient map is deleted, thereby achieving non-maximum suppression of the pixels in the gradient map. This can ensure that only the real pixels in the edge are retained and the responses in other places are suppressed, thereby refining the edges in the image, making the edges clearer and more accurate, and making them closer to the contour of the actual pattern.

[0094] Due to the presence of noise or texture in the image, the edge detection algorithm may produce false positive edge responses. By performing non-maximum suppression in the direction corresponding to the gradient direction region, these false positive edge responses can be eliminated while refining the edges in the image, thereby improving the accuracy of edge detection.

[0095] Step 812: Based on the threshold determination algorithm, obtain the high threshold and the low threshold corresponding to the gradient map.

[0096] In this step, since the local maximum gradient amplitude may be generated by details such as noise, the gradient amplitude needs to be screened. The terminal device obtains the high threshold and low threshold corresponding to the gradient map based on threshold determination algorithms such as Otsu's thresholding (OTSU) and fixed threshold method.

[0097] Taking the maximum inter-class variance method as an example, the terminal device can obtain the global threshold of the image, and use the global threshold to divide the pixels in the gradient image into two parts with the largest inter-class variance. The global threshold is used as the high threshold of the gradient amplitude, and 0.5 times the global threshold is used as the low threshold of the gradient amplitude.

[0098] The high threshold and the low threshold are used to filter the gradient amplitude of each pixel in the gradient map.

[0099] Step 814: Determine contour points according to the high threshold and the low threshold.

[0100] In this step, the terminal device screens the pixel points in the gradient image according to the high threshold and the low threshold to determine the contour points belonging to the edge curve.

[0101] If the gradient amplitude of the first pixel in the gradient map is greater than or equal to the high threshold, the gradient change of the first pixel is strong, and the first pixel is determined to be a contour point. If the gradient amplitude of the first pixel is less than or equal to the low threshold, although the first pixel has the local maximum gradient amplitude, the gradient change of the first pixel is still small relative to other pixels, and the first pixel may be a detail location such as a noise point, and the first pixel is determined not to be a contour point.

[0102] If the gradient amplitude of the first pixel is greater than the lower threshold and less than the upper threshold, it means that although the gradient amplitude of the first pixel is relatively small, it is still higher than the lower threshold, and it is determined that the first pixel may belong to a contour point.

[0103] The terminal device needs to further screen the pixels that may belong to the contour points. The eight pixels adjacent to the first pixel that may belong to the contour point are used as the third pixel. If at least one of the third pixels corresponding to the first pixel that may belong to the contour point belongs to the contour point, the first pixel is determined to belong to the contour point.

[0104] That is, if the three conditions are met at the same time: the gradient amplitude of the first pixel point is greater than the low threshold, the gradient amplitude of the first pixel point is less than the high threshold, and the third pixel point corresponding to the first pixel point belongs to the contour point, the first pixel point is determined to be a contour point.

[0105] By adaptively setting the high threshold and the low threshold, the pixels in the gradient map are classified into strong edge, weak edge and non-edge according to the gradient amplitude.

[0106] A strong edge is a pixel whose gradient amplitude is greater than or equal to the high threshold, which often corresponds to a real edge; a weak edge is a pixel whose gradient amplitude is greater than the low threshold and less than the high threshold, which may be noise, texture, or a weak edge; a non-edge is a pixel less than or equal to the low threshold, which is not a pixel in a real edge.

[0107] The terminal device can continuously search for all pixels that may belong to contour points and find their 8 adjacent positions. If a pixel is determined to belong to a contour point, the pixel that may belong to the contour point is confirmed to belong to the contour point.

[0108] The terminal device can also continuously search for all pixels that are determined to belong to the contour point and find its 8 adjacent positions. If there is a pixel that may belong to the contour point, the pixel that may belong to the contour point is confirmed to belong to the contour point until no new point that may belong to the edge is found.

[0109] As described above, by judging if the gradient amplitude of the first pixel point in the gradient map is greater than or equal to the high threshold, it is determined that the first pixel point belongs to the contour point; if the gradient amplitude of the first pixel point is less than or equal to the low threshold, it is determined that the first pixel point does not belong to the contour point; if the gradient amplitude of the first pixel point is greater than the low threshold and less than the high threshold and the third pixel point corresponding to the first pixel point belongs to the contour point, it is determined that the first pixel point belongs to the contour point, thereby determining whether the pixel point in the gradient map belongs to the contour point or not, screening out the pixel points in the real edge, suppressing noise, and enhancing edge connection, thereby improving the accuracy and stability of edge detection.

[0110] The terminal device only retains the pixels that are determined to be contour points in the image, deletes the pixels that are not contour points in the image, and obtains the contour points of the edge curves that constitute the pattern in the image.

[0111] As described above, by performing convolution calculation on the image to obtain a filtered image, the noise of the image can be reduced, image smoothing can be achieved, and the gradient calculation can be made more stable; the gradient amplitude and gradient direction of each pixel in the image are calculated, and the gradient map corresponding to the image is obtained. Based on the threshold determination algorithm, the high threshold and low threshold corresponding to the gradient map are obtained, and the contour points are determined according to the high threshold and the low threshold to avoid misjudging non-edge areas such as noise or texture as edges, thereby further improving the accuracy of edge detection.

[0112] In the above-mentioned embodiment, edge detection of an image is introduced to determine contour points in the edge. In the following embodiment, how to construct an edge curve in an image will be described in more detail, and can be applied to any of the above embodiments.

[0113] In one embodiment, the terminal device expands the edge curve in a manner of continuously increasing proximity and satisfying a cost function, and connects the obtained discrete contour points into a smooth and rounded curve to display the shape of the pattern.

[0114] See also Fig. 9 , Fig. 9 FIG. 1 is a flow chart of a method for constructing an edge curve according to an exemplary embodiment of the present specification. The method for constructing an edge curve may include the following steps: Step 902: Determine whether there are contour points in the image that do not form an edge curve.

[0115] In this step, the terminal device determines whether there are contour points in the image that do not form an edge curve.

[0116] If there are contour points in the image that do not form an edge curve, then continue to execute step 904 .

[0117] If there are no contour points that do not constitute an edge curve in the image, step 928 is executed.

[0118] Step 904: Select a fourth pixel point in the image that does not form an edge curve.

[0119] In this step, the terminal device selects the fourth pixel point in the image that does not form an edge curve, wherein the fourth pixel point is a contour point in the image that does not form an edge curve, and is used to create a new edge curve.

[0120] Step 906: Create a first edge curve corresponding to the fourth pixel point.

[0121] In this step, the terminal device creates a first edge curve corresponding to the fourth pixel point according to the fourth pixel point, and adds the fourth pixel point to the first edge curve.

[0122] The first edge curve is used to expand a new contour point connected to the fourth pixel point. At this time, the contour point in the first edge curve is only the fourth pixel point.

[0123] Step 908: Searching for an adjacent point corresponding to the first endpoint within a specified range corresponding to the first endpoint of the first edge curve.

[0124] In this step, the terminal device searches the image for all contour points around the first endpoint of the first edge curve that have not yet been added to the edge curve, within a specified range constructed with the first endpoint of the first edge curve as the center and the specified adjacent point search radius as the radius, as adjacent points corresponding to the first endpoint.

[0125] Step 910: Determine whether there is an adjacent point corresponding to the first endpoint.

[0126] In this step, the terminal device determines whether there is a neighboring point corresponding to the first endpoint within a specified range corresponding to the first endpoint.

[0127] If there is an adjacent point corresponding to the first endpoint, continue to execute step 912.

[0128] If there is no adjacent point corresponding to the first endpoint, step 922 is executed.

[0129] Step 912: Determine whether the number of pixels is less than a preset threshold.

[0130] In this step, the terminal device determines whether the number of pixels of the first edge curve is greater than or equal to a preset number threshold. The number of pixels is the number of contour points in the first edge curve. The preset number threshold is used to determine whether a selected point needs to be selected.

[0131] When the number of pixel points is less than the preset threshold, only the distance between the adjacent point and the first endpoint needs to be considered, and selecting the adjacent point closest to the first endpoint may cause the edge curve to be not smooth enough.

[0132] Therefore, the preset number threshold is set to three. While ensuring that there are a sufficient number of three pixel points in the edge curve when calculating the cost value, it is also ensured that the newly added contour point is the selected point with the smallest cost value among the adjacent points and the cost value is less than the cost threshold, making the edge curve more rounded and smooth.

[0133] If the number of pixel points of the first edge curve is less than the preset number threshold, then continue to execute step 914 .

[0134] If the number of pixels of the first edge curve is greater than or equal to the preset number threshold, step 916 is executed.

[0135] Step 914: Add the neighboring point closest to the first endpoint to the first edge curve.

[0136] In this step, when the number of pixel points in the first edge curve is less than the preset number threshold, the terminal device sorts the pixel points in the image from small to large according to the length between each adjacent point and the first endpoint, and adds the adjacent point closest to the first endpoint to the first edge curve as a new first endpoint. Based on the new first endpoint, step 908 is continued to be executed to expand the new contour point in the first edge curve.

[0137] As described above, by judging if the number of pixel points in the first edge curve is less than the preset threshold, the nearest point to the first endpoint is selected as the selected point, ensuring that the extended contour point is close to the endpoint in the first edge curve when the number of pixel points is less than the preset threshold, so that the edge curve is smooth and round.

[0138] Step 916: Determine whether the minimum cost value is less than the cost threshold.

[0139] In this step, when the number of pixels of the first edge curve is greater than or equal to the preset number threshold, the terminal device calculates the cost value of the adjacent points, selects the smallest cost value among the adjacent points and compares it with the cost threshold to determine whether the smallest cost value is less than the cost threshold.

[0140] If the minimum cost value is less than the cost threshold, then continue to execute step 918 .

[0141] If the minimum cost value is greater than or equal to the cost threshold, step 922 is executed.

[0142] Step 918: Select the adjacent point corresponding to the minimum cost value as the selected point.

[0143] In this step, the terminal device selects the adjacent point corresponding to the smallest cost value as the selected point corresponding to the first endpoint.

[0144] Step 920: Add the selected point to the first edge curve.

[0145] In this step, the terminal device adds the selected point to the first edge curve and uses the selected point as a new first endpoint. Based on the new first endpoint, step 908 is continued to be executed to expand the new contour point in the first edge curve.

[0146] As described above, by selecting the fourth pixel point that constitutes the edge curve in the image, a first edge curve corresponding to the fourth pixel point is created. If the number of pixel points in the first edge curve is greater than or equal to a preset threshold, the adjacent point with the smallest cost value is used as the selected point, and the selected point is added to the first edge curve, so as to find a selected point that is adjacent and does not bend at a large angle among the adjacent points around the endpoint of the edge curve, so that the newly added selected point does not deviate from the direction in which the edge curve is formed.

[0147] Step 922: Determine whether the second endpoint of the first edge curve has been calculated.

[0148] In this step, when there is no adjacent point in the contour point of the terminal device, or the cost value of the adjacent point is greater than or equal to the cost threshold, and there is no new contour point connected to the first endpoint in the image, it is determined whether the adjacent point corresponding to the second endpoint in the first edge curve has been calculated.

[0149] If the second endpoint of the first edge curve has not been calculated, then continue to execute step 924 .

[0150] If the second endpoint of the first edge curve has been calculated, step 926 is executed.

[0151] Step 924: construct a first edge curve based on the second endpoint in the first edge curve.

[0152] In this step, if there is no adjacent point in the contour point, or the cost value of the adjacent point is greater than or equal to the cost threshold, the terminal device uses the second endpoint in the first edge curve as a new first endpoint. Based on the new first endpoint, step 908 is continued to be executed to expand the new contour point in the first edge curve to construct the first edge curve.

[0153] As described above, by constructing the first edge curve based on the second endpoint in the first edge curve when there is no adjacent point in the contour point or the cost value of the adjacent point is greater than or equal to the cost threshold, the contour key point that is adjacent to the other endpoint of the first edge curve and does not bend at a large angle is extended.

[0154] Step 926: The first edge curve is constructed.

[0155] In this step, there are no new contour points in the image that can be added to the first edge curve, and the first edge curve is constructed.

[0156] Step 928: Determine whether all edge curves in the image are constructed.

[0157] In this step, the terminal device determines that all edge curves in the image are constructed and all contour points are connected into round and smooth edge curves.

[0158] To further illustrate the process of line graph generation, Fig.10 A flow chart of another line graph generation method is shown, and the line graph generation method may include the following steps: Step 1002: receiving an image and a neighboring point search radius input by a user.

[0159] In this step, please continue to Figure 2 , the terminal device receives the image 201 with the pattern and the designated adjacent point search radius input by the user.

[0160] Step 1004: Remove transparent areas in the image and convert it into a grayscale image.

[0161] In this step, please continue to Figure 3 The terminal device removes the transparent area 2011 in the input image 201 and converts the image after removing the transparent area 2011 into a grayscale image 301.

[0162] Step 1006: Perform adaptive Canny edge detection on the grayscale image to obtain contour points.

[0163] In this step, please continue to Figure 4 The terminal device performs adaptive Canny edge detection on the grayscale image 301, obtains contour points constituting the contour of the pattern in the image 201, and obtains a contour point image 401 that only retains the contour points.

[0164] Step 1008: dilate the contour points and refine the contour.

[0165] In this step, please continue to Figure 5 The terminal device dilates and refines the contour points in the contour point image to obtain an edge skeleton image 501 after dilation and contour refinement.

[0166] Step 1010: construct edge curves based on the contour points after dilation and contour refinement.

[0167] In this step, the terminal device extends new contour points on the end points of the edge curve according to the contour points after expansion and contour refinement in the edge skeleton image to construct the edge curve.

[0168] Step 1012: Perform a point reduction operation on the edge curve.

[0169] In this step, the terminal device performs a point reduction operation on the edge curve, and only retains contour points whose distance is greater than the distance threshold.

[0170] Step 1014: Generate a line graph corresponding to the image.

[0171] In this step, please continue to Figure 7The terminal device generates a line graph 701 corresponding to the image based on all edge curves after point reduction, and all edge curves constituting the outline of the pattern on the line graph 701.

[0172] Fig.11 This is a schematic diagram of the structure of an electronic device according to an exemplary embodiment of the present specification. The electronic device may be, for example, a mobile phone, a computer, a digital broadcast terminal, a message transceiver device, a game console, a tablet device, a personal digital assistant, a server, a smart home appliance, etc. Fig.11 At the hardware level, the electronic device includes a processor 1102, an internal bus 1104, a network interface 1106, a memory 1108, and a non-volatile memory 1110, and may also include hardware required for other services. The processor 1102 reads the corresponding computer program from the non-volatile memory 1110 into the memory 1108 and then runs it, forming a line graph generation device at the logical level. Of course, in addition to the software implementation, this application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0173] Fig.12 is a block diagram of a line graph generating device according to an exemplary embodiment of the present specification. Fig.12 The device may include: a contour point acquisition module 1202, an edge curve construction module 1204 and a line graph generation module 1206, wherein: The contour point acquisition module 1202 is used to perform edge detection on the image and acquire contour points of the pattern in the image; The edge curve construction module 1204 is used to construct an edge curve in the image based on a selected point among the contour points, wherein the selected point is a contour point located within a specified range of the edge curve and having a minimum cost value; The line graph generating module 1206 is used to generate a line graph corresponding to the image according to the edge curve.

[0174] In one example, the contour point acquisition module 1202, when used to perform edge detection on an image and obtain contour points of a pattern in the image, includes: performing convolution calculation on the image to obtain a filtered image after filtering; calculating the gradient amplitude and gradient direction of each pixel point in the filtered image to obtain a gradient map corresponding to the filtered image; based on a threshold determination algorithm, obtaining a high threshold and a low threshold corresponding to the gradient map; and determining the contour points according to the high threshold and the low threshold.

[0175] In one example, the contour point acquisition module 1202, before being used to obtain the high threshold and the low threshold corresponding to the gradient map based on the threshold determination algorithm, also includes: determining the gradient direction area of ​​the first pixel point in the gradient map based on the gradient ratio of the first pixel point and the preset tangent value, the gradient ratio being the ratio of the gradient amplitudes of the first pixel point in the longitudinal and transverse directions; determining the second pixel point corresponding to the first pixel point according to the gradient direction area; the second pixel point is the pixel point adjacent to the first pixel point in the direction corresponding to the gradient direction area; if the gradient amplitude of the first pixel point is greater than the gradient amplitude of the second pixel point, retaining the first pixel point in the gradient map; if the gradient amplitude of the first pixel point is less than or equal to the gradient amplitude of the second pixel point, deleting the first pixel point in the gradient map.

[0176] In one example, the contour point acquisition module 1202, when used to determine the contour point according to the high threshold and the low threshold, includes: if the gradient amplitude of the first pixel point in the gradient map is greater than or equal to the high threshold, determining that the first pixel point belongs to the contour point; if the gradient amplitude of the first pixel point is less than or equal to the low threshold, determining that the first pixel point does not belong to the contour point; if the gradient amplitude of the first pixel point is greater than the low threshold and less than the high threshold and the third pixel point corresponding to the first pixel point belongs to the contour point, determining that the first pixel point belongs to the contour point; the third pixel point is a pixel point adjacent to the first pixel point.

[0177] In one example, the edge curve construction module 1204, when used to construct an edge curve in an image based on a selected point in the contour points, includes: selecting a fourth pixel point in the image, wherein the fourth pixel point is a contour point that does not constitute the edge curve; creating a first edge curve corresponding to the fourth pixel point, and determining an adjacent point corresponding to the first endpoint in the first edge curve; if the number of pixel points in the first edge curve is greater than or equal to a preset number threshold, taking the adjacent point with the smallest cost value as the selected point; and adding the selected point to the first edge curve.

[0178] In one example, the edge curve construction module 1204 is further used to construct the first edge curve based on the second endpoint in the first edge curve when the adjacent point does not exist in the contour point or the cost value of the adjacent point is greater than or equal to the cost threshold.

[0179] In one example, the edge curve construction module 1204 is further configured to add the neighboring point closest to the first endpoint to the first edge curve if the number of pixel points in the first edge curve is less than the preset number threshold.

[0180] In one example, the contour point acquisition module 1202, before being used to perform edge detection on an image and obtain contour points of a pattern in the image, further includes: binarizing the image according to a preset intermediate value to remove transparent areas in the image; and performing grayscale conversion on pixel points in the image.

[0181] In one example, the edge curve construction module 1204, before being used to construct an edge curve in an image based on selected points in the contour points, further includes: dilating the image according to a preset structural element; and refining the dilated image based on a contour refinement algorithm to obtain the refined contour points.

[0182] In one example, the edge curve construction module 1204, after being used to construct the edge curve in the image, further includes: constructing a line segment corresponding to the edge curve; the line segment is a straight line between the first endpoint and the second endpoint of the edge curve; obtaining the distance from the fifth pixel point in the edge curve to the line segment; if the distance is less than or equal to the distance threshold, deleting the contour point between the first endpoint and the second endpoint; if the distance is greater than the distance threshold, retaining the fifth pixel point in the edge curve.

[0183] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.

[0184] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. A person of ordinary skill in the art can understand and implement it without paying creative labor.

[0185] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory including instructions. The instructions can be executed by a processor of a line graph generating device to implement any of the methods described in the above embodiments.

[0186] The non-temporary computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc., and the present application does not limit this.

[0187] In an exemplary embodiment, a computer program product including a computer program / instruction is further provided. The computer program / instruction can be executed by a processor of a line graph generating device to implement any of the methods described in the above embodiments.

[0188] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0189] Those skilled in the art will readily appreciate other embodiments of the specification after considering the specification and practicing the invention claimed herein. The specification is intended to cover any variations, uses or adaptations of the specification that follow the general principles of the specification and include common knowledge or customary techniques in the art that are not claimed in the specification. The specification and examples are to be considered exemplary only, and the true scope and spirit of the specification are indicated by the following claims.

[0190] It should be understood that the present description is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.

[0191] The above description is only a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification should be included in the scope of protection of this specification.

Claims

1. A method for generating a line graph, It is characterized in that The method comprises: Performing edge detection on the image to obtain contour points of the pattern in the image; constructing an edge curve in the image based on selected points among the contour points, wherein the selected points are contour points located within a specified range of the edge curve and having a minimum cost value, wherein the cost value is calculated based on a cost function and the contour points in the edge curve; A line graph corresponding to the image is generated according to the edge curve.

2. The method according to claim 1, It is characterized in that The step of performing edge detection on an image to obtain contour points of a pattern in the image includes: Performing convolution calculation on the image to obtain a filtered image; Calculating the gradient magnitude and gradient direction of each pixel in the filtered image to obtain a gradient map corresponding to the filtered image; Based on a threshold determination algorithm, obtaining a high threshold and a low threshold corresponding to the gradient map; The contour points are determined according to the high threshold and the low threshold.

3. The method according to claim 2, It is characterized in that Before obtaining the high threshold and the low threshold corresponding to the gradient map based on the threshold determination algorithm, the method further includes: Determine a gradient direction area of ​​a first pixel point based on a gradient ratio of a first pixel point in the gradient map and a preset tangent value, wherein the gradient ratio is a ratio of the gradient amplitudes of the first pixel point in the longitudinal direction to the horizontal direction; Determine, according to the gradient direction area, a second pixel point corresponding to the first pixel point; the second pixel point is a pixel point adjacent to the first pixel point in a direction corresponding to the gradient direction area; If the gradient magnitude of the first pixel is greater than the gradient magnitude of the second pixel, retaining the first pixel in the gradient map; If the gradient magnitude of the first pixel is less than or equal to the gradient magnitude of the second pixel, the first pixel in the gradient map is deleted.

4. The method according to claim 2, It is characterized in that The step of determining the contour point according to the high threshold and the low threshold comprises: If the gradient amplitude of the first pixel point in the gradient map is greater than or equal to the high threshold, it is determined that the first pixel point belongs to the contour point; If the gradient amplitude of the first pixel point is less than or equal to the low threshold, it is determined that the first pixel point does not belong to the contour point; If the gradient amplitude of the first pixel point is greater than the lower threshold and less than the upper threshold and the third pixel point corresponding to the first pixel point belongs to the contour point, it is determined that the first pixel point belongs to the contour point; the third pixel point is a pixel point adjacent to the first pixel point.

5. The method according to claim 1, It is characterized in that The step of constructing an edge curve in the image based on the selected points in the contour points includes: Selecting a fourth pixel point in the image, wherein the fourth pixel point is a contour point that does not constitute the edge curve; Creating a first edge curve corresponding to the fourth pixel point, and determining an adjacent point corresponding to a first endpoint in the first edge curve; If the number of pixel points of the first edge curve is greater than or equal to a preset number threshold, the adjacent point with the smallest cost value is used as the selected point; The selected point is added to the first edge curve.

6. The method according to claim 5, It is characterized in that The method further comprises: When the adjacent point does not exist in the contour point or the cost value of the adjacent point is greater than or equal to the cost threshold, the first edge curve is constructed based on the second endpoint in the first edge curve.

7. The method according to claim 5, It is characterized in that The method further comprises: If the number of pixel points in the first edge curve is less than the preset number threshold, the neighboring point closest to the first endpoint is added to the first edge curve.

8. The method according to claim 1, It is characterized in that Before performing edge detection on the image to obtain contour points of the pattern in the image, the method further includes: Binarize the image according to a preset intermediate value, and remove transparent areas in the image; Grayscale conversion is performed on the pixels in the image.

9. The method according to claim 1, It is characterized in that Before constructing the edge curve in the image based on the selected points in the contour points, the method further includes: dilating the image according to a preset structural element; Based on the contour thinning algorithm, the expanded image is thinned to obtain the thinned contour points.

10. The method according to claim 1, It is characterized in that After constructing the edge curve in the image and before generating the line graph corresponding to the image according to the edge curve, the method further includes: Constructing a line segment corresponding to the edge curve; the line segment is a straight line between a first endpoint and a second endpoint of the edge curve; Obtaining the distance from the fifth pixel point in the edge curve to the line segment; If the distance is less than or equal to the distance threshold, deleting the contour point between the first endpoint and the second endpoint; If the distance is greater than the distance threshold, the fifth pixel point in the edge curve is retained.

11. A line graph generating device, It is characterized in that The device comprises: A contour point acquisition module, used to perform edge detection on an image and acquire contour points of a pattern in the image; An edge curve construction module, used to construct an edge curve in an image based on a selected point among the contour points, wherein the selected point is a contour point located within a specified range of the edge curve and having a minimum cost value; A line graph generating module is used to generate a line graph corresponding to the image according to the edge curve.

12. An electronic device, It is characterized in that include: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 10 by running the executable instructions.

13. A computer-readable storage medium having computer instructions stored thereon, It is characterized in that When the instruction is executed by a processor, the method according to any one of claims 1 to 10 is implemented.

14. A computer program product having a computer program / instructions stored thereon, It is characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 10 is implemented.

Citation Information

Patent Citations

  • Method and system for partitioning construction in CT image

    CN104143190A

  • Image interpolation method and device

    CN106204453A

  • Molten pool contour image extraction method for realizing closed connected domain

    CN111696107A

  • Remote sensing image information extraction method based on FCN-8s and improved Canny edge detection

    CN111985329A

  • Image color edge correction method and device, electronic equipment and storage medium

    CN113132705A