Image tracing method and system, electronic equipment and storage medium

By using gradient values ​​to calculate edge weights in image processing and using minimum heap and recursive methods to determine image tracing paths, the problems of image tracing accuracy and low efficiency in the existing technology are solved, and more efficient and accurate tracing is achieved. operate.

CN119338856APending Publication Date: 2025-01-21SONOSCAPE MEDICAL CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310912209.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-21
Publication Date
2025-01-21

AI Technical Summary

Technical Problem

In the prior art, image tracing requires manual operation, which is difficult to achieve precise control, and is prone to trace errors, is inefficient, and is wasted a lot of manpower.

Method used

By acquiring and displaying the image to be processed, determine the positions of the two control points, calculate the gradient value between each pixel and adjacent pixels, calculate the weight of each edge based on the gradient value, and determine the two control points using the minimum heap and recursive methods. The minimum weight path between points is used as a trace.

Benefits of technology

It improves the convenience of user operation and work efficiency, ensures the accuracy and speed of tracing, and reduces manual errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119338856A_ABST
    Figure CN119338856A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an image tracing method and system, electronic equipment and a storage medium. The method comprises the following steps: acquiring and displaying a to-be-processed image; determining a first control point in response to an operation of determining the first control point in the image by the user; determining a second control point in response to an operation of determining the second control point in the image by the user; according to the pixel value of each pixel point in at least a local area in the image, calculating a gradient value of the pixel value of the pixel point and the pixel value of an adjacent pixel point; according to the gradient values, the weight of each edge is calculated, a connecting line between two adjacent pixel points forms an edge, and the weight of each edge is in inverse correlation with the corresponding gradient value; according to the weight of each edge, a trace between the first control point and the second control point is determined, the trace is the path with the minimum weight sum in all the paths between the first control point and the second control point, and the weight sum is the sum of the weights of the edges included in the paths. The scheme is accurate in tracing, fast in execution and good in user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing, and more specifically to an image tracing method, an image tracing system, an electronic device and a storage medium. Background Art

[0002] With the development of science and technology, digital images are used in more and more application scenarios to meet people's various needs. In some application scenarios, it is necessary to draw lines in the image for tracing. Through image tracing, the image can be divided in a certain sense so that the objects in the image can be located, identified or measured. For example, when using the free anatomical imaging function in the field of medical technology, you can trace in the medical image to view the outline of the target in the current slice.

[0003] In the prior art, there are usually four image tracing methods: straight line drawing, curved line drawing,

[0004] Multi-segment line drawing, tracing line drawing. The existing tracing methods are all manual tracing, which requires experienced engineers to slowly move the trackball manually. However, it is difficult to make the cursor accurately point to a certain pixel point when manually controlling the cursor movement. In addition, the naked eye cannot accurately observe whether the cursor position is the expected pixel point. Therefore, the above scheme is not only prone to tracing errors and low efficiency, but also wastes a lot of manpower. Summary of the invention

[0005] In view of the above problems, embodiments of the present application are proposed. Embodiments of the present application provide an image tracing method, an electronic device and a storage medium.

[0006] According to one aspect of the present application, there is provided an image tracing method, comprising:

[0007] Acquire and display the image to be processed;

[0008] In response to a user's operation of determining a first control point in the displayed image to be processed, determining a position of the first control point;

[0009] In response to a user's operation of determining a second control point in the displayed image to be processed, determining a position of the second control point;

[0010] Calculate the gradient value of the pixel value between the pixel point and its adjacent pixel points according to the pixel value of each pixel point in at least a local area of ​​the image to be processed;

[0011] Calculating the weight of each edge according to the gradient value, wherein a line between two adjacent pixels constitutes an edge, and the weight of each edge is inversely correlated with the corresponding gradient value; and

[0012] A trace between the first control point and the second control point is determined according to the weight of each edge, wherein the trace is a path with the smallest sum of weights among all paths between the first control point and the second control point, and the sum of weights is the sum of weights of the edges included in the path.

[0013] Exemplarily, determining the trace between the first control point and the second control point according to the weight of each edge includes:

[0014] Using the weight of each edge, a minimum heap is established, wherein the elements in the minimum heap include the weight of the edge;

[0015] Based on the elements in the minimum heap and using a recursive method, among all paths between the first control point and the second control point, the weights of the edges included in the path and the minimum path are determined.

[0016] Exemplarily, the determining, based on the minimum heap and using a recursive method, among all paths between the first control point and the second control point, the weights of the edges included in the paths and the minimum path includes:

[0017] Taking any control point of the first control point and the second control point as a starting point, searching for a first element in the minimum heap, wherein an edge corresponding to the first element is an edge connecting the starting point and having the smallest weight;

[0018] The following search operation is performed in a loop until an element whose corresponding edge connects the end point is found, wherein the search operation includes: deleting the found element in the current minimum heap to obtain an updated minimum heap, the edge corresponding to the deleted element is the deleted edge, and in the current minimum heap, a second element is searched, the edge corresponding to the second element is the edge with the smallest weight connecting the deleted edges, and the end point is another control point other than the starting point among the first control point and the second control point;

[0019] Based on the found elements, a path among all the paths having the smallest sum of weights of the edges included in the path is determined.

[0020] Exemplarily, the step of calculating the gradient value of the pixel value between the pixel point and its adjacent pixel points according to the pixel value of each pixel point in at least a local area of ​​the image to be processed includes:

[0021] The gradient value of the pixel value of the pixel point and its adjacent pixel points is calculated according to the difference between the pixel value of the pixel point and its horizontally adjacent pixel points and the vertically adjacent pixel points respectively.

[0022] Exemplarily, calculating the weight of each edge according to the gradient value includes:

[0023] For each pixel, calculating the azimuth of the pixel according to the difference between the pixel value and its adjacent pixel value in the horizontal direction and the difference between the pixel value and its adjacent pixel value in the vertical direction; and

[0024] Based on the azimuth angle and the gradient value of the pixel values ​​of the pixel point and its adjacent pixel points, the weight of the edge between the pixel point and its transversely adjacent pixel points and the weight of the edge between the pixel point and its longitudinally adjacent pixel points are calculated.

[0025] Exemplarily, before calculating the gradient value of the pixel value of each pixel point and its adjacent pixel points according to the pixel value of each pixel point in at least a local area of ​​the image to be processed, the method further includes:

[0026] The local area is determined according to the position of the first control point, wherein the local area includes the first control point.

[0027] Exemplarily, determining the local area according to the position of the first control point includes:

