Image segmentation method, device, equipment and storage medium
By using gradient point sets to generate edge paths in image segmentation, the problem of difficulty in obtaining sample sets and noise sensitivity in image segmentation of various types of targets is solved, and high-accuracy image segmentation is achieved without relying on sample sets.
Patent Information
- Application Number
- CN202010139053.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-03
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2040-03-03
AI Technical Summary
The existing technology is difficult to process images of multiple types of targets in image segmentation. Especially when segmenting SKU images, sample sets are difficult to collect, and segmentation methods based on color features are sensitive to noise, resulting in local segmentation errors. Methods based on saliency are adapted to Poor sex.
By obtaining the gradient point set of the image, dividing it into subsets with different gradient values, generating first and second edge paths, and processing these paths to obtain closed edges, thereby achieving image segmentation and avoiding the need for sample sets. dependence and reduce the impact of noise.
Without the need for a training sample set, the image can be effectively segmented, ensuring that boundary points with high gradient values generate edge paths first, improving the accuracy and adaptability of segmentation, and reducing local segmentation errors.
Smart Images

Figure CN112288764B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to an image segmentation method, apparatus, device and readable storage medium. Background Art
[0002] Image segmentation technology is the foundation of computer vision, an important part of image analysis, and one of the most difficult problems in image processing. Image segmentation refers to dividing an image into several non-intersecting regions based on features such as grayscale, color, spatial texture, and geometric shape, so that these features show consistency or similarity in the same region, but show obvious differences between different regions. Image segmentation can be used to separate the target from the background in an image. Image segmentation technology is widely used. For example, in the process of intelligent page decoration of e-commerce online stores, it is necessary to segment the target (product image) from the stock keeping unit (SKU) image and merge it with the store template page.
[0003] In some related technologies, machine learning methods such as deep learning are used for image segmentation, but there are many types of SKU image targets, and sample sets are difficult to collect, which makes it difficult to learn the characteristics of the targets through machine learning methods.
[0004] In other related technologies, such as the threshold segmentation method, the basic principle is to set different feature thresholds to divide image pixels into several categories of target areas and background areas with different gray levels. This method is suitable for images where the target and background occupy different gray level ranges. However, this method is based on the color features of the image for segmentation, without considering the structural graphic features. Therefore, it is sensitive to noise and easily leads to problems such as local segmentation errors.
[0005] In other related technologies, such as the segmentation method based on image saliency, this method relies on the triplicate map to segment the object of interest from the image. Usually the triplicate map contains the foreground (target) part marked as white, the background part marked as black, and the uncertain part marked as gray. However, when a large number of images need to be segmented, such as SKU images, the triplicate map cannot be provided for all of them, resulting in poor adaptability of this method.
[0006] As mentioned above, how to provide an image segmentation method applicable to a large number of multiple types of targets has become an urgent problem to be solved.
[0007] The above information disclosed in this Background section is only for enhancement of understanding of the background of the present disclosure and therefore it may contain information that does not constitute the prior art that is already known to one of ordinary skill in the art. Summary of the invention
[0008] The purpose of the present disclosure is to provide an image segmentation method, apparatus, device and readable storage medium, which at least to some extent overcome the problem that it is difficult to collect sample sets of multiple types of target images due to related technologies.
[0009] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.
[0010] According to one aspect of the present disclosure, there is provided an image segmentation method, comprising: obtaining a gradient point set of an image, the gradient point set comprising a plurality of gradient points representing grayscale changes of pixel points in the image; dividing the gradient point set into a plurality of gradient point subsets, the plurality of gradient point subsets comprising a first gradient point subset and a second gradient point subset, wherein the gradient values of the gradient points in the first gradient point subset are greater than the gradient values of the gradient points in the second gradient point subset; generating a first edge path according to the first gradient point subset; generating a second edge path according to the second gradient point subset and the first edge path; and processing the second edge path to obtain a closed edge to segment the image.
[0011] According to an embodiment of the present disclosure, generating a first edge path according to the first gradient point subset includes: obtaining a first initial gradient point and a first growing gradient point in the first gradient point subset, wherein the distance between the first growing gradient point and the first initial gradient point is not greater than a first preset value; obtaining a first edge growth function according to the first initial gradient point and the first growth gradient point, wherein the first edge growth function is an edge growth function with the first initial gradient point as a reference point, and the edge growth function is a continuously differentiable function representing the change of the gradient value with the coordinates of the point on the image, and the coordinates include an angle component and a step component; obtaining a first growth point according to the first edge growth function, wherein the first growth point is the point where the function value of the first edge growth function is the largest when the step component is a second preset value, and the second preset value is less than the first preset value; generating the first edge path according to the first initial gradient point and the first growth point based on the first edge growth function.
[0012] According to an embodiment of the present disclosure, generating the first edge path according to the first initial gradient point and the first growth point based on the first edge growth function includes: obtaining a first directional growth function according to the first edge growth function and a first growth constraint term, wherein the first growth constraint term is used to constrain the angular growth amount of the second growth point, the first directional growth function is a directional growth function with the first growth point as the reference point and the second preset value as the step growth amount, and the directional growth function represents a function of the gradient value changing with the angular growth amount of the point on the image; obtaining the second growth point according to the first directional growth function through a gradient ascent iterative algorithm, wherein the second growth point is the point with the largest function value of the first directional growth function; connecting the first initial gradient point, the first growth point and the second growth point in sequence to generate the first edge path.
[0013] According to an embodiment of the present disclosure, generating a second edge path according to the second gradient point subset and the first edge path includes: taking the endpoint of the first edge path as a second initial gradient point; obtaining a second growth gradient point in the second gradient point subset, wherein the distance between the second growth gradient point and the second initial gradient point is not greater than a third preset value; obtaining a second edge growth function according to the second initial gradient point and the second growth gradient point, wherein the second edge growth function is an edge growth function with the second initial gradient point as a reference point; obtaining a third growth point according to the second edge growth function, wherein the third growth point is the value of the step size component when the step size component is the fourth preset value. The point where the function value of the second edge growth function is the largest, and the fourth preset value is less than the third preset value; the second directional growth function is obtained according to the second edge growth function and the second growth constraint term, wherein the second growth constraint term is used to constrain the angular growth amount of the fourth growth point, and the second directional growth function is a directional growth function with the third growth point as the reference point and the fourth preset value as the step growth amount; the fourth growth point is obtained according to the second directional growth function through the gradient ascent iterative algorithm, wherein the fourth growth point is the point where the function value of the second directional growth function is the largest; the second initial gradient point, the third growth point and the fourth growth point are connected in sequence to generate the second edge path.
[0014] According to an embodiment of the present disclosure, the second edge path includes a plurality of sub-paths; the processing of the second edge path includes: sorting each of the plurality of sub-paths from most to least according to the number of the gradient points included in the sub-paths to obtain a sub-path sequence; calculating the initial total energy of the initial path set according to the total energy function, wherein the total energy function is used to characterize the segmentation of the path for the image; selecting the first sub-path ranked first from the sub-path sequence and putting it into the initial path set to obtain a current path set, wherein the initial path set is an empty set; excluding the first sub-path from the sub-path sequence to obtain a current sub-path sequence; Calculate the first total energy of the first subpath in the current path set according to the total energy function, and obtain the current total energy as the first total energy; traversal step: select the second subpath ranked first from the current subpath sequence and put it into the current path set, update the current path set, and obtain the current selected subpath as the second subpath; energy calculation step: calculate the second total energy of the current edge path according to the total energy function, and the current edge path is obtained by connecting the subpaths in the current path set; determine whether the second total energy is less than the current total energy; if the second total energy is not less than the current total energy, remove the currently selected subpath from the current The path set is excluded, the current path set is updated, and it is determined whether there is a subpath in the current subpath sequence that is ranked after the currently selected subpath; if there is no subpath in the current subpath sequence that is ranked after the currently selected subpath, a closed edge for segmenting the image is obtained according to the current edge path; if there is a subpath in the current subpath sequence that is ranked after the currently selected subpath, the third subpath that is ranked after the currently selected subpath is selected and put into the current path set, the current path set is updated, and the currently selected subpath is obtained as the third subpath, and the energy calculation step is returned; the second total energy is less than the current total energy, and the closed edge for segmenting the image is obtained according to the current edge path; Connect the sub-paths on the current edge path, exclude each sub-path in turn, and calculate the third total energy of the edge path obtained by connecting the remaining sub-paths according to the total energy function; determine whether the third total energy is less than the second total energy; if the third total energy is less than the second total energy, remove the excluded sub-path corresponding to the third total energy from the current path set, update the current path set, update the current total energy to the second total energy, and return to the traversal step; if the third total energy is not less than the second total energy, exclude the currently selected sub-path from the current sub-path sequence, update the current sub-path sequence, and return to the traversal step.
[0015] According to one embodiment of the present disclosure, the total energy function is the sum of an envelope energy function, a length energy function and a connection energy function, wherein: the envelope energy function is used to characterize the average distance between the sub-path and the boundary of the image; the length energy function is used to characterize the number of gradient points on the sub-path; and the connection energy function is used to characterize the degree of curvature of the sub-paths after being connected to each other.
[0016] According to one embodiment of the present disclosure, the processing of the second edge path includes: updating the coordinates of each connection point on the second edge path on the image based on the total adjustment energy function until the increase in the total adjustment energy function value is less than a fifth preset value, wherein the total adjustment energy function is obtained by adding an edge growth function and a connection constraint term, the edge growth function is a continuously differentiable function representing the change of gradient value with the coordinates of the points on the image, and the total adjustment energy function value is obtained by substituting the coordinates of the each connection point into the total adjustment energy function.
[0017] According to another aspect of the present disclosure, an image segmentation device is provided, comprising: a gradient point acquisition module, used to obtain a gradient point set of an image, the gradient point set comprising a plurality of gradient points representing grayscale changes of pixel points in the image; a gradient point classification module, used to divide the gradient point set into a plurality of gradient point subsets, the plurality of gradient point subsets comprising a first gradient point subset and a second gradient point subset, wherein the gradient values of the gradient points in the first gradient point subset are greater than the gradient values of the gradient points in the second gradient point subset; an edge growing module, used to generate a first edge path according to the first gradient point subset; the edge growing module is further used to generate a second edge path according to the second gradient point subset and the first edge path; and a path processing module, used to process the second edge path to obtain a closed edge to segment the image.
[0018] According to another aspect of the present disclosure, a device is provided, comprising: a memory, a processor, and executable instructions stored in the memory and executable in the processor, wherein the processor implements any of the above methods when executing the executable instructions.
[0019] According to another aspect of the present disclosure, a computer-readable storage medium is provided, on which computer-executable instructions are stored, and when the executable instructions are executed by a processor, any of the above methods is implemented.
[0020] The image segmentation method provided by the embodiments of the present disclosure obtains a gradient point set representing the grayscale changes of pixel points of the image, divides the gradient point set into multiple gradient point subsets according to the gradient value, generates a first edge path according to the first gradient point subset in order from high to low gradient values, and then generates a second edge path according to the second gradient point subset and the first edge path, and finally processes the second edge path to obtain a closed edge to segment the image, thereby achieving image segmentation without the need for a training sample set, and ensuring that edge paths are generated preferentially for boundary points with high gradient values.
[0021] It is to be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The above and other objects, features and advantages of the present disclosure will become more apparent by describing in detail example embodiments thereof with reference to the attached drawings.
[0023] Figure 1 A schematic diagram showing the structure of an image segmentation system in an embodiment of the present disclosure.
[0024] Figure 2 A flow chart of an image segmentation method in an embodiment of the present disclosure is shown.
[0025] Figure 3 A flowchart of another image segmentation method in an embodiment of the present disclosure is shown.
[0026] Figure 4 A flow chart of an edge path processing method for image segmentation in an embodiment of the present disclosure is shown.
[0027] Figure 5 A schematic diagram of path boundary distance in an embodiment of the present disclosure is shown.
[0028] Figure 6 A schematic diagram of a sub-path connection method in an embodiment of the present disclosure is shown.
[0029] Figure 7 A flow chart showing another edge path processing method for image segmentation in an embodiment of the present disclosure.
[0030] Figure 8 A block diagram of an image segmentation device in an embodiment of the present disclosure is shown.
[0031] Fig. 9 A block diagram of another image segmentation device in an embodiment of the present disclosure is shown.
[0032] Fig.10 A schematic structural diagram of an electronic device in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0033] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the disclosure will be more comprehensive and complete and will fully convey the concepts of the example embodiments to those skilled in the art. The accompanying drawings are only schematic illustrations of the disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and thus their repeated description will be omitted.
[0034] In addition, the described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, devices, steps, etc. may be adopted. In other cases, well-known structures, methods, devices, implementations or operations are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0035] In addition, the terms "first", "second", etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present disclosure, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. The symbol " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0036] In this disclosure, unless otherwise clearly specified and limited, terms such as "connection" should be understood in a broad sense, for example, it can be an electrical connection or can communicate with each other; it can be directly connected or indirectly connected through an intermediate medium. For ordinary technicians in this field, the specific meanings of the above terms in this disclosure can be understood according to specific circumstances.
[0037] As mentioned above, in some related technologies, it is difficult to collect sample sets for SKU images with a wide variety of target types using machine learning methods such as deep learning, which makes it difficult to learn the characteristics of the target through machine learning methods; in other related technologies, segmentation based only on the color features of the image is sensitive to noise, which easily leads to problems such as local segmentation errors; in other related technologies, the segmentation method based on image saliency relies on a trigraph to segment the target of interest from the image, and when a large number of images need to be segmented, the trigraph cannot be provided for all, resulting in poor adaptability of this method. Therefore, the present disclosure provides an image segmentation method, by obtaining a gradient point set representing the grayscale change of a pixel point of an image, dividing the gradient point set into a plurality of gradient point subsets according to the size of the gradient value, generating a first edge path according to the first gradient point subset in order from high to low gradient values, and then generating a second edge path according to the second gradient point subset and the first edge path, and finally processing the second edge path to obtain a closed edge to segment the image, thereby achieving image segmentation without the need for a training sample set, and ensuring that the edge path is generated preferentially by the boundary points with high gradient values.
[0038] Figure 1 An exemplary system architecture 100 to which the image segmentation method or image segmentation apparatus disclosed in the present invention can be applied is shown.
[0039] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0040] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as image recognition applications, online store decoration applications, etc.
[0041] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0042] The server 105 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 101, 102, and 103. The backend management server may analyze and process the received initial image and other data, and feed back the image segmentation result to the terminal device.
[0043] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0044] Figure 2 FIG. 1 is a flow chart of an image segmentation method according to an exemplary embodiment. Figure 2 The image segmentation method shown can be applied to the server side of the above system, for example, and can also be applied to the terminal device of the above system.
[0045] refer to Figure 2 , the method 20 provided in the embodiment of the present disclosure may include the following steps.
[0046] In step S202, a gradient point set of the image is obtained, and the gradient point set includes a plurality of gradient points representing the grayscale changes of the pixel points in the image. The discrete grayscale value points of the image can be represented by a two-dimensional discrete function, and the gradient point with the largest grayscale change can be obtained by an orthogonal gradient operator, such as the Roberts crossover operator, the Prewiit operator or the Sobel operator; the image gradient point can be obtained by derivation of the two-dimensional discrete function, such as using the Laplace operator, the Marr operator or the Canny operator to calculate the second-order derivative.
[0047] In step S204, the gradient point set is divided into a plurality of gradient point subsets, the plurality of gradient point subsets comprising a first gradient point subset and a second gradient point subset, wherein the gradient values of the gradient points in the first gradient point subset are greater than the gradient values of the gradient points in the second gradient point subset. The stronger the gradient of a point in the gradient point set, the higher the probability that the point is the target boundary. Therefore, the points in the gradient point set are divided into several levels, for example, 10 levels. If the gradient value of the point with the largest gradient value in the gradient point set is 180, and the gradient value of the point with the smallest gradient value is 0, then (180-0) / 10=18 is obtained. Then the gradient points with gradient values in the range of 163 to 180 are divided into the first gradient point subset (where 180-17=163), the gradient points with gradient values in the range of 145 to 162 are divided into the second gradient point subset (where 163-18=145), and the gradient points with gradient values in the range of 127 to 144 are divided into the third gradient point subset (where 145-18=127), and so on, so as to grow and merge the boundaries from high level to low level, so as to ensure that the strong gradient preferentially connects the adjacent points, while the low level lags the adjacent points, and it is easier to grow an edge path that meets the target boundary.
[0048] In step S206, a first edge path is generated according to the first gradient point subset. Starting from the first gradient point subset with the highest level, the first edge path of the highest level subset can be obtained by connecting each gradient point in the gradient point subset in order from large to small gradient values, or fitting each gradient point in the first gradient point subset to obtain a continuously differentiable edge function surface, and then starting from the gradient point with the largest gradient value, searching for the point with the largest function value on the edge function surface with a preset step size as the next initial growth point, and so on, until all the gradient points in the first gradient point subset are connected.
[0049] In some embodiments, if there are points with large gradient value differences in the first gradient point subset, the first edge path may include multiple first edge sub-paths, i.e., paths starting from different gradient points. When two first edge sub-paths grow to intersect, the two sub-paths may be merged, for example, the ends of the two sub-paths with a shorter distance to the intersection are deleted, and the ends with a longer distance to the intersection are retained and merged.
[0050] In some embodiments, due to image noise and other reasons, the two end line segments of the two first edge sub-paths may be close to each other and approximately parallel, that is, close to overlapping. In this case, the two farthest vertices of the approximate parallelogram formed by connecting the two end line segments in sequence can be connected, and the end line segments can be removed to merge the two first edge sub-paths.
[0051] In step S208, a second edge path is generated according to the second gradient point subset and the first edge path. After connecting all the gradient points in the first gradient point subset, one or more first edge paths are generated, and then the two end points of the first edge path are used as starting points, and the above-mentioned method similar to the method of generating the first edge path is used to connect the gradient points in the second gradient point subset to generate one or more second edge sub-paths. Then the above-mentioned method for processing the first edge sub-path is used to generate one or more second edge paths. According to an embodiment of the present application, the gradient point set can be divided into multiple levels of gradient point subsets from high to low according to the gradient value, and each gradient point is connected in sequence from the high level to the low level gradient point subset. Therefore, the second gradient point subset may include multiple levels of gradient point subsets such as the third gradient point subset and the fourth gradient point subset. The growth method of the gradient points in the third gradient point subset, the fourth gradient point subset and other gradient point subsets is similar, and will not be repeated here.
[0052] In step S210, the second edge path is processed to obtain a closed edge to segment the image. After all levels of gradient points are grown into edge paths, a closed edge may be obtained, or multiple unconnected edge paths may be obtained. In this case, the multiple edge paths need to be connected to obtain a closed edge, which is used to segment the image and separate the target from the background of the image.
[0053] In some embodiments, SKU images are usually single-target images, so the image segmentation method for obtaining closed edges disclosed in the present invention is applicable to SKU image segmentation. The image segmentation method disclosed in the present invention can also be used for each target segmentation process in multi-target segmentation, so the images disclosed in the present invention are not limited to SKU images.
[0054] According to the image segmentation method provided by the embodiments of the present disclosure, a gradient point set representing the grayscale change of pixel points of the image is obtained, the gradient point set is divided into multiple gradient point subsets according to the gradient value size, a first edge path is generated according to the first gradient point subset in order from high to low gradient values, and then a second edge path is generated according to the second gradient point subset and the first edge path, and finally the second edge path is processed to obtain a closed edge to segment the image, thereby achieving image segmentation without the need for a training sample set, and ensuring that edge paths are generated preferentially for boundary points with high gradient values.
[0055] Figure 3 FIG. 1 is a flow chart of an image segmentation method according to an exemplary embodiment. Figure 3 The image segmentation method shown can be applied to the server side of the above system, for example, and can also be applied to the terminal device of the above system.
[0056] refer to Figure 3 , the method 30 provided in the embodiment of the present disclosure may include the following steps.
[0057] In step S302, a gradient point set of the image is obtained, where the gradient point set includes a plurality of gradient points representing grayscale changes of pixels in the image.
[0058] In some embodiments, for example, the gradient value of each point in the image is calculated by the Sobel operator to obtain a gradient point set: The calculation method is as follows:
[0059]
[0060]
[0061] In the formula, A is the set of pixel values of the original image, and the coordinates of each gradient point in G correspond to the pixel points in A one-to-one. The two-dimensional coordinate of the i-th pixel in the image, i is a positive integer greater than or equal to 1 and less than or equal to the total number of pixels in the image, That is, the two-dimensional coordinates of each gradient point in the image.
[0062] In step S304, the gradient point set is divided into a plurality of gradient point subsets, the plurality of gradient point subsets including a first gradient point subset and a second gradient point subset, wherein the gradient values of the gradient points in the first gradient point subset are greater than the gradient values of the gradient points in the second gradient point subset. The plurality of gradient point subsets may further include a third gradient point subset, a fourth gradient point subset, and so on, which are graded from large to small according to the gradient values, and grow from a high-grade gradient point subset to a low-grade gradient point subset, and the specific growth method will be described in detail in subsequent steps.
[0063] In step S306, a first initial gradient point and a first growing gradient point in the first gradient point subset are obtained, wherein a distance between the first growing gradient point and the first initial gradient point is not greater than a first preset value.
[0064] When growing from the initial gradient point to find the next growth point, if all gradient points are considered, for example, all gradient points are accumulated when obtaining the edge growth function, it will cause a large amount of calculation. Therefore, in some embodiments, the edge growth function is only generated by accumulating the gradient points within the circle whose radius of the current point is the first preset value R. In order to improve the calculation efficiency of the gradient point traversal within the circle, all gradient points are managed using a grid. It is only necessary to traverse and search for gradient points in the squares above, below, left, right, upper left, upper right, lower right, and lower left of the square where the current point is located, and screen the points with a distance less than R, so as to obtain the first growth gradient point.
[0065] In step S308, a first edge growth function is obtained according to the first initial gradient point and the first growth gradient point, wherein the first edge growth function is an edge growth function with the first initial gradient point as a reference point, and the edge growth function is a continuously differentiable function representing the change of the gradient value with the coordinates of the point on the image, and the coordinates include an angle component and a step size component.
[0066] In some embodiments, a gradient point with the largest gradient value in the first gradient point subset may be selected as the first initial gradient point, and each first growth gradient point is first generated into a continuously differentiable edge function surface f(x, y). For example, a Gaussian kernel function may be used to replace each gradient point:
[0067]
[0068] Where h is the bandwidth of the Gaussian kernel function. The edge function surface can be obtained by multiplying the kernel function of each gradient point with the gradient value and then accumulating them:
[0069]
[0070] Since the accumulation of edge function surfaces is prone to value overflow, the bitangent function can be used to normalize the boundary function to obtain the normalized edge function surface f(x, y), as shown in the following formula:
[0071]
[0072] In step S310, a first growth point is obtained according to the first edge growth function, wherein the first growth point is a point where the function value of the first edge growth function is the largest when the step size component is a second preset value, and the second preset value is smaller than the first preset value.
[0073] In some embodiments, the maximum value of the normalized edge surface function f(x, y) can be found on a circular boundary with a radius of a second preset value r and the first initial gradient point as the center. Since the growth step length r is a constant value, the variable can be converted into a change dθ in the path direction, which is then converted into the maximum value of the normalized edge surface function f(dθ). By:
[0074] θ j =θ j-1 +dθ (6)
[0075] Where j is a positive integer greater than or equal to 1 and less than or equal to the total number of growth points (when j = 1, the point corresponding to (x0, y0) is the initial gradient point), and then let:
[0076] x j =rcos(θ j )+x j-1 =rcos(θ j-1 )cos(dθ)-rsin(θ j-1 )sin(dθ)+x j-1 (7)
[0077] y j =rsin(θ j )+y j-1 =rsin(θ j-1 )cos(dθ)-rcos(θ j-1 )sin(dθ)+y j-1 (8)
[0078] Usually, the gradient ascent iterative method can be used to obtain the dθ corresponding to the maximum value of the edge surface function f(dθ): max1 , to obtain the first growth point. The gradient of f(dθ) can be obtained by the following formula:
[0079]
[0080] The partial derivatives of f(x,y) with respect to x and y can be calculated according to the following formulas:
[0081]
[0082]
[0083] The partial derivatives of x and y with respect to dθ can be obtained from equations (7) and (8):
[0084]
[0085]
[0086] Iterate according to the gradient ascent principle:
[0087]
[0088] Where α is the iteration step size. Until dθ converges, the path direction change dθ1 corresponding to the maximum value of the edge surface function f(dθ) on the circular boundary with a radius of the second preset value r and centered at the first initial gradient point can be obtained, that is, the coordinates (x1, y1) of the point corresponding to the maximum value of the edge surface function f(x, y), that is, the first growth point.
[0089] In step S312, a first edge path is generated according to the first initial gradient point and the first growth point based on the first edge growth function.
[0090] Furthermore, a first directional growth function is obtained according to the first edge growth function and the first growth constraint term, wherein the first growth constraint term is used to constrain the angular growth amount of the second growth point, the first directional growth function is a directional growth function with the first growth point as the reference point and the second preset value as the step growth amount, and the directional growth function represents a function of the gradient value changing with the angular growth amount of the point on the image; according to the first directional growth function, a second growth point is obtained by a gradient ascent iterative algorithm, wherein the second growth point is the point with the largest function value of the first directional growth function; the first initial gradient point, the first growth point and the second growth point are sequentially connected to generate a first edge path.
[0091] In some embodiments, when growing with the first growth point as the initial point, that is, when searching for the second growth point, the same method of searching for the maximum value of the edge surface function on the circular boundary with a radius of r and the initial point as the center can be used. Since in the process of path growth, the probability of the direction of the current path (from the starting point to the end point) continuing the direction of the previous path is the largest, and the probability of the reverse retreat is the smallest, the probability density curve about dθ is bilaterally symmetrical, so the Gaussian function f1(dθ) can be used to constrain the extension direction of the path:
[0092]
[0093] Where σ is the standard deviation of the probability density of dθ. The direction-constrained edge surface function z(dθ) with constraints is:
[0094] z(dθ)=f(dθ)+ωf1(dθ) (16)
[0095] Where ω is the constraint term coefficient. Similarly, the gradient ascent iterative method can be used to obtain the dθ corresponding to the maximum value of the edge surface function z(dθ) of the direction constraint: max2 , to obtain the coordinates of the second growth point. The gradient of z(dθ) can be obtained by the following formula:
[0096]
[0097] Then iterate according to the gradient ascent principle:
[0098]
[0099] Where β is the iteration step size. Until dθ converges, the path direction change dθ2 corresponding to the maximum value of the edge surface function z(dθ) with the first growth point as the center and the direction constraint on the circular boundary with a radius of r can be obtained, that is, the coordinates of the second growth point.
[0100] After obtaining the second growth point, if there are still gradient points remaining in the first gradient point subset, the growth points can be obtained according to the above method of obtaining the second growth point until all the gradient points in the first gradient point subset are connected to form a first edge path. In some embodiments, if there are points with large differences in gradient values in the first gradient point subset, the first edge path may include multiple first edge sub-paths, that is, paths starting from different gradient points. When two first edge sub-paths grow to intersect, the two sub-paths can be merged, for example, the end of the two sub-paths with a shorter distance to the intersection is deleted, and the end with a longer distance to the intersection is retained and merged.
[0101] In some embodiments, due to image noise and other reasons, the two end line segments of the two first edge sub-paths may be close to each other and approximately parallel, that is, close to overlapping. In this case, the two farthest vertices of the approximate parallelogram formed by connecting the two end line segments in sequence can be connected, and the end line segments can be removed to merge the two first edge sub-paths.
[0102] In step S3141, the endpoint of the first edge path is used as the second initial gradient point.
[0103] In step S3142, a second growth gradient point in the second gradient point subset is obtained, wherein a distance between the second growth gradient point and the second initial gradient point is not greater than a third preset value.
[0104] In step S3143, a second edge growth function is obtained according to the second initial gradient point and the second growth gradient point, wherein the second edge growth function is an edge growth function with the second initial gradient point as a reference point.
[0105] In step S3144, a third growth point is obtained according to the second edge growth function, wherein the third growth point is a point where the function value of the second edge growth function is the largest when the step size component is a fourth preset value, and the fourth preset value is less than the third preset value.
[0106] In step S3145, a second directional growth function is obtained according to the second edge growth function and the second growth constraint term, wherein the second growth constraint term is used to constrain the angular growth amount of the fourth growth point, and the second directional growth function is a directional growth function with the third growth point as the reference point and the fourth preset value as the step growth amount.
[0107] In step S3146, a fourth growth point is obtained according to the second directional growth function through a gradient ascent iterative algorithm, wherein the fourth growth point is a point where the function value of the second directional growth function is the largest.
[0108] In step S3147, the second initial gradient point, the third growth point and the fourth growth point are connected in sequence to generate a second edge path.
[0109] In some embodiments, obtaining the second growth gradient point can be similar to the method for obtaining the first growth gradient point in the above embodiments, and the third preset value can be selected R' different from the first preset value according to actual conditions; obtaining the third growth point and the fourth growth point can also be similar to the method for obtaining the first growth point and the second growth point in the above embodiments, and the growth step, i.e., the fourth preset value, can be the same r as the second preset value.
[0110] In step S316, the second edge path is processed to obtain a closed edge to segment the image. The method for processing the edge path can be found in the following embodiment and will not be described in detail here.
[0111] According to the image segmentation method provided by the embodiments of the present disclosure, a continuous edge function surface function is generated according to a gradient point subset, and an edge path is generated in a manner of searching for points corresponding to the maximum values of the surface function in order of gradient values from high to low with a fixed step size, thereby being able to eliminate the influence of image noise to a certain extent, so that the generated edge path is closer to the actual target edge; when growing from a high gradient value to a low gradient value, the growth starts from the two endpoints of the generated edge path, thereby reducing the possibility of the boundary trajectory connection falling into a local minimum solution.
[0112] Figure 4 FIG. 1 is a flow chart of an edge path processing method according to an exemplary embodiment. Figure 4The edge path processing method shown can be applied to the server side of the above system, for example, and can also be applied to the terminal device of the above system.
[0113] According to the above embodiment, when the second edge path is generated from the gradient points of each level from a high level to a low level, since there may be points with large gradient value differences or noise in the gradient point subset, even after the intersecting paths and the approximately overlapping paths are processed, the first edge path or the second edge path may still include multiple sub-paths. At this time, the multiple sub-paths need to be connected to form a closed edge. The method for closing the edge path will be described in detail below.
[0114] refer to Figure 4 , the method 40 provided in the embodiment of the present disclosure may include the following steps.
[0115] In step S401, each of the multiple sub-paths in the second edge path is sorted from most to least according to the number of gradient points included in the sub-path to obtain a sub-path sequence.
[0116] In step S402, the initial total energy of the initial path set is calculated according to the total energy function, wherein the total energy function is used to characterize the segmentation of the path for the image, and the initial path set is an empty set. Further, the total energy function is the sum of the envelope energy function, the length energy function and the connection energy function, wherein:
[0117] The envelope energy function is used to characterize the average distance between the subpath and the boundary of the image;
[0118] The length energy function is used to characterize the number of gradient points on a subpath;
[0119] The connection energy function is used to characterize the degree of curvature after the subpaths are connected to each other.
[0120] In some embodiments, for the segmentation problem of a single target, the envelope energy function indicates that the closer the path is to the outer layer, the more likely it is to be the edge of the target. For example, the shortest vertical distance between the connection point of the edge path and the image boundary can be used as the boundary distance, such as Figure 5 As shown, points A, B, and C are the connection points of the three edge paths, and the shortest vertical distance between points A, B, and C and the image boundary is the length of the thick solid line in the figure. The envelope energy function can be established as shown below:
[0121]
[0122] Where D min It represents the shortest vertical distance between each connection point of the edge path and the boundary, N1 represents the total number of connection points on the edge path, and the average value of all the shortest vertical distances measures the degree to which the edge path is close to the image boundary.
[0123] In some embodiments, in order to maximize the number of total gradient points of the edge path finally selected, a path length energy function is established, for example:
[0124]
[0125] In some embodiments, when connecting multiple sub-paths to form a closed edge, there may be multiple ways of connecting two sub-paths. One possible way of connecting two sub-paths is as follows: Figure 6 As shown, the dotted line For the connecting line, and Reason To select a connection method where the connection line is closer to a straight line, the connection condition of the connection line can be measured by vector operation, and the energy of the connection line is defined as:
[0126]
[0127] Then establish the connection energy function:
[0128]
[0129] Where N b is the total number of links that connect multiple subpaths.
[0130] In some embodiments, the total energy function may be established as follows:
[0131] S=γ·S1+δ·S2+λ·S3 (23)
[0132] In the formula, γ is the envelope energy coefficient, δ is the length energy coefficient, λ is the connection energy coefficient, and γ+δ+λ=1. Based on this, the initial total energy can be calculated to be 1.
[0133] In step S403, the first sub-path ranked first is selected from the sub-path sequence and put into the initial path set to obtain the current path set.
[0134] In step S404, the first subpath is excluded from the subpath sequence to obtain a current subpath sequence.
[0135] In step S405, the first total energy of the current edge path is calculated according to the total energy function, and the current edge path is obtained by closing the first subpath in the current path set, and the current total energy is obtained as the first total energy. In some embodiments, if the first total energy is calculated according to the above energy function, it is less than the initial total energy 1.
[0136] In step S406, the second sub-path ranked first is selected from the current sub-path sequence and put into the current path set, the current path set is updated, and the currently selected sub-path is obtained as the second sub-path.
[0137] In step S407, the second total energy of the current edge path is calculated according to the total energy function, and the current edge path is obtained by connecting each sub-path in the current path set.
[0138] In step S408, it is determined whether the second total energy is less than the current total energy.
[0139] In step S4091, if the second total energy is not less than the current total energy, the currently selected subpath is excluded from the current path set, the current path set is updated, and it is determined whether there is a subpath in the current subpath sequence that is next to the currently selected subpath.
[0140] In step S4092, if there is no sub-path in the current sub-path sequence that is next to the currently selected sub-path, a closed edge for segmenting the image is obtained according to the current edge path.
[0141] In step S4093, if there is a subpath in the current subpath sequence that ranks next to the currently selected subpath, select the third subpath that ranks next to the currently selected subpath and put it into the current path set, update the current path set, and obtain the currently selected subpath as the third subpath, and return to step S407.
[0142] In step S410, if the second total energy is less than the current total energy, disconnect each subpath on the current edge path, exclude each subpath in turn, and calculate the third total energy of the edge path obtained by connecting the remaining subpaths according to the total energy function.
[0143] In step S411, it is determined whether the third total energy is less than the second total energy.
[0144] In step S4121, if the third total energy is less than the second total energy, the excluded subpath corresponding to the third total energy is removed from the current path set, the current path set is updated, the current total energy is updated to the second total energy, and the process returns to step S406.
[0145] In step S4122, if the third total energy is not less than the second total energy, the currently selected subpath is excluded from the current subpath sequence, the current subpath sequence is updated, and the process returns to step S406.
[0146] According to the edge path processing method provided by the embodiment of the present disclosure, multiple sub-paths in the second edge path are measured by an energy function, and an iterative method is used to screen the sub-paths and select the connection method, so as to generate a closed edge path that is closer to the actual target edge.
[0147] Figure 7 FIG. 1 is a flow chart of an edge path processing method according to an exemplary embodiment. Figure 7 The edge path processing method shown can be applied to the server side of the above system, for example, and can also be applied to the terminal device of the above system.
[0148] After generating a closed edge for segmenting the target from the image, the closed edge curve can be adjusted in position, that is, each connection point on the closed edge can be adjusted to maximize the total value of the edge surface function of the connection points while maximizing the continuity between the connection points.
[0149] refer to Figure 7 , the method 70 provided in the embodiment of the present disclosure may include the following steps.
[0150] In step S701, the current coordinates of each connection point on the second edge path on the image are obtained. In some embodiments, for example, the coordinates (x k ,y k ) is represented by X k , k is a positive integer greater than or equal to 1 and less than or equal to the total number N2 of connection points on the second edge path.
[0151] In step S702, the current total adjustment energy function value is calculated according to the current coordinates of each connection point. The total adjustment energy function is obtained by adding the edge growth function and the connection constraint term. The edge growth function is a continuous differentiable function that represents the change of the gradient value with the coordinates of the points on the image. The connection constraint term is obtained according to the current coordinates of each connection point.
[0152] In some embodiments, for example, the edge growth function is represented by f(X k )=f(x k ,y k ), the function value can be calculated according to equations (1) to (5). The connection constraint term can be expressed as follows:
[0153]
[0154] Where X represents (x, y). Since the second edge path here is a closed edge, X0 represents the coordinates of the point connected to the first connection point X1 to obtain a closed edge, that is, and Represents the last connection point Connect to obtain the coordinates of the closed edge point, that is, X1. In order to keep the monotonicity of the connection constraint consistent with the edge growth function, the activation function is used to reverse it:
[0155]
[0156] The total adjustment energy function can be expressed as:
[0157]
[0158] Where ε represents the connection constraint coefficient.
[0159] In some embodiments, for example, to obtain the coordinates of each connection point that maximizes the total adjustment energy function value, the gradient ascent iterative method can also be used to update the coordinates of each connection point. From formula (26), it can be obtained that for the kth connection point X k , the gradient of the total adjusted energy function is:
[0160]
[0161] in, It can be calculated according to formula (10) and formula (11), and formula (24) can be obtained:
[0162]
[0163] again:
[0164]
[0165] Therefore, from equations (25), (28) and (29), we can calculate According to the gradient ascent principle, the position of each connection point is iteratively updated. For example, the kth connection point X k As shown below:
[0166]
[0167] Where θ is the iteration step size.
[0168] In step S704, it is determined whether the increase value of the total adjustment energy function value is less than a fifth preset value.
[0169] In step S705, if the increase in the total adjusted energy function value is not less than the fifth preset value, the current coordinates of each connection point are obtained as the updated coordinates, and the process returns to step S701. Before returning to step S701 and iterating again, if a path segment is too long, for example, the distance between two adjacent connection points updated is greater than 2r, the path between the two connection points needs to be split into two paths, that is, the midpoint of the path is added as a new connection point; if a path segment is too short, for example, the distance between two adjacent connection points updated is less than 1 / 2r, the path needs to be merged with an adjacent path into one path segment.
[0170] In step S706, if the increase value of the total adjustment energy function value is less than the fifth preset value, an edge path obtained by connecting the updated connection points is obtained.
[0171] According to the edge path processing method provided by the embodiment of the present disclosure, the coordinates of each connection point on the closed edge are adjusted by adopting an iterative method, and the coordinate adjustment of the connection point is constrained by using the adjustment energy, so as to achieve the goal of maximizing the total value of the edge surface function of the connection point while maximizing the coherence between the connection points.
[0172] Figure 8 FIG. 1 is a block diagram of an image segmentation device according to an exemplary embodiment. Figure 8 The image segmentation device shown can be applied to the server side of the above system, for example, and can also be applied to the terminal device of the above system.
[0173] refer to Figure 8 The device 80 provided in the embodiment of the present disclosure may include a gradient point acquisition module 802 , a gradient point classification module 804 , an edge growth module 806 and a path processing module 808 .
[0174] The gradient point acquisition module 802 may be used to obtain a gradient point set of an image, where the gradient point set includes a plurality of gradient points representing grayscale changes of pixels in the image.
[0175] The gradient point classification module 804 may be used to divide the gradient point set into a plurality of gradient point subsets, the plurality of gradient point subsets comprising a first gradient point subset and a second gradient point subset, wherein the gradient values of the gradient points in the first gradient point subset are greater than the gradient values of the gradient points in the second gradient point subset.
[0176] The edge growing module 806 may be configured to generate a first edge path based on the first subset of gradient points.
[0177] The edge growing module 806 may also be configured to generate a second edge path according to the second gradient point subset and the first edge path.
[0178] The path processing module 808 may be used to process the second edge path to obtain a closed edge to segment the image.
[0179] Fig. 9 FIG. 1 is a block diagram of an image segmentation device according to an exemplary embodiment. Fig. 9 The image segmentation device shown can be applied to the server side of the above system, for example, and can also be applied to the terminal device of the above system.
[0180] refer to Fig. 9 The device 90 provided in the embodiment of the present disclosure may include a gradient point acquisition module 902, a gradient point classification module 904, an edge growth module 906 and a path processing module 908, wherein the path processing module 908 includes a path closing module 9081 and a path adjustment module 9082.
[0181] The gradient point acquisition module 902 may be used to obtain a gradient point set of an image, where the gradient point set includes a plurality of gradient points representing grayscale changes of pixels in the image.
[0182] The gradient point classification module 904 may be used to divide the gradient point set into a plurality of gradient point subsets, the plurality of gradient point subsets comprising a first gradient point subset and a second gradient point subset, wherein the gradient values of the gradient points in the first gradient point subset are greater than the gradient values of the gradient points in the second gradient point subset.
[0183] The edge growing module 906 may be configured to generate a first edge path based on the first subset of gradient points.
[0184] The edge growth module 906 can also be used to obtain a first initial gradient point and a first growth gradient point in the first gradient point subset, wherein the distance between the first growth gradient point and the first initial gradient point is not greater than a first preset value; obtain a first edge growth function based on the first initial gradient point and the first growth gradient point, wherein the first edge growth function is an edge growth function with the first initial gradient point as a reference point, and the edge growth function is a continuously differentiable function representing the change of the gradient value with the coordinates of the point on the image, and the coordinates include an angle component and a step length component; obtain a first growth point based on the first edge growth function, wherein the first growth point is the point where the function value of the first edge growth function is the largest when the step length component is a second preset value, and the second preset value is less than the first preset value; generate a first edge path based on the first edge growth function according to the first initial gradient point and the first growth point.
[0185] The edge growth module 906 can also be used to obtain a first directional growth function based on the first edge growth function and the first growth constraint term, wherein the first growth constraint term is used to constrain the angular growth amount of the second growth point, the first directional growth function is a directional growth function with the first growth point as the reference point and the second preset value as the step growth amount, and the directional growth function represents a function of the gradient value changing with the angular growth amount of the point on the image; according to the first directional growth function, the second growth point is obtained by a gradient ascent iterative algorithm, wherein the second growth point is the point with the largest function value of the first directional growth function; the first initial gradient point, the first growth point and the second growth point are connected in sequence to generate a first edge path.
[0186] The edge growing module 906 may also be configured to generate a second edge path according to the second gradient point subset and the first edge path.
[0187] The edge growth module 906 can also be used to use the endpoint of the first edge path as a second initial gradient point; obtain a second growth gradient point in the second gradient point subset, wherein the distance between the second growth gradient point and the second initial gradient point is not greater than a third preset value; obtain a second edge growth function based on the second initial gradient point and the second growth gradient point, wherein the second edge growth function is an edge growth function with the second initial gradient point as a reference point; obtain a third growth point based on the second edge growth function, wherein the third growth point is a point where the function value of the second edge growth function is the largest when the step length component is a fourth preset value, and the fourth preset value is less than the third preset value; obtain a second directional growth function based on the second edge growth function and the second growth constraint term, wherein the second growth constraint term is used to constrain the angular growth amount of the fourth growth point, and the second directional growth function is a directional growth function with the third growth point as a reference point and the fourth preset value as the step length growth amount; obtain a fourth growth point based on the second directional growth function through a gradient ascent iterative algorithm, wherein the fourth growth point is a point where the function value of the second directional growth function is the largest; and connect the second initial gradient point, the third growth point and the fourth growth point in sequence to generate a second edge path.
[0188] The path processing module 908 may be used to process the second edge path to obtain a closed edge to segment the image.
[0189] The path closing module 9081 can be used to sort each subpath in the multiple subpaths from most to least according to the number of gradient points contained in the subpath, so as to obtain a subpath sequence; calculate the initial total energy of the initial path set according to the total energy function, and the total energy function is the sum of the envelope energy function, the length energy function and the connection energy function, wherein: the envelope energy function is used to characterize the average distance between the subpath and the boundary of the image; the length energy function is used to characterize the number of gradient points on the subpath; the connection energy function is used to characterize the degree of curvature after the subpaths are connected to each other; select the first subpath ranked first from the subpath sequence and put it into the initial path set to obtain the current path set, The initial path set is an empty set; the first subpath is excluded from the subpath sequence to obtain the current subpath sequence; the first total energy of the first subpath in the current path set is calculated according to the total energy function, and the current total energy is obtained as the first total energy, wherein the total energy function is used to characterize the segmentation of the path for the image; the traversal step: the second subpath ranked first in the current subpath sequence is selected and put into the current path set, the current path set is updated, and the currently selected subpath is obtained as the second subpath; the energy calculation step: the second total energy of the current edge path is calculated according to the total energy function, and the current edge path is obtained by connecting the subpaths in the current path set; the judgment step Determine whether the second total energy is less than the current total energy; if the second total energy is not less than the current total energy, exclude the currently selected subpath from the current path set, update the current path set, and determine whether there is a subpath in the current subpath sequence that is next to the currently selected subpath; if there is no subpath in the current subpath sequence that is next to the currently selected subpath, obtain the closed edge for segmenting the image according to the current edge path; if there is a subpath in the current subpath sequence that is next to the currently selected subpath, select the third subpath that is next to the currently selected subpath and put it into the current path set, update the current path set, and obtain the currently selected subpath as the third subpath, Return to the energy calculation step; if the second total energy is less than the current total energy, disconnect the sub-paths on the current edge path, exclude each sub-path in turn, and calculate the third total energy of the edge path obtained by connecting the remaining sub-paths according to the total energy function; determine whether the third total energy is less than the second total energy; if the third total energy is less than the second total energy, remove the excluded sub-path corresponding to the third total energy from the current path set, update the current path set, update the current total energy to the second total energy, and return to the traversal step; if the third total energy is not less than the second total energy, exclude the currently selected sub-path from the current sub-path sequence, update the current sub-path sequence, and return to the traversal step.
[0190] The path adjustment module 9082 can be used to update the coordinates of each connection point on the second edge path on the image based on the total adjustment energy function until the increase in the total adjustment energy function value is less than the fifth preset value, wherein the total adjustment energy function is obtained by adding the edge growth function and the connection constraint term, the edge growth function is a continuous differentiable function representing the change of the gradient value with the coordinates of the point on the image, the connection constraint term is obtained according to the coordinates of each connection point, and the total adjustment energy function value is obtained by substituting the coordinates of each connection point into the total adjustment energy function.
[0191] It should be noted that Fig.10 The device shown is only an example of a computer system, which should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0192] like Fig.10 As shown, the device 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the device 1000 are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0193] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.
[0194] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part 1009, and / or installed from a removable medium 1011. When the computer program is executed by a central processing unit (CPU) 1001, the above-mentioned functions defined in the system of the present disclosure are executed.
[0195] It should be noted that the computer-readable medium shown in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0196] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0197] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes an acquisition module and a processing module. The names of these modules do not constitute a limitation on the modules themselves in some cases, for example, the acquisition module may also be described as a "module for acquiring gradient point data from a connected terminal".
[0198] As another aspect, the present disclosure also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: obtaining a gradient point set of an image, the gradient point set includes multiple gradient points representing grayscale changes of pixel points in the image; dividing the gradient point set into multiple gradient point subsets, the multiple gradient point subsets include a first gradient point subset and a second gradient point subset, wherein the gradient value of the gradient point in the first gradient point subset is greater than the gradient value of the gradient point in the second gradient point subset; generating a first edge path according to the first gradient point subset; generating a second edge path according to the second gradient point subset and the first edge path; processing the second edge path to obtain a closed edge to segment the image.
[0199] The exemplary embodiments of the present disclosure are specifically shown and described above. It should be understood that the present disclosure is not limited to the detailed structures, configurations or implementations described herein; on the contrary, the present disclosure is intended to cover various modifications and equivalent configurations included in the spirit and scope of the appended claims.
Claims
1. An image segmentation method, characterized in that: include: Obtaining a gradient point set of an image, the gradient point set comprising a plurality of gradient points representing grayscale changes of pixel points in the image; Dividing the gradient point set into a plurality of gradient point subsets, the plurality of gradient point subsets comprising a first gradient point subset and a second gradient point subset, wherein the gradient values of the gradient points in the first gradient point subset are greater than the gradient values of the gradient points in the second gradient point subset; generating a first edge path according to the first gradient point subset, wherein the first edge path is formed by connecting at least the gradient points in the first gradient point subset in descending order of gradient values; generating a second edge path according to the second gradient point subset and the first edge path; Processing the second edge path to obtain closed edges to segment the image; Generating a second edge path according to the second gradient point subset and the first edge path comprises: The endpoint of the first edge path is used as a starting point, and at least each gradient point in the second gradient point subset is connected in order of gradient value from large to small to generate one or more second edge paths.
2. The method according to claim 1, characterized in that Generating a first edge path according to the first gradient point subset comprises: Acquire the gradient points in the first gradient point subset in order from large to small gradient values as first initial gradient points; Obtaining the first initial gradient point and a corresponding first growth gradient point, wherein a distance between the first growth gradient point and the first initial gradient point is not greater than a first preset value; Obtaining a first edge growth function according to the first initial gradient point and the first growth gradient point, wherein the first edge growth function is an edge growth function with the first initial gradient point as a reference point, and the edge growth function is a continuous differentiable function representing a gradient value changing with coordinates of a point on the image, wherein the coordinates include an angle component and a step length component; Obtaining a first growth point according to the first edge growth function, wherein the first growth point is a point at which the function value of the first edge growth function is the largest when the step length component is a second preset value, and the second preset value is less than the first preset value; The first edge path is generated according to the first initial gradient point and the first growth point based on the first edge growth function.
3. The method according to claim 2, characterized in that Generating the first edge path according to the first initial gradient point and the first growth point based on the first edge growth function comprises: Obtaining a first directional growth function according to the first edge growth function and the first growth constraint term, wherein the first growth constraint term is used to constrain the angular growth amount of the second growth point, the first directional growth function is a directional growth function with the first growth point as a reference point and the second preset value as a step growth amount, and the directional growth function represents a function of a gradient value changing with the angular growth amount of a point on the image; Obtaining the second growth point by using a gradient ascent iterative algorithm according to the first directional growth function, wherein the second growth point is a point where the function value of the first directional growth function is the largest; The first initial gradient point, the first growth point, and the second growth point are sequentially connected to generate the first edge path.
4. The method according to claim 3, characterized in that The step of taking the endpoint of the first edge path as a starting point and connecting at least the gradient points in the second gradient point subset in order of gradient values from large to small to generate one or more second edge paths comprises: Taking the endpoint of the first edge path as the starting second initial gradient point, and then sequentially acquiring the gradient points in the second gradient point subset in descending order of gradient values as the second initial gradient points; Obtain a second growth gradient point in the second gradient point subset, wherein the distance between the second growth gradient point and the second initial gradient point is not greater than a third preset value; Obtaining a second edge growth function according to the second initial gradient point and the second growth gradient point, wherein the second edge growth function is an edge growth function with the second initial gradient point as a reference point; Obtaining a third growth point according to the second edge growth function, wherein the third growth point is a point where the function value of the second edge growth function is the largest when the step size component is a fourth preset value, and the fourth preset value is less than the third preset value; Obtaining a second directional growth function according to the second edge growth function and the second growth constraint term, wherein the second growth constraint term is used to constrain the angular growth amount of the fourth growth point, and the second directional growth function is a directional growth function with the third growth point as a reference point and the fourth preset value as a step growth amount; Obtaining the fourth growth point by using a gradient ascent iterative algorithm according to the second directional growth function, wherein the fourth growth point is a point where the function value of the second directional growth function is the largest; The second initial gradient point, the third growth point and the fourth growth point are sequentially connected to generate the second edge path.
5. The method according to claim 1, characterized in that The second edge path includes a plurality of sub-paths; The processing of the second edge path comprises: Sort each subpath in the plurality of subpaths from most to least according to the number of the gradient points included in the subpath to obtain a subpath sequence; Calculating the initial total energy of the initial path set according to the total energy function, wherein the total energy function is used to characterize the segmentation of the path for the image; Selecting the first subpath ranked first from the subpath sequence and putting it into the initial path set to obtain the current path set, wherein the initial path set is an empty set; Excluding the first subpath from the subpath sequence to obtain a current subpath sequence; Calculate the first total energy of the first subpath in the current path set according to the total energy function, and obtain the current total energy as the first total energy; Traversal step: select the second subpath ranked first from the current subpath sequence and put it into the current path set, update the current path set, and obtain the currently selected subpath as the second subpath; Energy calculation step: calculating a second total energy of a current edge path according to the total energy function, wherein the current edge path is obtained by connecting each subpath in the current path set; Determining whether the second total energy is less than the current total energy; If the second total energy is not less than the current total energy, the currently selected subpath is excluded from the current path set, the current path set is updated, and it is determined whether there is a subpath in the current subpath sequence that is next to the currently selected subpath; If there is no subpath in the current subpath sequence that is next to the currently selected subpath, obtaining a closed edge for segmenting the image according to the current edge path; If there is a subpath in the current subpath sequence that ranks next to the currently selected subpath, select the third subpath that ranks next to the currently selected subpath and put it into the current path set, update the current path set, obtain the currently selected subpath as the third subpath, and return to the energy calculation step; If the second total energy is less than the current total energy, disconnect the sub-paths on the current edge path, exclude the sub-paths in turn, and calculate the third total energy of the edge path obtained by connecting the remaining sub-paths according to the total energy function; Determining whether the third total energy is less than the second total energy; If the third total energy is less than the second total energy, remove the excluded subpath corresponding to the third total energy from the current path set, update the current path set, update the current total energy to the second total energy, and return to the traversal step; If the third total energy is not less than the second total energy, the currently selected subpath is excluded from the current subpath sequence, the current subpath sequence is updated, and the traversal step is returned.
6. The method according to claim 5, characterized in that The total energy function is the sum of the envelope energy function, the length energy function and the connection energy function, where: The envelope energy function is used to characterize the average distance between the subpath and the boundary of the image; The length energy function is used to characterize the number of the gradient points on the subpath; The connection energy function is used to characterize the degree of curvature after the sub-paths are connected to each other.
7. The method according to claim 1, characterized in that The processing of the second edge path includes: Based on the total adjustment energy function, the coordinates of each connection point on the second edge path on the image are updated until the increase in the total adjustment energy function value is less than a fifth preset value, wherein the total adjustment energy function is obtained by adding an edge growth function and a connection constraint term, the edge growth function is a continuously differentiable function representing a gradient value that changes with the coordinates of the points on the image, and the total adjustment energy function value is obtained by substituting the coordinates of each connection point into the total adjustment energy function.
8. An image segmentation device, characterized in that: include: A gradient point acquisition module, used to obtain a gradient point set of an image, wherein the gradient point set includes a plurality of gradient points representing grayscale changes of pixel points in the image; a gradient point classification module, configured to divide the gradient point set into a plurality of gradient point subsets, the plurality of gradient point subsets comprising a first gradient point subset and a second gradient point subset, wherein the gradient values of the gradient points in the first gradient point subset are greater than the gradient values of the gradient points in the second gradient point subset; an edge growth module, configured to generate a first edge path according to the first gradient point subset, wherein the first edge path is formed by connecting at least the gradient points in the first gradient point subset in descending order of gradient values; an edge growing module, further configured to generate a second edge path according to the second gradient point subset and the first edge path; The edge growth module is further configured to use the endpoint of the first edge path as a starting point, and at least connect the gradient points in the second gradient point subset in descending order of gradient value to generate one or more second edge paths; A path processing module is used to process the second edge path to obtain a closed edge to segment the image.
9. A device comprising: A memory, a processor, and executable instructions stored in the memory and executable in the processor, wherein the processor implements the method according to any one of claims 1 to 7 when executing the executable instructions.
10. A computer-readable storage medium having computer-executable instructions stored thereon, characterized in that: When the executable instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.