[0028] A rectangular area or a circular area centered at the position of the first control point is determined as the local area.

[0029] Exemplarily, the image to be processed is a color image. Before calculating the gradient value of the pixel value of each pixel point and its adjacent pixel points based on the pixel value of each pixel point in at least a local area of ​​the image to be processed, the method also includes: grayscale the image to be processed.

[0030] According to another aspect of the present invention, there is also provided an image tracing system, comprising:

[0031] An image acquisition module, used for acquiring and displaying the image to be processed;

[0032] A first determining module, configured to determine a position of a first control point in response to a user's operation of determining the first control point in the displayed image to be processed;

[0033] A second determining module, configured to determine a position of a second control point in response to a user's operation of determining the second control point in the displayed image to be processed;

[0034] A first calculation module, used for calculating a gradient value of a pixel point and a pixel value of an adjacent pixel point according to a pixel value of each pixel point in at least a local area of ​​the image to be processed;

[0035] a second calculation module, configured to calculate the weight of each edge according to the gradient value, wherein a line between two adjacent pixels constitutes an edge, and the weight of each edge is inversely correlated with the corresponding gradient value; and

[0036] A tracing module is used to determine a tracing between the first control point and the second control point according to the weight of each edge, wherein the tracing is a path with the smallest weight sum among all paths between the first control point and the second control point, and the weight sum is the sum of the weights of the edges included in the path.

[0037] According to yet another aspect of the present invention, there is further provided an electronic device, comprising a processor and a memory, wherein the memory stores computer program instructions, and the computer program instructions are used to execute the above-mentioned image tracing method when the processor is running.

[0038] According to another aspect of the present invention, a storage medium is provided, on which program instructions are stored, and the program instructions are used to execute the above-mentioned image tracing method when running.

[0039] According to the above scheme, the two endpoints of the trace are first determined, then the weight of the line between the pixels is determined by the degree of change of the pixel values ​​of the pixels, and finally, the trace between the two endpoints is automatically determined based on the weight of each edge. For the user, the operation of determining the trace is more convenient, which greatly improves the user's work efficiency. In addition, the trace determined by the technical solution is more accurate and the entire determination process is faster. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] By describing the embodiments of the present application in more detail in conjunction with the accompanying drawings, the above and other purposes, features and advantages of the present application will become more apparent. The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the present application and do not constitute a limitation of the present application. In the accompanying drawings, the same reference numerals generally represent the same components or steps.

[0041] Figure 1 A schematic flow chart of an image tracing method according to an embodiment of the present application is shown;

[0042] Figure 2 An image to be processed according to an embodiment of the present application is shown;

[0043] Figure 3 A schematic diagram of a minimum heap according to an embodiment of the present application is shown;

[0044] Figure 4A schematic flow chart of determining the weights of the edges included in all paths between a first control point and a second control point and the minimum path according to an embodiment of the present application is shown;

[0045] Figure 5A An enlarged schematic diagram of a local area according to an embodiment of the present application is shown;

[0046] Figure 5B Shown in Figure 5A A schematic diagram of the trace of a determined image within the local area shown;

[0047] Fig. 6A shows an image to be processed according to another embodiment of the present application;

[0048] Figure 6B shows an image on which a trace has been drawn according to one embodiment of the present invention;

[0049] Fig. 7A An ultrasound image with a trace drawn based on the prior art is shown;

[0050] Figure 7B shows an ultrasound image with traces determined according to one embodiment of the present invention; and

[0051] Figure 8 A schematic block diagram of an image tracing system according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0052] In order to make the purpose, technical solutions and advantages of the present application more obvious, the example embodiments according to the present application will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application, and it should be understood that the present application is not limited to the example embodiments described herein. Based on the embodiments of the present application described in the present application, all other embodiments obtained by those skilled in the art without creative work should fall within the scope of protection of the present application.

[0053] In order to at least partially solve the above technical problems, the present application embodiment provides an image tracing method. Figure 1 The image tracing method according to an embodiment of the present application is described. The image tracing method can be applied to electronic devices such as ultrasound equipment. Figure 1 FIG. 1 is a schematic flow chart of an image tracing method 1000 according to an embodiment of the present application. Figure 1 As shown, the image tracing method 1000 includes steps S1100 , S1200 , S1300 , S1400 , S1500 , and step S1600 .

[0054] In step S1100, an image to be processed is acquired and displayed.

[0055] According to the embodiments of the present application, any existing or future image acquisition method can be used to acquire the image to be processed. For example, the image to be processed can be obtained by photographing through an image acquisition device. The image acquisition device can be a camera or a video camera with suitable configuration parameters. The image to be processed can be a static image of the target captured by the camera, or each frame or multiple frames of a continuous dynamic video frame of the target acquired in real time by the camera. Optionally, the image to be processed can be an ultrasound image obtained by ultrasound scanning with an ultrasound device. After displaying the image to be processed, the ultrasound device can enter the tracing mode automatically or under the trigger of the user, for example: after displaying the image to be processed, it automatically enters the fetal head circumference measurement mode and starts the tracing mode; at this time, the user can determine the control points, draw trajectories, etc. on the image to be processed by operating the mouse, trackball, etc.

[0056] The image to be processed may be an original image directly acquired by the image acquisition device, or may be an image after a preprocessing operation is performed on the original image. The preprocessing operation may include all operations for improving the visual effect of the image, improving the clarity of the image, or highlighting certain features in the image to facilitate tracing the edge of the target. For example, the preprocessing operation may include denoising operations such as filtering, and may also include adjustments to image parameters such as image grayscale, contrast, brightness, etc., and may also include operations such as image cropping or image scaling.

[0057] The image to be processed may be any suitable image. It may be a two-dimensional image or a three-dimensional image; it may be a black-and-white image or a color image; it may be an image of any size or an image that meets a preset resolution requirement. This application may not limit it, as long as the image contains the target to be traced.

[0058] For example, the image to be processed may be a medical cross-sectional image, and the image tracing method of the embodiment of the present application may be used to trace the edge of the target therein, such as body organs, diseased tissues, and the like.

[0059] The acquired image to be processed may be displayed to the user so that the user can operate the image to determine the trace of the target in the image to be processed. Figure 2 An image to be processed according to an embodiment of the present application is shown.

[0060] In step S1200 , in response to a user's operation of determining a first control point in the displayed image to be processed, a position of the first control point is determined.

[0061] In step S1300, in response to a user's operation of determining a second control point in the displayed image to be processed, a position of the second control point is determined.

[0062] The first control point and the second control point may be a point on the trace in the image, and the two may serve as the starting point and the end point of the trace, respectively. The positions of the first control point and the second control point may be determined by manual operation of the user. The positions of the first control point and the second control point may be used to automatically determine the trace of the image later.

[0063] Specifically, after the user carefully observes the image to be processed, the edge of the target to be traced in the image to be processed can be determined. The user can use the input device to respectively determine the first control point and the second control point on the determined edge. For example, the user can use the mouse to operate the cursor displayed on the screen, and when the cursor moves to the desired first control point, click the left mouse button to confirm the position of the first control point. Then, the user can release the left mouse button and use the mouse to control the movement of the cursor, and when the cursor moves to the desired second control point, click the left mouse button again to confirm the position of the second control point. Alternatively, after the user clicks the left mouse button to confirm the position of the first control point, the user can also keep pressing the left mouse button and move the mouse to control the movement of the cursor. As the mouse moves, a cursor track can be drawn on the screen. When the cursor moves to the desired second control point, the user can release the left mouse button. Then, when the user releases the left mouse button, the position of the cursor is the position of the second control point.

[0064] In step S1400, a gradient value of pixel values ​​of each pixel and its adjacent pixels is calculated based on the pixel value of each pixel in at least a local area of ​​the image to be processed.

[0065] The tracing of the target in the entire image to be processed can be determined, or the tracing of the target can be determined for a local area in the image. The local area is used for the calculation of the subsequent steps S1500 and S1600, and the local area can be displayed or not displayed in the image. The local area can be preset. Exemplarily, the local area can be a square area centered on the center of the image and with a side length of a preset size. In some application scenarios, the target in the image to be processed is usually located at the center of the image. Therefore, the position of the local area can be determined based on the center of the image. The local area will most likely include the image of the target. Alternatively, the local area can be a rectangular area centered on the first control point or the second control point, with a length and a width of a first preset size and a second preset size, respectively. Using the local area in the image to be processed to trace the image will greatly reduce unnecessary calculations and improve the image tracing speed while ensuring the accuracy of the tracing.

[0066] The gradient value of the pixel value of a pixel represents the rate of change of the pixel value at the pixel. In other words, the gradient value of the pixel value of a pixel reflects the degree of color change of the pixel. The higher the gradient value, the greater the change of the pixel value of the pixel compared to the pixel values ​​of the surrounding pixels, that is, the greater the color difference between the pixel and the adjacent pixels; otherwise, the opposite is true. Therefore, the larger the gradient value of the pixel value of the pixel, the more likely the pixel is on the boundary of the object in the image.

[0067] The pixel values ​​of all pixels in the image to be processed or in the local area of ​​the image to be processed can be read. The pixel value can include the RGB three primary color value of the pixel point, or it can be the grayscale value of the pixel point. Then, the gradient value is calculated using the pixel value. Specifically, the gradient value can be related to the difference between the pixel value of a certain pixel point and the pixel value of its adjacent pixel point. For example, for any pixel point, its adjacent pixel points can be its right adjacent point and its lower adjacent point. Exemplarily, the gradient value of the pixel value of the pixel point can be calculated based on the difference between the pixel value of the pixel point and its two adjacent pixel points.

[0068] In step S1500, the weight of each edge is calculated according to the gradient value.

[0069] Specifically, the line between two adjacent pixels constitutes an edge. The edge is a virtual concept that does not actually exist in the image. The concept of the edge is conducive to the intuitive understanding of the boundary and the path. Specifically, the edge is derived to facilitate the screening of pixels and find the trace that best matches the boundary of the target. Each edge can be assigned a corresponding weight based on the information of the two pixels connected by each edge. The weight of the edge is inversely correlated with the gradient value of the pixel values ​​of the two pixels connected by the edge. In other words, the larger the gradient value of the pixel values ​​of two adjacent pixels, the smaller the weight of the edge formed by the line between the two adjacent pixels, and the greater the probability that the edge is part of the trace; conversely, the smaller the gradient value of the pixel values ​​of two adjacent pixels, the larger the weight of the edge formed by the line between the two adjacent pixels, and the smaller the probability that the edge is part of the trace. Thus, the trace of the target can be determined based on the weights of all edges in the image to be processed or in the local area of ​​the image to be processed.

[0070] In step S1600, a trace between the first control point and the second control point is determined according to the weight of each edge. The trace is a path with the minimum weight sum among all paths between the first control point and the second control point, where the weight sum is the sum of the weights of the edges included in the path.

[0071] It can be understood that there are multiple different paths between the first control point and the second control point. The edges included in each path are different. From these paths, according to the weights of the edges included therein, a path with the minimum weight can be selected as the trace.

[0072] Exemplarily, all paths between the first control point and the second control point can be traversed, and the sum of the weights of the edges included in each path can be calculated. According to the calculated sum, the path with the smallest sum of the weights of the edges included is taken as the trace. As mentioned above, the smaller the weight of the edge, the greater the probability that the edge is part of the trace. Therefore, in the above scheme, the trace is determined based on whether the sum of the weights of the edges included is the smallest among all the edges, which effectively ensures the accuracy of the determined trace.

[0073] In the above technical solution, the two endpoints of the trace are first determined, then the weight of the line between the pixels is determined using the degree of change in the pixel values ​​of the pixels, and finally, the trace between the two endpoints is automatically determined based on the weight of each edge. For the user, the operation of determining the trace is more convenient, which greatly improves the user's work efficiency. In addition, the trace determined by the technical solution is more accurate and the entire determination process is faster.

[0074] Exemplarily, the image to be processed may be a color image. Before calculating the gradient value of the pixel value of each pixel and its adjacent pixel values ​​according to the pixel value of each pixel in at least a local area of ​​the image to be processed in step S1400, the method may further include: graying the image to be processed so that in subsequent steps, calculation and processing are all performed based on the grayscale image.

[0075] As mentioned above, various technical means can be used to obtain the image to be processed, and this application does not limit this. For example, for ultrasound images with different functions, their color states are different. Some ultrasound images are grayscale images, such as B-ultrasound. Some ultrasound images are color images, such as Doppler color ultrasound. For color images, each pixel may have pixel values ​​of three channels: red, green, and blue. For each pixel, the pixel values ​​of these three channels jointly determine the color of the pixel. Exemplarily, the color image can be converted into a grayscale image using the following formula: Y=0.3R+0.59G+0.11B, where Y represents the grayscale value of the pixel, R represents the pixel value of the red channel of the pixel, G represents the pixel value of the green channel of the pixel, and B represents the pixel value of the blue channel of the pixel. After the image to be processed is grayed, it can be subsequently processed.

[0076] In the above technical solution, the three scalars of each pixel in the color image are converted into one scalar. The unique scalar is used as the basis for calculating the gradient value, and then the trace in the image is determined according to the gradient value. This can reduce the amount of calculation and speed up the operation. In addition, the image tracing method is applicable to various different images and has stronger universality.

[0077] As described above in step S1400, the gradient value can be calculated based on the pixel values ​​of the pixels in the local area of ​​the image to be processed. In subsequent steps S1500 and S1600, the image is traced based on the gradient values ​​calculated for the pixels in the local area. In one embodiment, the above-mentioned image tracing method may also include: step S1350, determining the local area according to the position of the first control point. The local area includes the first control point. In other words, the boundary of the local area surrounds the first control point.

[0078] It can be understood that the second control point determined by the user should also be within the local area, thereby smoothly determining the trace between the first control point and the second control point. In other words, the size of the local area should be suitable for the user to determine the second control point. Exemplarily, after the user determines the first control point, when the user moves the mouse to determine the second control point, if the cursor is located in the local area, the trace between the first control point and the second control point can be determined and displayed; if the cursor moves outside the local area, an alarm can be issued.

[0079] In the above technical solution, a local area is determined based on the first control point, and image tracing is performed in the local area. This not only reduces the amount of calculation and speeds up the operation compared to performing image tracing on the entire image to be processed, but also ensures that the first control point is within the local area compared to the solution of determining the local area based on the center of the image to be processed, thereby ensuring smooth image tracing.

[0080] In one embodiment, step S1350 includes: determining a rectangle or a circle centered on the position of the first control point as a local area. Rectangles and circles are both regular shapes, and determining a rectangular area or a circular area as a local area can facilitate determining pixels in the local area, and then determining a trace based on these pixels. Determining the rectangular or circular area with the position of the first control point as the center can facilitate locating the rectangular or circular area. Figure 2 FIG. 4 also shows a local area in an image to be processed according to an embodiment of the present invention. Figure 2 In FIG. 1 , a white “+” mark indicates a first control point determined by a user, and a red rectangular frame shows a boundary of a local area determined according to the first control point.

[0081] In a specific embodiment, the size of the image to be processed is 500*1000. A rectangular area can be determined as the local area with the first control point as the center of the rectangle. The length of the rectangular area can be 300 to 600, and the width can be 200 to 400. If the area of ​​the local area is too small, it is not only difficult for the user to determine the second control point in it, but also the length of the trace determined each time is too short due to the area limit of the local area; the size of the local area will increase the amount of calculation and reduce the calculation speed. The size of the rectangular area takes these considerations into account, which is convenient for the user to operate, thereby obtaining a trace of appropriate length, and effectively reduces the amount of calculation and ensures the calculation speed. In addition, in the above example, the first control point is used as the center of the local area, but this is not necessary. Alternatively, the first control point can be used as a pixel point in the left position of the local area. For example, first determine the center point of the right side of the first control point at a specific distance based on the first control point. Then determine the local area with the center point as the center of the local area. This makes it easy for the user to determine the second control point, so that the trace finally determined is roughly located at the center of the local area.

[0082] In the above technical solution, a rectangular area or a circular area is determined as the local area with the first control point as the center. This method can not only determine the position of the local area with less computational cost, but also the determined local area has a regular shape, which is convenient for subsequent determination of pixels and edges in the local area, and thus is conducive to determining the trace of the image.

[0083] In one embodiment, step S1400 calculates the gradient value of the pixel values ​​of the pixel point and its adjacent pixel points, including: calculating the gradient value of the pixel values ​​of the pixel point and its adjacent pixel points according to the difference between the pixel values ​​of the pixel point and its horizontally adjacent pixel points and vertically adjacent pixel points respectively.

[0084] Specifically, the gradient value of the pixel value between the pixel point and its adjacent pixel points can be calculated using the following formula.

[0085]

[0086] Among them, H represents the gradient value of the pixel value of the pixel point, G0 represents the pixel value of the pixel point, and G x+1 Represents the pixel value of the adjacent pixel to the right of the pixel, G y-1 Indicates the pixel value of the adjacent pixel below the pixel.

[0087] In the above embodiment, the difference between the pixel value of the pixel point and the pixel point adjacent to the bottom and right is calculated first. Then the gradient value of the pixel value of the pixel point can be determined according to the two calculated differences. It can be understood that for other pixel points in the image except those on the boundary, each pixel point has four pixel points of the top, bottom, left and right. In this embodiment, for each pixel point, only the difference between the pixel value of the pixel point to its right and below can be calculated. The difference between the pixel value of the pixel point and the pixel point above it can be used to calculate the gradient value of the pixel value of the pixel point above. The difference between the pixel value of the pixel point and the pixel point to its left can be used to calculate the gradient value of the pixel value of the pixel point to the left. Therefore, for each pixel point, its gradient can be calculated using only the pixel value of the pixel point to its right and below. Alternatively, its gradient can also be calculated using only the pixel value of the pixel point to its left and below, right and above, left and above.

[0088] The above technical solution is not only simple and easy to implement, but also the calculated gradient value better reflects the color change between pixels, thereby ensuring the accuracy of tracing.

[0089] In one embodiment, step S1500 calculates the weight of each edge according to the gradient value, including the following steps S1510 and S1520.

[0090] In step S1510, for each pixel point, the azimuth angle of the pixel point is calculated according to the difference in pixel values ​​between the pixel point and its lateral adjacent pixel points and the difference in pixel values ​​between the pixel point and its longitudinal adjacent pixel points.

[0091] As mentioned above, the horizontally adjacent pixel point can be the adjacent pixel point to the right. The vertically adjacent pixel point can be the adjacent pixel point below it. The formula (G0-G x+1 ) calculates the difference between the pixel value of the pixel and its adjacent pixel to the right. For the convenience of description, it is called the first difference. Using the formula (G0-G y-1 ) calculates the difference between the pixel value of the pixel point and the adjacent pixel point below it, referred to as the second difference. After obtaining the first difference and the second difference, the second difference can be divided by the first difference to obtain the quotient of the two, that is, (G0-G y-1 ) / (G0-G x+1 ). The inverse tangent of the quotient can be taken to determine the azimuth angle α, using the formula Calculate the azimuth angle α of the pixel.

[0092] In step S1520, based on the azimuth angle and the gradient value of the pixel values ​​of the pixel point and its adjacent pixel points, the weight of the edge between the pixel point and its transverse adjacent pixel points and the weight of the edge between the pixel point and its longitudinal adjacent pixel points are calculated.

[0093] First, the azimuth angle β obtained by rotating the azimuth angle α of the pixel point by 90 degrees clockwise can be determined, that is, β=α+90°. Then, the weight of the pixel point is calculated based on the rotated azimuth angle and the gradient value corresponding to the pixel point. Specifically, the weight Wx of the edge between the pixel point and the adjacent pixel point to its right is calculated according to the formula Wx=abs(H*cosβ), and the weight Wy of the edge between the pixel point and the adjacent pixel point below it is calculated according to the formula Wy=abs(H*sinβ). In this embodiment, after rotating the azimuth angle by 90 degrees, the obtained azimuth angle belongs to the interval (π / 2,π). In this interval, as β increases, the weights Wx and Wy decrease. This ensures that for each edge, its weight and the corresponding gradient value are inversely correlated.

[0094] In the above technical solution, the azimuth of the pixel point is first determined based on the difference in pixel values ​​of adjacent pixels, and then the weight of the edge associated with the pixel value is determined based on the azimuth and the gradient value corresponding to the pixel point. This solution ensures the accuracy of the image trace determined based on the edge weight.

[0095] Alternatively, for each edge, the sum of the gradient values ​​of the pixel values ​​of the adjacent pixels connected to the edge can be calculated. As mentioned above, the line between two adjacent pixels constitutes an edge, that is, the two adjacent pixels are the pixels connected by the edge. The sum of the gradient values ​​of the pixel values ​​of the pixels connected by the edge can be directly taken as the weight of the edge. For example, for each pixel, its gradient value H is added to the gradient value Hr of the pixel value of the adjacent pixel to its right, and the sum is taken as the reciprocal. The obtained reciprocal 1 / (H+Hr) can be used as the weight of the edge between the pixel and the adjacent pixel to its right. Similarly, 1 / (H+Hb) can be used as the weight of the edge between the pixel and the adjacent pixel below it, where Hb represents the gradient value of the pixel value of the adjacent pixel below the pixel.

[0096] This technical solution has a simple algorithm and fast calculation speed, which ensures the efficiency of image tracing.

[0097] In one embodiment, step S1600 of determining the trace between the first control point and the second control point according to the weight of each edge may include step S1610 and step S1620.

[0098] In step S1610, a minimum heap is established using the weight of each edge in at least a local area of ​​the image to be processed. A minimum heap is a data structure, and the elements in the minimum heap may include the weight of the edge.

[0099] In a minimum heap, the ordering basis of elements can be the weight of the edge. It can be understood that a heap is a data structure that automatically selects the maximum value according to the ordering basis. It is essentially a binary tree, and the maximum value appears at the top of the heap. Exemplarily, the heap can be a minimum heap. Figure 3 FIG. 4 shows a schematic diagram of a minimum heap according to an embodiment of the present application. Figure 3 As shown, in the minimum heap, the minimum value "3" is at the top of the heap. For the minimum heap according to an embodiment of the present invention, the elements in the minimum heap can be swapped according to the weight of the edge, and the element with the minimum weight is finally at the top of the heap. Each time an element is taken from the top of the heap, the minimum heap will automatically adjust, and a new element with the minimum weight will appear at the top of the heap.

[0100] It can be understood that by taking out elements from the top of the heap one by one, an ordered sequence of elements with weights from small to large can be obtained.

[0101] The elements in the minimum heap may also include the position information of the pixels connected by the edge, such as the coordinates of the pixels. As mentioned above, the line between two adjacent pixels constitutes an edge. In other words, each edge directly connects two adjacent pixels. The coordinates of the two adjacent pixels directly connected by the edge may be included in the elements of the minimum heap, and the coordinates may be used to locate the edge, i.e., represent the position of the edge.

[0102] In step S1620, based on the elements in the minimum heap and using a recursive method, among all paths between the first control point and the second control point, the weights of the edges included in the path and the minimum path are determined.

[0103] In step S1610, a minimum heap is established with all the edges in at least a local area of ​​the image to be processed as elements. In step S1620, based on the elements in the minimum heap, a desired path is found in all paths between the first control point and the second control point, and the weight sum of the edges included in the desired path is the smallest among all paths. Specifically, the first control point can be set as the starting point of the trace, and the element at the top of the minimum heap is selected. It is determined whether the two adjacent pixels connected by the edge corresponding to the element include the starting point, that is, the first control point, and the other pixel of the two adjacent pixels is not in the desired path. If true, the edge is incorporated into the desired path, and the other pixel connected by the edge except the starting point is used as a new starting point. Based on the above steps, the starting point and the new top element of the heap are recursively selected and incorporated into the desired path until the edge where the second control point is located is incorporated into the desired path. Thus, the desired path between the first control point and the second control point formed by the edges incorporated into the path, that is, the trace between the two control points, is determined.

[0104] In the above technical solution, the trace between two control points is determined based on the minimum heap and a recursive method. This solution can not only quickly determine the trace between the control points, but also the determined trace is more accurate and does not generate redundant trace lines.

[0105] Figure 4 FIG. 1 is a schematic flow chart showing step S1620 according to an embodiment of the present application, which is based on a minimum heap and uses a recursive method to determine the weights of the edges included in the path and the minimum path among all the paths between the first control point and the second control point. Figure 4 As shown, step S1620 may include the following steps S1621, S1622 and S1623.

[0106] In step S1621, taking any control point of the first control point and the second control point as a starting point, a first element is searched in the minimum heap, wherein the edge corresponding to the first element is an edge connecting the starting points and having the smallest weight.

[0107] In step S1622, the following search operation is performed in a loop until the element corresponding to the edge connecting the end point is found. The end point is another control point other than the starting point among the first control point and the second control point. The above-mentioned search operation includes: deleting the found element in the current minimum heap to obtain an updated minimum heap; searching for the second element in the current minimum heap. The edge corresponding to the second element is the edge with the smallest weight among the connected deleted edges. The deleted edge is the edge corresponding to the deleted element. It can be understood that the current minimum heap lacks the deleted elements relative to the original minimum heap. These elements can be considered as a whole, and the edge with the smallest weight is determined among all the edges directly connected to the whole. The element corresponding to the edge is the second element. For the loop operation in step S1622, if an element is found, and the edge corresponding to the element connects the end point, the loop operation is terminated.

[0108] In step S1623, based on the found elements, a path with the smallest sum of weights of edges included in all paths is determined.

[0109] Figure 5A FIG. 6 shows an enlarged schematic diagram of a local area 600 according to an embodiment of the present invention. Figure 5A The local area 600 shown includes 6 pixels A to F. The lines between the pixels represent edges. The numbers next to the edges represent the weights of the edges. Figure 5B Shown in Figure 5A Schematic diagram of the trace of the determined image in the local area shown. Figure 5A In the example, the first control point is pixel A, which is the starting point of the trace. The second control point is pixel F, which is the ending point of the trace. Figure 5A and Figure 5B The execution process of the above step S1620 is described.

[0110] First, the first element is found in the minimum heap according to the starting point. In this embodiment, the starting point is pixel A. The edges connected to pixel A include AB edge and AC edge. The weight of AB edge is 1, and the weight of AC edge is 4, so the edge with the smallest weight among the two is AB edge. Then the first element corresponding to AB edge in the minimum heap is found. Then the AB edge is incorporated into the pending path, and the predecessor pixel of pixel B is recorded as A, the first element is deleted in the minimum heap, and the updated minimum heap is obtained. Based on the pixel B connected to the edge AB corresponding to the starting point A and the first element just deleted, the first second element is found in the current minimum heap. The first second element is the element with the smallest weight of the corresponding edge connecting pixel A or B. Among the edges corresponding to all elements of the current minimum heap, the edges connected to pixel A or B include AC edge, BD edge and BE edge. The weight of AC edge is 4, the weight of BD edge is 2, and the weight of BE edge is 5. Therefore, the weight of the BD edge is the smallest. At the same time, it is determined that the pixel points connected by the BD edge include the pixel point B that has been incorporated into the pending path, and the other pixel point D is not in the pending path. Then the first second element is the element corresponding to the BD edge. The BD edge is incorporated into the pending path, and the predecessor pixel point of the pixel point D is recorded as B. The element is deleted to obtain the updated minimum heap. Based on the starting point A and the pixels B and D connected by the edge BD corresponding to the second element just deleted, the second second element is found in the current minimum heap. Among the edges corresponding to all elements of the current minimum heap, the edges connected by the pixel points A or B or D include AC, CD, BE and DF. The weight of the AC edge is 4, the weight of the CD edge is 7, the weight of the BE edge is 5, and the weight of the DF edge is 1. Thus, the weight of the DF edge is the smallest. At the same time, it is determined that the pixel points connected by the edge contained in the element DF include the pixel point D that has been incorporated into the pending path, and the other pixel point F is not in the pending path. Then the second second element is the element corresponding to the DF edge. The DF edge is incorporated into the pending path, and the predecessor pixel point of the pixel point F is recorded as D. The element is deleted to obtain the updated minimum heap. At the same time, it is found that the pixel point corresponding to the DF edge includes the second control point F. The search operation executed in the loop is terminated. In the pending path, based on the predecessor pixel point D of the second control point F, the predecessor pixel point B of the pixel point D is found, and then the predecessor pixel point of the pixel point B is found as A, and finally the weight of the edge included therein and the minimum path are determined, that is, the trace between the two control points.

[0111] The above-mentioned image tracing method can be applied to the tracing of ultrasound images. Ultrasound images such as B-ultrasound images and Doppler color ultrasound images. According to one embodiment of the present application, first, an ultrasound image can be acquired and displayed using an ultrasound device for the physician to view. The physician can operate the ultrasound image while observing the ultrasound image. In response to the physician's operation of determining a first control point in the displayed ultrasound image, the position of the first control point is determined. After the physician determines the first control point, a first local area centered on the first control point can be determined in the ultrasound image. The subsequent operation of determining the tracing starting from the first control point is performed in the first local area. The physician can use the mouse to operate the cursor displayed on the screen, and the tracing between the first control point and the pixel point where the current cursor is located can be automatically calculated and displayed. The displayed tracing can be highlighted or can be a different color from the pixel value of the pixel in the ultrasound image. Fig. 6A A schematic diagram of an ultrasound image according to another embodiment of the present application is shown. As shown in the figure, the physician determines a first control point as the starting point of the tracing in the ultrasound image, and can further operate the cursor, which is shown as a white "cross" in the figure. In the process of operating the cursor, the tracing between the first control point and the pixel point where the current cursor is located is displayed in the ultrasound image, that is, the green line in the figure. Optionally, in the embodiment of determining the tracing in the local area in the ultrasound image, the determined tracing is displayed only when the cursor is located in the local area; when the cursor moves outside the local area, the tracing is not displayed. Then, in response to the physician's operation of determining the second control point in the displayed ultrasound image, the position of the second control point is determined. For example, the physician can click the left mouse button again to confirm the position of the second control point. After determining the second control point, the calculations of steps S1400 to S1600 can be performed to determine the tracing between the first control point and the second control point. Figure 6B An ultrasound image is shown in which a trace between a first control point and a second control point has been drawn according to an embodiment of the present invention. The first control point as the starting point of the trace is at the portrait position in the figure, the position of the green mark "1" is the second control point as the ending point of the trace, and the green line shows the drawn trace.

[0112] Similarly, the second local area centered on the second control point can also be determined. When the cursor continues to move in the second local area centered on the second control point, the trace between the second control point and the pixel where the cursor is currently located can be automatically calculated and displayed. When the physician clicks the left mouse button again to confirm the position of another control point, the trace between the second control point and the other control point can be determined. It can be understood that the trace starting from the second control point will not affect the trace between the first control point and the second control point. By repeating this process, multiple traces can be determined, and the multiple traces can more accurately outline the edge of the target.

[0113] Fig. 7A shows an ultrasound image with a trace drawn based on the prior art, Figure 7B FIG. 2 shows an ultrasound image in which a trace is determined according to one embodiment of the present invention. Fig. 7A and Figure 7B In the figure, the green line is the drawn trace. It can be understood that the edge of the target in the ultrasound image is usually not very clear, and the existing trace method is prone to errors and inefficiency. Fig. 7A and Figure 7B It can be seen from the comparison that the trace drawn according to the present application is closer to the edge of the target in the ultrasound image, has high accuracy and no erroneous lines.

[0114] According to another aspect of the present application, an image tracing system is provided. Figure 8 FIG. 8 is a schematic block diagram of an image tracing system 800 according to an embodiment of the present application.

[0115] like Figure 8 As shown, the image tracing system 800 according to the embodiment of the present application includes an image acquisition module 810, a first determination module 820, a second determination module 830, a first calculation module 840, a second calculation module 850 and a tracing module 860. Each module can respectively execute the above Figure 1 The following describes the steps of the image tracing method 1000. Only the main functions of the components of the image tracing system 800 are described below, and the details described above are omitted.

[0116] The image acquisition module 810 is used to acquire and display the image to be processed.

[0117] The first determining module 820 is used to determine the position of the first control point in response to the user's operation of determining the first control point in the displayed image to be processed.

[0118] The second determining module 830 is used to determine the position of the second control point in response to the user's operation of determining the second control point in the displayed image to be processed.

[0119] The first calculation module 840 is used to calculate the gradient value of the pixel value of each pixel and its adjacent pixel values ​​according to the pixel value of each pixel in at least a local area of ​​the image to be processed.

[0120] The second calculation module 850 is used to calculate the weight of each edge according to the gradient value, wherein a line between two adjacent pixels constitutes an edge, and the weight of each edge is inversely correlated with the corresponding gradient value.

[0121] The tracing module 860 is used to determine the tracing between the first control point and the second control point according to the weight of each edge, wherein the tracing is the path with the minimum weight sum among all paths between the first control point and the second control point. The weight sum is the sum of the weights of the edges included in the path.

[0122] Exemplarily, the tracing module 860 includes a heap building submodule and a recursive submodule. The heap building submodule is used to build a minimum heap using the weight of each edge. The elements in the minimum heap include the weight of the edge. The recursive submodule is used to determine the weight of the edge included in the path and the minimum path among all paths between the first control point and the second control point based on the elements in the minimum heap and using a recursive method.

[0123] Exemplarily, the recursive submodule includes a first search unit, a loop execution unit and a path determination unit. The first search unit is used to find the first element in the minimum heap with any control point of the first control point and the second control point as the starting point. The edge corresponding to the first element is the edge connecting the starting point and having the smallest weight. The loop execution unit is used to loop through the following search operations until the element whose corresponding edge connects the end point is found. The search operation includes: deleting the found element in the current minimum heap to obtain an updated minimum heap, and searching for the second element in the current minimum heap, the edge corresponding to the second element is the edge with the smallest weight in the edge connecting the deleted edge, the deleted edge is the edge corresponding to the deleted element, and the end point is another control point other than the starting point in the first control point and the second control point. The path determination unit is used to determine the path with the smallest weight and edge included in all paths based on the found element.

[0124] Exemplarily, the first calculation module 840 includes a gradient value calculation submodule, which is used to calculate the gradient value of the pixel value of the pixel point and its adjacent pixel points based on the difference between the pixel value of the pixel point and its horizontally adjacent pixel points and vertically adjacent pixel points respectively.

[0125] Exemplarily, the second calculation module 850 includes an azimuth calculation submodule and a weight calculation submodule. The azimuth calculation submodule is used to calculate the azimuth of each pixel point according to the difference in pixel values ​​between the pixel point and its horizontally adjacent pixel points and the difference in pixel values ​​between the pixel point and its vertically adjacent pixel points. The weight calculation submodule is used to calculate the weight of the edge between the pixel point and its horizontally adjacent pixel points and the weight of the edge between the pixel point and its vertically adjacent pixel points based on the azimuth and the gradient value of the pixel value between the pixel point and its adjacent pixel points.

[0126] Exemplarily, the image tracing system 800 further includes a local area determination module. The local area determination module is used to determine the local area according to the position of the first control point before the first calculation module 830 calculates the gradient value of the pixel value of each pixel point and the pixel value of its adjacent pixel points according to the pixel value of each pixel point in at least the local area of ​​the image to be processed. The local area includes the first control point.

[0127] Exemplarily, the local area determination module includes a regular area determination submodule. The regular area determination submodule is used to determine a rectangular area or a circular area centered at the position of the first control point as the local area.

[0128] The image tracing system 800 further includes a grayscale module, which is used to grayscale the image to be processed before the first calculation module 830 calculates the gradient value of the pixel value of each pixel point and its adjacent pixel points according to the pixel value of each pixel point in at least a local area of ​​the image to be processed.

[0129] According to an embodiment of the present application, an electronic device is provided, including a processor and a memory. The memory stores computer program instructions and parameters required by the program instructions, and the processor is used to run the computer program instructions stored in the memory to perform corresponding steps of the image tracing method according to the embodiment of the present application.

[0130] In one embodiment, the computer program instructions are used by the processor to perform the following steps when executed: acquiring and displaying an image to be processed; determining the position of the first control point in response to a user's operation of determining a first control point in the displayed image to be processed; determining the position of the second control point in response to a user's operation of determining a second control point in the displayed image to be processed; calculating the gradient value of the pixel value of each pixel point and its adjacent pixel points according to the pixel value of each pixel point in at least a local area of ​​the image to be processed; calculating the weight of each edge according to the gradient value, wherein a line between two adjacent pixels constitutes an edge, and the weight of each edge is inversely correlated with the corresponding gradient value; determining the trace between the first control point and the second control point according to the weight of each edge, wherein the trace is a path with the smallest weight sum among all paths between the first control point and the second control point. The weight sum is the sum of the weights of the edges included in the path.

[0131] In addition, according to an embodiment of the present application, a storage medium is also provided, on which program instructions and parameters required for the program instructions are stored, and when the program instructions are executed by a computer or a processor, the corresponding steps of the image tracing method of the embodiment of the present application are executed, and the corresponding modules in the image tracing system according to the embodiment of the present application are implemented. The storage medium may include, for example, a storage component of a tablet computer, a hard disk of a personal computer, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a portable read-only memory (CD-ROM), a USB memory, or any combination of the above storage media.

[0132] In one embodiment, when the program instructions are executed by a computer or a processor, the computer or the processor may implement various functional modules of the image tracing system according to the embodiment of the present application, and / or may execute the image tracing method according to the embodiment of the present application.

[0133] In one embodiment, the program instructions are used to perform the following steps when running: used to perform the following steps: acquiring and displaying an image to be processed; determining the position of the first control point in response to a user's operation of determining a first control point in the displayed image to be processed; determining the position of the second control point in response to a user's operation of determining a second control point in the displayed image to be processed; calculating the gradient value of the pixel value of each pixel point and its adjacent pixel points according to the pixel value of each pixel point in at least a local area of ​​the image to be processed; calculating the weight of each edge according to the gradient value, wherein a line between two adjacent pixels constitutes an edge, and the weight of each edge is inversely correlated with the corresponding gradient value; determining the trace between the first control point and the second control point according to the weight of each edge, wherein the trace is a path with the smallest weight sum among all paths between the first control point and the second control point. The weight sum is the sum of the weights of the edges included in the path.

[0134] A person skilled in the art may understand the specific implementation scheme and beneficial effects of the above-mentioned image tracing system, electronic device and storage medium by reading the above-mentioned description of the image tracing method, and will not be described in detail here for the sake of brevity.

[0135] Although example embodiments have been described herein with reference to the accompanying drawings, it should be understood that the above example embodiments are merely exemplary and are not intended to limit the scope of the present application to this. Those of ordinary skill in the art may make various changes and modifications therein without departing from the scope and spirit of the present application. All these changes and modifications are intended to be included within the scope of the present application as required by the appended claims.

[0136] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed.

[0137] It will be understood by those skilled in the art that, except for mutually exclusive features, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this specification may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature that provides the same, equivalent or similar purpose.

[0138] The various component embodiments of the present application can be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) can be used in practice to implement some or all functions of some modules in the image tracing system according to the embodiment of the present application. The present application can also be implemented as a device program (e.g., computer program and computer program product) for executing a part or all of the methods described herein. Such a program implementing the present application can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

Claims

1. An image tracing method, characterized in that: include: Acquire and display the image to be processed; In response to a user's operation of determining a first control point in the displayed image to be processed, determining a position of the first control point; In response to a user's operation of determining a second control point in the displayed image to be processed, determining a position of the second control point; Calculate the gradient value of the pixel value between the pixel point and its adjacent pixel points according to the pixel value of each pixel point in at least a local area of ​​the image to be processed; Calculating the weight of each edge according to the gradient value, wherein a line between two adjacent pixels constitutes an edge, and the weight of each edge is inversely correlated with the corresponding gradient value; and A trace between the first control point and the second control point is determined according to the weight of each edge, wherein the trace is a path with the smallest sum of weights among all paths between the first control point and the second control point, and the sum of weights is the sum of weights of the edges included in the path.

2. The image tracing method according to claim 1, characterized in that: Determining the trace between the first control point and the second control point according to the weight of each edge includes: Using the weight of each edge, a minimum heap is established, wherein the elements in the minimum heap include the weight of the edge; Based on the elements in the minimum heap and using a recursive method, among all paths between the first control point and the second control point, the weights of the edges included in the path and the minimum path are determined.

3. The image tracing method according to claim 2, characterized in that: The method of determining the weights of the edges included in the paths and the minimum path among all the paths between the first control point and the second control point based on the minimum heap and using a recursive method comprises: Taking any control point of the first control point and the second control point as a starting point, searching for a first element in the minimum heap, wherein an edge corresponding to the first element is an edge connecting the starting point and having the smallest weight; The following search operation is performed in a loop until an element of the corresponding edge connecting the end point is found, wherein the search operation includes: deleting the found element in the current minimum heap to obtain an updated minimum heap, searching for a second element in the current minimum heap, the edge corresponding to the second element is the edge with the smallest weight among the edges connected to the deleted edge, the deleted edge is the edge corresponding to the deleted element, and the end point is another control point other than the starting point among the first control point and the second control point; Based on the found elements, a path among all the paths having the smallest sum of weights of the edges included in the path is determined.

4. The image tracing method according to any one of claims 1 to 3, characterized in that: The step of calculating the gradient value of the pixel value between the pixel point and the pixel value of the adjacent pixel points according to the pixel value of each pixel point in at least a local area of ​​the image to be processed comprises: The gradient value of the pixel value of the pixel point and its adjacent pixel points is calculated according to the difference between the pixel value of the pixel point and its horizontally adjacent pixel points and the vertically adjacent pixel points respectively.

5. The image tracing method according to claim 4, characterized in that: Calculating the weight of each edge according to the gradient value includes: For each pixel, calculating the azimuth of the pixel according to the difference between the pixel value and its adjacent pixel value in the horizontal direction and the difference between the pixel value and its adjacent pixel value in the vertical direction; and Based on the azimuth angle and the gradient value of the pixel values ​​of the pixel point and its adjacent pixel points, the weight of the edge between the pixel point and its transversely adjacent pixel points and the weight of the edge between the pixel point and its longitudinally adjacent pixel points are calculated.

6. The image tracing method according to any one of claims 1 to 3, characterized in that: Before calculating the gradient value of the pixel value of each pixel point and its adjacent pixel points according to the pixel value of each pixel point in at least a local area of ​​the image to be processed, the method further includes: The local area is determined according to the position of the first control point, wherein the local area includes the first control point.

7. The image tracing method according to claim 6, characterized in that: The determining the local area according to the position of the first control point includes: A rectangular area or a circular area centered at the position of the first control point is determined as the local area.

8. The image tracing method according to any one of claims 1 to 3, characterized in that: The image to be processed is a color image, Before calculating the gradient value of the pixel value of each pixel point and its adjacent pixel points according to the pixel value of each pixel point in at least a local area of ​​the image to be processed, the method further includes: The image to be processed is grayed out.

9. An image tracing system, characterized in that: include: An image acquisition module, used for acquiring and displaying the image to be processed; A first determining module, configured to determine a position of a first control point in response to a user's operation of determining the first control point in the displayed image to be processed; A second determining module, configured to determine a position of a second control point in response to a user's operation of determining the second control point in the displayed image to be processed; A first calculation module, used for calculating a gradient value of a pixel point and a pixel value of an adjacent pixel point according to a pixel value of each pixel point in at least a local area of ​​the image to be processed; A second calculation module is used to calculate the weight of each edge according to the gradient value, wherein a line between two adjacent pixels constitutes an edge, and the weight of each edge is inversely correlated with the corresponding gradient value; as well as A tracing module is used to determine a tracing between the first control point and the second control point according to the weight of each edge, wherein the tracing is a path with the smallest weight sum among all paths between the first control point and the second control point, and the weight sum is the sum of the weights of the edges included in the path.

10. An electronic device comprising a processor and a memory, characterized in that: The memory stores computer program instructions, which are used by the processor to execute the image tracing method according to any one of claims 1 to 8 when the processor executes the computer program instructions.

11. A storage medium having program instructions stored thereon, characterized in that: The program instructions are used to execute the image tracing method according to any one of claims 1 to 8 when running.