CN113129307A - Image segmentation method and image segmentation device - Google Patents

Image segmentation method and image segmentation device Download PDF

Info

Publication number
CN113129307A
CN113129307A CN201911411574.7A CN201911411574A CN113129307A CN 113129307 A CN113129307 A CN 113129307A CN 201911411574 A CN201911411574 A CN 201911411574A CN 113129307 A CN113129307 A CN 113129307A
Authority
CN
China
Prior art keywords
image
anchor point
point
line
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201911411574.7A
Other languages
Chinese (zh)
Inventor
赵光耀
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201911411574.7A priority Critical patent/CN113129307A/en
Priority to PCT/CN2020/140570 priority patent/WO2021136224A1/en
Publication of CN113129307A publication Critical patent/CN113129307A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/194Segmentation; Edge detection involving foreground-background segmentation

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • General Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Biomedical Technology (AREA)
  • Molecular Biology (AREA)
  • Biophysics (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Image Analysis (AREA)

Abstract

The application provides an image segmentation method and an image segmentation device, wherein the image segmentation method is applied to terminal equipment with a display screen and comprises the following steps: detecting a first operation of manually marking anchor points in a first image by a user, wherein the anchor points comprise a starting anchor point and a target anchor point; detecting a second operation of automatically segmenting the first image indicated by the user; and displaying a second image on the display screen in response to the second operation, wherein the second image is obtained after the second operation is performed on the first image, the second image comprises a division line between the starting anchor point and the target anchor point, and the division line is obtained by moving a dividing point in the first image by taking the starting anchor point as a starting position and taking the target anchor point as a target position. According to the technical scheme, the segmentation result matched with the natural boundary of the image can be obtained under the condition of saving manpower, so that the accuracy of the image segmentation result is improved.

Description

Image segmentation method and image segmentation device
Technical Field
The present application relates to the field of artificial intelligence, and more particularly, to an image segmentation method and an image segmentation apparatus in the field of computer vision.
Background
Computer vision is an integral part of various intelligent/autonomous systems in various application fields, such as manufacturing, inspection, document analysis, medical diagnosis, military and the like, and is a study on how to use cameras/video cameras and computers to acquire data and information of a photographed object which are required by us. In a descriptive sense, a computer is provided with eyes (camera/camcorder) and a brain (algorithm) to recognize, track, measure, etc. a target instead of human eyes, thereby enabling the computer to perceive the environment. The task of accurate segmentation has wide application in the field of computer vision. For example, background blurring of an image, background replacement, commercial production and live broadcasting of an e-commerce, movie (animation) production, etc., wherein the precise segmentation may refer to a segmentation line between a target object on an acquired image or video and a background.
At present, a polygon method or a curve fitting method is generally adopted to accurately segment an image; the difference between the image segmentation line obtained by the polygon method and the actual segmentation line of the image is large, and the accuracy is low; the need to manually select multiple cut points by the curve fitting method results in a large amount of manpower.
Therefore, under the condition of saving manpower, how to improve the accuracy of the accurate segmentation result of the image becomes a problem which needs to be solved urgently.
Disclosure of Invention
The present application provides an image segmentation method and an image segmentation apparatus, which can obtain a segmentation result matching with a natural boundary of an image under the condition of saving manpower, thereby improving the accuracy of the image segmentation result.
In a first aspect, an image segmentation method applied to a terminal device having a display screen includes: detecting a first operation of manually marking anchor points in a first image by a user, wherein the anchor points comprise a starting anchor point and a target anchor point; detecting a second operation of automatically segmenting the first image indicated by the user; and displaying a second image on the display screen in response to the second operation, wherein the second image is obtained after the second operation is performed on the first image, the second image comprises a dividing line between the starting anchor point and the target anchor point, and the dividing line is obtained by moving a dividing point in the first image by taking the starting anchor point as a starting position and taking the target anchor point as a target position.
The dividing line can be obtained by automatically moving a dividing point in the first image by taking the starting anchor point as a starting position and taking the target anchor point as a target position; the automatic movement may mean that the user only needs to manually mark the initial anchor point and the target anchor point in the first image, or manually marks a small number of mark points including the initial anchor point and the target anchor point, and the dividing line between the initial anchor point and the target anchor point in the first image can be automatically obtained.
The boundary point may refer to a point on a boundary between a target region and a background region in the image, wherein the target region may refer to a region including a target object.
The first image may refer to an image having an image segmentation requirement; the second image may be an image obtained by performing automatic segmentation processing on the first image.
It should be understood that the start anchor point and the target anchor point may be positions in the image to be processed, where the positions of the start anchor point and the target anchor point do not change, and a division line of the first image between the start anchor point and the target anchor point may be obtained by moving a division point from the start anchor point to the target anchor point, where the division line coincides with a natural boundary of a different object in the first image.
In the embodiment of the application, a small number of anchor points including the initial anchor point and the target anchor point are manually marked on the first image, and the division line of the first image is obtained by automatically moving the boundary point in the pixel gradient map of the first image by taking the initial anchor point as the initial position and taking the target anchor point as the target position, so that the division result inosculated with the natural boundary of the image can be obtained under the condition of saving manpower, and the accuracy of the image division result is improved.
In a possible implementation manner, the second operation of the user for indicating automatic segmentation may include that the user clicks a button of an image to be automatically segmented in the image processing tool, and may also include a behavior that the user indicates automatic segmentation through voice, or may also include another behavior that the user indicates automatic segmentation.
With reference to the first aspect, in certain implementations of the first aspect, the segmentation line coincides with a segmentation line in a ridge direction in a pixel gradient map of the first image.
It should be noted that the ridge direction in the pixel gradient map of the first image may refer to a curve formed by local maxima of gradient in the pixel gradient map.
In the embodiment of the present application, the obtained dividing line of the first image may coincide with the dividing line in the ridge direction in the pixel gradient map of the first image, that is, the dividing line of the first image may be obtained according to the pixel gradient map of the first image, thereby avoiding the problem of manpower consumption caused by manually marking a large number of anchor points in the first image; by manually marking a small number of anchor points, the accuracy of the image segmentation result can be improved under the condition of saving manpower.
With reference to the first aspect, in certain implementations of the first aspect, the displaying the second image on the display screen in response to the second operation includes: searching a mask image and a secant image corresponding to the first image according to the first image, wherein the mask image is used for representing different objects in the first image, and the secant image is used for representing the boundaries of the different objects in the first image; and displaying the first image, the mask image and the superposed image of the secant image on the display screen.
In a possible implementation manner, a mask image and/or a secant image corresponding to the first image may be searched for under a preset file path according to the first image.
Illustratively, each image file may be saved as a bitmap file (BMP), a lossless compressed bitmap graphics format (PNG), or other image file format; the correspondence between the image file, the mask file, and the cut line file may be described by an icon or a file name naming rule, or may be represented by packing three images in one file or one folder.
With reference to the first aspect, in certain implementations of the first aspect, the method further includes: detecting a third operation of the user indicating to process the second image through the mask image or the secant image.
In a possible implementation manner, the second image may refer to a superimposed image of the first image, the mask image and the secant image displayed on the display screen, and the third operation may be used to instruct automatic segmentation processing on the superimposed image through the mask image or the secant image.
In the embodiment of the present application, the user may select to perform the automatic segmentation process on the first image according to the mask image or the secant image, for example, the user may manually adjust the position of the anchor point according to the mask image or the secant image.
With reference to the first aspect, in certain implementations of the first aspect, the second image is obtained from a pixel gradient map of the first image and an anchor point tracting model, where the anchor point tracting model is used to indicate a moving direction of the demarcation point.
In an embodiment of the application, the second image may be obtained according to the pixel gradient map of the first image and an anchor point traction model, and the anchor point traction model may indicate a moving direction of each step when the demarcation point automatically moves from the start anchor point to the target anchor point, so as to reduce the artificial participation degree.
With reference to the first aspect, in some implementations of the first aspect, when the dividing point is currently located in a region without ridge in the pixel gradient map, a moving direction of the dividing point is determined according to an included angle between a first line and a second line, where the first line is a straight line in which each of the eight orientations is located, and the second line is a line between the current location of the dividing point and the target anchor point; or
When the demarcation point is located in a region with ridge and bifurcation in the pixel gradient map, the moving direction of the demarcation point is determined according to an included angle between a first connecting line and a second connecting line and a distance parameter, wherein the first straight line refers to a straight line in which each azimuth in eight azimuths is located, the second straight line refers to a connecting line between the current position of the demarcation point and the target anchor point, and the distance parameter refers to a distance between the current position of the demarcation point and the target anchor point; or
When the boundary point is currently located in a region having ridge and no bifurcation in the pixel gradient map, the moving direction of the boundary point is determined according to the ridge direction of the pixel gradient map.
With reference to the first aspect, in certain implementations of the first aspect, in a case that a moving direction of the demarcation point at a previous time is the same as the moving direction of the demarcation point at a current time, the moving direction of the demarcation point is determined according to absolute values of gradients of different azimuths.
In the embodiment of the present application, in the case that the moving direction of the boundary point at the previous time is the same as the moving direction of the current time, the boundary point may be moved to the preset direction, that is, the moving direction of the boundary point may be determined according to the absolute values of the gradients of different moving orientations, so that the error of the boundary point when moving along the ridge direction of the gradient map can be compensated.
With reference to the first aspect, in certain implementations of the first aspect, the anchor point is obtained by optimizing an initial anchor point, wherein the initial anchor point is an anchor point manually marked in the first image by a user.
In the embodiment of the application, since the anchor point in the image to be processed is marked in the image to be processed manually by the user, the position of the anchor point may have a certain deviation; in order to make the position of the anchor point more accurate and improve the accuracy of the segmentation line of the image to be processed, the anchor point marked manually by the user can be optimized in position.
In a second aspect, an image segmentation method is provided, including: acquiring a first image and position information of an anchor point in the first image, wherein the anchor point comprises an initial anchor point and a target anchor point; and obtaining a second image according to the first image and the anchor point, wherein the second image is obtained after the first image is subjected to image segmentation processing, the second image comprises a division line between the starting anchor point and the target anchor point, and the division line is obtained by moving a boundary point in a pixel gradient map of the first image by taking the starting anchor point as a starting position and taking the target anchor point as a target position.
The boundary point may refer to a point on a boundary between a target region and a background region in the image, wherein the target region may refer to a region including a target object.
In one possible implementation, a first image, a pixel gradient map of the first image, and location information of anchor points in the first image may be obtained, and the anchor points may include a start anchor point and a target anchor point.
The dividing line can be obtained by automatically moving a dividing point in the first image by taking the starting anchor point as a starting position and taking the target anchor point as a target position; the automatic movement may be to acquire the start anchor point and the target anchor point in the first image, or to automatically obtain a dividing line between the start anchor point and the target anchor point in the first image by including a small number of mark points of the start anchor point and the target anchor point.
The first image may refer to an image having an image segmentation requirement; the second image may be an image obtained by performing automatic segmentation processing on the first image.
It should be understood that the start anchor point and the target anchor point may be positions in the image to be processed, where the positions of the start anchor point and the target anchor point do not change, and a division line of the first image between the start anchor point and the target anchor point may be obtained by moving a division point from the start anchor point to the target anchor point, where the division line coincides with a natural boundary of a different object in the first image.
In the embodiment of the application, a small number of anchor points including the initial anchor point and the target anchor point are manually marked on the first image, and the division line of the first image is obtained by automatically moving the boundary point in the pixel gradient map of the first image by taking the initial anchor point as the initial position and taking the target anchor point as the target position, so that the division result inosculated with the natural boundary of the image can be obtained under the condition of saving manpower, and the accuracy of the image division result is improved.
With reference to the second aspect, in certain implementations of the second aspect, the segmentation line coincides with a segmentation line in a ridge direction in the pixel gradient map.
It should be noted that the ridge direction in the pixel gradient map may refer to a curve formed by local maxima of gradient in the pixel gradient map.
In the embodiment of the present application, the obtained dividing line of the first image may coincide with the dividing line in the ridge direction in the pixel gradient map of the first image, that is, the dividing line of the first image may be obtained according to the pixel gradient map of the first image, thereby avoiding the problem of manpower consumption caused by manually marking a large number of anchor points in the first image; by manually marking a small number of anchor points, the accuracy of the image segmentation result can be improved under the condition of saving manpower.
With reference to the second aspect, in some implementations of the second aspect, the obtaining a second image according to the first image and the anchor point includes: and obtaining the second image according to the pixel gradient map, the anchor point and an anchor point traction model, wherein the anchor point traction model is used for indicating the moving direction of the demarcation point.
In an embodiment of the application, the secant image may be obtained according to a pixel gradient map of the first image and an anchor point traction model, and the anchor point traction model may indicate a moving direction of each step when the demarcation point automatically moves from the start anchor point to the target anchor point, thereby reducing the artificial participation degree.
With reference to the second aspect, in some implementations of the second aspect, if the dividing point is currently located in a region without ridge in the pixel gradient map, the moving direction of the dividing point is determined according to an included angle between a first line and a second line, where the first line is a straight line in which each of the eight azimuths is located, and the second line is a line between the current location of the dividing point and the target anchor point; or,
if the boundary point is located in a region with ridge and bifurcation in the pixel gradient map, the moving direction of the boundary point is determined according to an included angle between a first connecting line and a second connecting line and a distance parameter, wherein the first straight line refers to a straight line in which each of eight azimuths is located, the second straight line refers to a connecting line between the current position of the boundary point and the target anchor point, and the distance parameter refers to a distance between the current position of the boundary point and the target anchor point; or,
if the boundary point is currently located in the pixel gradient map with ridge and no bifurcation area, the moving direction of the boundary point is determined according to the ridge direction of the pixel gradient map.
With reference to the second aspect, in some implementations of the second aspect, the method further includes: and if the moving direction of the previous moment of the demarcation point is the same as the moving direction of the current moment, determining the moving direction of the demarcation point according to the gradient absolute values of different moving directions.
In the embodiment of the present application, in the case that the moving direction of the boundary point at the previous time is the same as the moving direction of the current time, the boundary point may be moved to the preset direction, that is, the moving direction of the boundary point may be determined according to the absolute values of the gradients of different moving orientations, so that the error of the boundary point when moving along the ridge direction of the gradient map can be compensated.
With reference to the second aspect, in some implementations of the second aspect, the anchor point is obtained by optimizing an initial anchor point, wherein the initial anchor point is an anchor point manually marked in the first image by a user.
In the embodiment of the application, since the anchor point in the image to be processed is marked in the image to be processed manually by the user, the position of the anchor point may have a certain deviation; in order to make the position of the anchor point more accurate and improve the accuracy of the segmentation line of the image to be processed, the anchor point marked manually by the user can be optimized in position.
In a third aspect, an image segmentation apparatus is provided, wherein the image segmentation apparatus comprises a terminal device with a display screen, and the image segmentation apparatus comprises: the detection unit is used for detecting a first operation of manually marking anchor points in a first image by a user, wherein the anchor points comprise an initial anchor point and a target anchor point; detecting a second operation of automatically segmenting the first image indicated by the user;
and the processing unit is used for responding to the second operation, displaying a second image on the display screen, wherein the second image is obtained after the first image is subjected to the second operation, the second image comprises a dividing line between the starting anchor point and the target anchor point, and the dividing line is obtained by moving by taking the starting anchor point as a starting position and the target anchor point as a target position in the first image through a dividing point.
The dividing line can be obtained by automatically moving a dividing point in the first image by taking the starting anchor point as a starting position and taking the target anchor point as a target position; the automatic movement may mean that the user only needs to manually mark the initial anchor point and the target anchor point or a small number of mark points including the initial anchor point and the target anchor point in the first image, and the division line between the initial anchor point and the target anchor point in the first image can be automatically obtained.
With reference to the third aspect, in certain implementations of the third aspect, the dividing line coincides with a dividing line in a ridge direction in a pixel gradient map of the first image.
With reference to the third aspect, in some implementations of the third aspect, the processing unit is specifically configured to: searching a mask image and a secant image corresponding to the first image according to the first image, wherein the mask image is used for representing different objects in the first image, and the secant image is used for representing the boundaries of the different objects in the first image; and displaying the first image, the mask image and the superposed image of the secant image on the display screen.
With reference to the third aspect, in certain implementations of the third aspect, the detecting unit is further configured to detect that the user indicates a third operation of processing the second image through the mask image or the secant image.
In a possible implementation manner, the second image may refer to a superimposed image of the first image, the mask image and the secant image displayed on the display screen, and the third operation may be used to instruct automatic segmentation processing on the superimposed image through the mask image or the secant image.
With reference to the third aspect, in certain implementations of the third aspect, the second image is obtained from a pixel gradient map of the first image and an anchor point pulling model, where the anchor point pulling model is used to indicate a moving direction of the demarcation point.
With reference to the third aspect, in some implementations of the third aspect, when the dividing point is currently located in a region without ridge in the pixel gradient map, the moving direction of the dividing point is determined according to an included angle between a first line and a second line, where the first line is a straight line in which each of the eight orientations is located, and the second line is a line between the current location of the dividing point and the target anchor point; or
When the demarcation point is located in a region with ridge and bifurcation in the pixel gradient map, the moving direction of the demarcation point is determined according to an included angle between a first connecting line and a second connecting line and a distance parameter, wherein the first straight line refers to a straight line in which each azimuth in eight azimuths is located, the second straight line refers to a connecting line between the current position of the demarcation point and the target anchor point, and the distance parameter refers to a distance between the current position of the demarcation point and the target anchor point; or
When the boundary point is currently located in a region having ridge and no bifurcation in the pixel gradient map, the moving direction of the boundary point is determined according to the ridge direction of the pixel gradient map.
With reference to the third aspect, in certain implementations of the third aspect, in a case that a moving direction of the demarcation point at a previous time is the same as the moving direction of the demarcation point at a current time, the moving direction of the demarcation point is determined according to absolute values of gradients of different azimuths.
With reference to the third aspect, in certain implementations of the third aspect, the anchor point is obtained by optimizing an initial anchor point, wherein the initial anchor point is an anchor point manually marked in the first image by a user.
In a fourth aspect, there is provided an image segmentation apparatus comprising: the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a first image and position information of an anchor point in the first image, and the anchor point comprises an initial anchor point and a target anchor point; and the processing unit is used for obtaining a second image according to the first image and the anchor point, wherein the second image is obtained by image segmentation processing of the first image, the second image comprises a dividing line between the starting anchor point and the target anchor point, and the dividing line is obtained by moving a dividing point in a pixel gradient map of the first image by taking the starting anchor point as a starting position and taking the target anchor point as a target position.
In one possible implementation, a first image, a pixel gradient map of the first image, and location information of anchor points in the first image may be obtained, and the anchor points may include a start anchor point and a target anchor point.
The dividing line can be obtained by automatically moving a boundary-passing point in the first image by taking the starting anchor point as a starting position and taking the target anchor point as a target position; the automatic movement may be to acquire the start anchor point and the target anchor point in the first image, or to automatically obtain a dividing line between the start anchor point and the target anchor point in the first image by including a small number of mark points of the start anchor point and the target anchor point.
With reference to the fourth aspect, in certain implementations of the fourth aspect, the segmentation line coincides with a segmentation line in a ridge direction in the pixel gradient map.
With reference to the fourth aspect, in some implementations of the fourth aspect, the processing unit is specifically configured to: and obtaining the second image according to the pixel gradient map, the anchor point and an anchor point traction model, wherein the anchor point traction model is used for indicating the moving direction of the demarcation point.
With reference to the fourth aspect, in some implementations of the fourth aspect, if the dividing point is currently located in a region without ridge in the pixel gradient map, the moving direction of the dividing point is determined according to an included angle between a first line and a second line, where the first line is a straight line of each of the eight orientations, and the second line is a line between the current position of the dividing point and the target anchor point; or,
if the demarcation point is located in a region with ridge and bifurcation in the pixel gradient map, the moving direction of the demarcation point is determined according to an included angle between a first connecting line and a second connecting line and a distance parameter, wherein the first straight line refers to a straight line of each of eight azimuths, the second straight line refers to a connecting line between the current position of the demarcation point and the target anchor point, and the distance parameter refers to a distance between the current position of the demarcation point and the target anchor point; or,
if the boundary point is currently located in the pixel gradient map with ridge and no bifurcation area, the moving direction of the boundary point is determined according to the ridge direction of the pixel gradient map.
With reference to the fourth aspect, in certain implementations of the fourth aspect, the processing unit is further configured to: and if the moving direction of the previous moment of the demarcation point is the same as the moving direction of the current moment, determining the moving direction of the demarcation point according to the gradient absolute values of different moving directions.
With reference to the fourth aspect, in some implementations of the fourth aspect, the anchor point is obtained by optimizing an initial anchor point, wherein the initial anchor point is an anchor point manually marked by a user in the first image.
In a fifth aspect, an image segmentation apparatus is provided, the image segmentation apparatus having a display screen, comprising: a memory for storing a program; a processor for executing the memory-stored program, the processor for performing, when the memory-stored program is executed: detecting a first operation of manually marking anchor points in a first image by a user, wherein the anchor points comprise a starting anchor point and a target anchor point; detecting a second operation of automatically segmenting the first image indicated by the user; and displaying a second image on the display screen in response to the second operation, wherein the second image is obtained after the first image is subjected to the second operation, and the second image comprises a dividing line between the starting anchor point and the target anchor point, and the dividing line is obtained by moving a dividing point in the first image by taking the starting anchor point as a starting position and taking the target anchor point as a target position.
In a possible implementation manner, the processor included in the image segmentation apparatus is further configured to execute the image segmentation method in the first aspect and any implementation manner of the first aspect.
It will be appreciated that extensions, definitions, explanations and explanations of relevant content in the above-described first aspect also apply to the same content in the fifth aspect.
In a sixth aspect, there is provided an image segmentation apparatus comprising: a memory for storing a program; a processor for executing the memory-stored program, the processor for performing, when the memory-stored program is executed: acquiring a first image and position information of an anchor point in the first image, wherein the anchor point comprises an initial anchor point and a target anchor point; and obtaining a second image according to the pixel gradient map and the anchor point, wherein the second image is obtained by performing image segmentation processing on the first image, the second image comprises a dividing line between the starting anchor point and the target anchor point, and the dividing line is obtained by moving a boundary point in the pixel gradient map of the first image by taking the starting anchor point as a starting position and taking the target anchor point as a target position.
In a possible implementation manner, the processor included in the image segmentation apparatus is further configured to execute the image segmentation method in the first aspect and any implementation manner of the first aspect.
It will be appreciated that extensions, definitions, explanations and explanations of relevant matters in the above first aspect also apply to the same matters in the sixth aspect.
In a seventh aspect, a computer-readable medium is provided, which stores program code for execution by a device, where the program code includes instructions for performing the image segmentation method in the first aspect and any one of the implementations of the first aspect.
In an eighth aspect, a computer-readable medium is provided, which stores program code for execution by a device, the program code comprising instructions for performing the image segmentation method of the second aspect and any one of the implementations of the second aspect.
A ninth aspect provides a computer program product containing instructions for causing a computer to perform the image segmentation method of the first aspect and any one of the implementations of the first aspect when the computer program product runs on a computer.
In a tenth aspect, a computer program product containing instructions is provided, which when run on a computer causes the computer to perform the image segmentation method of the second aspect and any one of the implementations of the second aspect.
In an eleventh aspect, a chip is provided, where the chip includes a processor and a data interface, and the processor reads instructions stored in a memory through the data interface, and executes the image segmentation method in any one implementation manner of the first aspect and the first aspect.
Optionally, as an implementation manner, the chip may further include a memory, where instructions are stored in the memory, and the processor is configured to execute the instructions stored in the memory, and when the instructions are executed, the processor is configured to execute the image segmentation method in any one implementation manner of the first aspect and the first aspect.
In a twelfth aspect, a chip is provided, where the chip includes a processor and a data interface, and the processor reads instructions stored in a memory through the data interface, and executes the image segmentation method in any one implementation manner of the second aspect and the second aspect.
Optionally, as an implementation manner, the chip may further include a memory, where instructions are stored in the memory, and the processor is configured to execute the instructions stored in the memory, and when the instructions are executed, the processor is configured to execute the image segmentation method in any one of the second aspect and the second implementation manner of the second aspect.
Drawings
FIG. 1 is a schematic diagram of a system architecture provided by an embodiment of the present application;
FIG. 2 is a schematic flow chart of an image segmentation method provided by an embodiment of the present application;
FIG. 3 is a schematic flow chart of an image segmentation method provided by an embodiment of the present application;
FIG. 4 is a schematic diagram of an N-map adjusted mask image provided by an embodiment of the present application;
FIG. 5 is a schematic diagram of a to-be-processed image and a pixel gradient map provided by an embodiment of the present application;
FIG. 6 is a schematic flow chart diagram of a method for optimizing anchor point positions according to an embodiment of the present application;
FIG. 7 is a diagram of a four-way convolution kernel provided by an embodiment of the present application;
FIG. 8 is a schematic flow chart diagram of an image segmentation method provided by an embodiment of the present application;
FIG. 9 is a schematic flow chart of an image segmentation method provided by an embodiment of the present application;
FIG. 10 is a schematic flow chart of an anchor-based pull gradient ridge running algorithm provided by an embodiment of the present application;
FIG. 11 is a schematic diagram of convolution kernels for different azimuthal gradient calculations provided by embodiments of the present application;
FIG. 12 is a schematic diagram of performing lateral drift as provided by an embodiment of the present application;
FIG. 13 is a schematic diagram of an anchor point tow model provided by embodiments of the present application;
fig. 14 is a schematic block diagram of an image segmentation apparatus provided in an embodiment of the present application;
fig. 15 is a schematic block diagram of an image segmentation apparatus provided in an embodiment of the present application;
fig. 16 is a schematic hardware configuration diagram of an image segmentation apparatus according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
At present, a polygon method or a curve fitting method is generally adopted to accurately segment an image; the difference between the image segmentation line obtained by the polygon method and the actual segmentation line of the image is large, and the accuracy is low; the need to manually select multiple cut points by the curve fitting method results in a large amount of manpower.
In view of this, an embodiment of the present application provides an image segmentation method and an image segmentation apparatus, where a user manually marks an initial anchor point and a target anchor point on an image to be processed, so that a demarcation point automatically moves according to a pixel gradient map of the image to be processed with the initial anchor point as an initial position and the target anchor point as a target position, and a segmentation line of the image to be processed is obtained; namely, a dividing line can be automatically run out from a boundary point along the direction of the gradient ridge on the pixel gradient image, so that the dividing line is matched with the natural boundary of the image, and the accuracy of the image dividing result is improved under the condition of saving manpower.
Fig. 1 is a schematic diagram of a system architecture provided in an embodiment of the present application.
As shown in fig. 1, the system 100 may include an application server 110, a data server 120, and a plurality of clients (e.g., a client 131, a client 132, and a client 133); wherein, the client can be connected with the application server 110 and the data server 120 through the communication network; the data server 110 may be used to store massive image files and annotation files; the application server 120 may be used to provide image annotation, or retouching services; the client can be used to provide a human-computer interaction interface.
For example, the client may be a mobile or fixed terminal; for example, the client may be a mobile phone with an image processing function, a Tablet Personal Computer (TPC), a media player, a smart tv, a notebook computer (LC), a Personal Digital Assistant (PDA), a Personal Computer (PC), a camera, a camcorder, a smart watch, a Wearable Device (WD), an autonomous vehicle, or the like, which is not limited in the embodiment of the present application.
Wherein each client may interact with the data server 110 or the application server 120 via a communication network of any communication mechanism/communication standard, wherein the communication network may be a wide area network, a local area network, a peer-to-peer connection, etc., or any combination thereof.
It should be understood that the system 100 shown in fig. 1 is a multi-user system, and the image segmentation method provided by the present application is also applicable to a single-user system; for a single-user system, namely a system comprising a client, the image segmentation method provided by the embodiment of the application can be deployed at the client; for a multi-user system, that is, a system including multiple clients as shown in fig. 1, the image segmentation method provided by the embodiment of the present application may be deployed on a server, for example, an application server or a data server.
For example, the image segmentation method provided by the embodiment of the present application may be applied to an image segmentation labeling tool or a retouching tool, and the image segmentation method may be used to replace the background of an image or blurring the background of the image.
For example, a user starts a video call function in the intelligent terminal, and only a target object area is reserved after image segmentation is performed in real time in the shooting process, so that replacement of a video call background area is realized.
For example, a user starts a shooting function at the intelligent terminal, and can virtualize a foreground region and a background region of a shot target object after performing image segmentation in real time in the shooting process, so that the image effect of a large aperture of a single lens reflex is realized.
It should be understood that the background blurring and the background replacement of the image described above are only two specific scenes to which the image processing method according to the embodiment of the present application is applied, and the image processing method according to the embodiment of the present application is not limited to the above two scenes, and the image processing method according to the embodiment of the present application can be applied to any scene requiring image segmentation.
The image segmentation method according to the embodiment of the present application is described in detail below with reference to fig. 2 to 13.
Fig. 2 is a schematic flowchart of an image segmentation method provided in an embodiment of the present application. The method may be performed by the server or the client shown in fig. 1, and the method shown in fig. 2 includes steps 210 to 230, which are described in detail below.
Step 210, a first operation of manually marking an anchor point in a first image by a user is detected.
The first image may refer to an image to be processed with an image segmentation requirement, and the anchor point may include a start anchor point and a target anchor point.
Illustratively, before step 210, the user may open the image processing tool by operation and import the first image into the image processing tool, and the first image required to be subjected to image segmentation may be displayed on an interface of the image processing tool.
Step 220, detecting a second operation of automatically segmenting the first image indicated by the user.
For example, the second operation of the user for indicating automatic segmentation of the first image may include the user clicking a button of the automatic segmentation image in the image processing tool, or may include a behavior that the user indicates automatic segmentation through voice, or may also include other behaviors that the user indicates automatic segmentation; the foregoing is illustrative and not limiting of the present application.
Step 230, responding to the second operation, displaying a second image on the display screen;
the second image is obtained after the first image is subjected to the second operation, the second image comprises a division line between the starting anchor point and the target anchor point, and the division line is obtained by moving a demarcation point in the first image by taking the starting anchor point as a starting position and taking the target anchor point as a target position.
For example, the above-mentioned dividing line may be automatically moved by a boundary point in the first image with the start anchor point as a start position and the target anchor point as a target position; the automatic movement may mean that the user only needs to manually mark the initial anchor point and the target anchor point or a small number of mark points including the initial anchor point and the target anchor point in the first image, and the division line between the initial anchor point and the target anchor point in the first image can be automatically obtained.
It should be understood that the start anchor point and the target anchor point may be positions in the image to be processed, where the positions of the start anchor point and the target anchor point do not change, and a division line between the start anchor point and the target anchor point in the first image may be obtained by moving a division point from the start anchor point to the target anchor point, where the division line coincides with a natural boundary of a different object in the first image.
For example, the above mentioned boundary point may be a start point, and the target point is a target position, and a dividing line runs out along the ridge of the pixel gradient map of the first image, that is, the dividing line coincides with the dividing line in the ridge direction in the pixel gradient map of the first image; the pixel gradient map of the first image may refer to an image composed of the variation of the brightness of the pixels in different rows or different columns in the first image.
In an example, after the user indicates the second operation of automatic segmentation, the terminal device may search, according to the first image, a mask image and a cut line image corresponding to the first image, where the mask image may be used to represent an object region in the first image, and the cut line image may be used to represent a boundary of different objects in the first image; and displaying the image to be processed, the mask image and the secant image in an interface of the image processing tool after the image to be processed, the mask image and the secant image are superposed.
For example, the mask image corresponding to the first image and the secant image corresponding to the first image are found after the search.
In an example, if the dividing line image and the mask image corresponding to the first image are not found after the search, the dividing line image and the mask image corresponding to the first image need to be generated.
For example, automatic image segmentation is performed on the first image by adopting Mask-RCNN, deep LabV3 or other algorithms, so as to generate a Mask image corresponding to the first image; further, a preset boundary threshold is adopted according to the first image and the mask image, the mask range is automatically adjusted by using an N-map-based method, and then a secant image is automatically generated according to the mask boundary, so that the secant image and the mask image are automatically aligned.
Wherein, the N-map method can also be called boundary drift based on N-map; supposing that N image segmentation areas exist in a mask layer file, the value of each pixel is the area number K of the pixel, and the K belongs to [0, N-1 ]; setting pixels of unknown classification at two sides of the secant, and changing the value of the mask layer of the pixels into N; then, the corresponding image layer file is processed by using a pre-trained deep neural network, and pixels of unknown classification and background pixels are distributed into N segmentation areas.
In an example, after the search, the secant image corresponding to the first image is found, and if the mask image corresponding to the first image is not found, the mask image corresponding to the first image needs to be generated.
In one example, after searching, a mask image corresponding to a first image is found, and if a secant image corresponding to the first image is not found, a secant image corresponding to the first image needs to be generated; the specific process of generating the secant image is shown in the schematic flow charts shown in fig. 9 and fig. 10.
Further, the user may manually select to perform the segmentation process on the first image through the mask image or the secant image.
It should be noted that after the user adjusts the mask image, the dividing line image needs to be updated synchronously, that is, the updated mask image and the dividing line image are aligned synchronously; similarly, after the user adjusts the secant image, the mask image needs to be updated synchronously, i.e. the updated secant image and the mask image are aligned synchronously.
Optionally, in an embodiment of the present application, the image segmentation method further includes: detecting a third operation of the user indicating to process the second image through the mask image or the secant image.
In a possible implementation manner, the second image may refer to a superimposed image of the first image, the mask image, and the secant image displayed on the display screen, and the third operation may be used to instruct the automatic segmentation processing on the superimposed image through the mask image or the secant image.
Alternatively, in an embodiment of the present application, the second image may be obtained from a pixel gradient map of the first image and an anchor point traction model, and the anchor point traction model may be used to indicate a moving direction of the boundary point, that is, the anchor point may be caused to obtain a partition line of the first image in a ridge direction along the pixel gradient map by a preset anchor point traction model, so that the partition line of the first image is consistent with a natural boundary of the image.
For example, the anchor point traction model may provide a moving direction for a dividing point in the segmentation line, for example, when the dividing point is currently located in a region without ridge in the pixel gradient map, the moving direction of the dividing point is determined according to an included angle between a first line and a second line, wherein the first line is a straight line in which each of the eight orientations is located, and the second line is a line between the current position of the dividing point and the target anchor point;
or when the dividing point is located in a region with ridge and bifurcation in the pixel gradient map, the moving direction of the dividing point is determined according to an included angle between a first connecting line and a second connecting line and a distance parameter, wherein the first connecting line is a straight line in which each of eight azimuths is located, the second connecting line is a connecting line between the current position of the dividing point and the target anchor point, and the distance parameter is a distance between the current position of the dividing point and the target anchor point;
or, when the boundary point is currently located in a region having a ridge and no bifurcation in the pixel gradient map, the moving direction of the boundary point is determined according to the ridge direction of the pixel gradient map.
As shown in fig. 11 (a), the first line, i.e., each of the eight azimuths, may be a straight line oa, a straight line ob, a straight line oc, a straight line od, a straight line of, a straight line og, and a straight line oh.
Illustratively, the model of the gravity of a target anchor point (e.g., anchor point B) versus a running point (e.g., a cut point) may be viewed as being composed of a strong gravity model and a weak gravity model; assuming that the distance between the running point and the target anchor point is dis, the distance between the anchor point A and the anchor point B is d0, and the included angle between the connecting lines of the 8 azimuths and the anchor point AB is thetaiThe strong gravity weight w for each orientation can be calculated from the gravity model shown in FIG. 13iAnd weak gravitational offset bi. For the strong gravity model and the weak gravity model, the smaller the connecting line included angle between the 8 directions and the anchor point AB is, the larger the gravity is; for example, the orientation gravity with an angle of 0 ° with the anchor point AB line among the 8 orientations is the largest, and the orientation gravity with an angle of 180 ° with the anchor point AB line is the smallest. The strong and weak gravity models differ in that the weak gravity model is independent of distance dis; the strong gravity model has the slowest speed of gravity attenuation along with the increase of the included angle when dis is d0, and the faster the dis deviates from the d0 attenuation speed.
Further, in order to compensate for an error of the boundary point when moving along the ridge direction of the gradient map, in a case where the moving direction of the boundary point at the previous time is the same as the moving direction of the current time, the boundary point may be moved in a preset direction, that is, the moving direction of the boundary point is determined according to the absolute value of the gradient of different moving azimuths.
In the embodiment of the application, because the position of the anchor point is generated by clicking in the image through the mouse by the user, the position of the anchor point may have a deviation and is not located on the gradient map corresponding to the image, and in order to enable the anchor point to accurately obtain the dividing line of the image according to the gradient map, the position of the anchor point can be optimized.
Illustratively, the position of the anchor point may be optimized by a quadriversal gradient convolution kernel as shown in fig. 6 in the embodiments of the present application; for example, the position of the anchor point may be optimized according to the absolute values of the gradients of the anchor point in different directions, so as to obtain the optimized position information of the anchor point.
Fig. 3 shows a schematic flowchart of an image segmentation method provided by an embodiment of the present application, which may be performed by an image processing tool (e.g., an image segmentation labeling tool, or a cropping tool) in the server or the client shown in fig. 1. The method shown in fig. 3 includes steps 301 to 311, which are described in detail below.
Firstly, explaining the image layers included in the image processing tool; the image processing tool may include an image layer, a mask layer, and a cut line layer.
Wherein each pixel value in the image layer may represent a gray scale of an image, and the pixel coordinates (x, y) may be a positive integer, the image layer is displayed as a normal image, for example, a color image on the screen.
For example, each pixel value in the mask layer may represent a serial number of the mask; for example, when the mask layer is displayed on the screen, the same dyeing may be adopted for each area with the same mask serial number, for example, the mask serial number of the background is 0, and the dyeing may be blue when displayed; the serial number of a mask of the TV is 1, and the mask is dyed into red when displayed; other mask sequence numbers and so on. The user may assign a different display color to each mask sequence number by manipulating a menu or button or palette on a Graphical User Interface (GUI).
Exemplarily, the cutting line layer may be composed of a cutting line composed of an anchor point and a cutting point; wherein, the anchor point can be an endpoint of the partition line; the value of an anchor may represent a sequence number of an anchor (e.g., 129 to 255) the value of a segmentation point may represent a sequence number of a segmentation line (e.g., 1 to 127), and a point having a value of 0 may be neither an anchor nor a segmentation point.
For example, the anchor point and the segmentation point may be between pixels, not coinciding with the pixel location, with its two-dimensional coordinates (u, v) offset from the coordinates (x, y) of nearby pixels by a distance of 0.5 pixels.
For example, the split layer may be a dotted line when displayed on the screen, and the anchor point may be a small circle when displayed on the screen; the user can move any anchor point through clicking or dragging and other operations, and the dividing line also moves along with the anchor point.
It should be noted that, the user can operate a menu or a button on the labeling tool GUI, so that each layer can be independently closed (not shown) or opened (shown).
Step 301, reading an image layer file.
For example, the user may import the image layer file by operation.
Step 302, mask layer files and secant layer files corresponding to the image layer files are searched.
The image layer file may be an image file of a specific image segmentation requirement, and a file corresponding to the image layer file may be searched through a preset file path.
Illustratively, each layer file may be saved as a bitmap file (BMP), a lossless compressed bitmap graphics format (PNG), or other image file format; the correspondence between different layer files may be described by using an icon or a file name naming rule, or the image layer file, the mask layer file corresponding to the image layer file, and the cut line file corresponding to the image layer file are packaged in one file or one folder, as shown in table 1.
TABLE 1
Image layer file Mask layer file Cut line layer document
P0001_img.jpg P0001_msk.png P0001_ctl.png
P0002_img.jpg P0002_msk.png P0002_ctl.png
P0003_img.jpg P0003_msk.png P0003_ctl.png
Illustratively, the correspondence relationship between the partition line sequence number and the anchor point sequence number may be shown in table 2.
TABLE 2
Parting line Anchor point A Anchor point B
1 129 130
2 130 132
3 130 134
In one example, step 306 may be performed by determining to save the mask layer file and the scribe line layer file corresponding to the image layer file after the search.
In one example, if it is determined that there is no dividing line layer file and mask layer file corresponding to the image layer file after the search, step 303 is executed to automatically generate a mask layer file and a dividing line layer file corresponding to the image layer file.
For example, the Mask layer file is generated by automatically segmenting an image through the image layer file by adopting Mask-RCNN or deep LabV3 or other algorithms; furthermore, according to the image layer file and the mask layer file, a preset boundary threshold is adopted, the mask range is automatically adjusted by using an N-map-based method, and then a cutting line layer file is automatically generated according to the mask boundary, so that the cutting line layer and the mask layer are automatically aligned.
The method for adjusting the mask layer based on the N-map can also be called boundary drift based on the N-map; supposing that N image segmentation areas exist in a mask layer file, the value of each pixel is the area number K of the pixel, and the K belongs to [0, N-1 ]; setting pixels of unknown classification at two sides of the secant, and changing the value of the mask layer of the pixels into N; then, the corresponding image layer file is processed by using a pre-trained deep neural network, and pixels of unknown classification and background pixels are distributed into N segmentation areas.
For example, as shown in fig. 4, the value of the mask layer may be changed to N for T consecutive pixels on both sides of the cut line perpendicular to the midpoint of the cut line; the farther the distance from the midpoint of the secant is, the fewer the number of pixels for changing the value of the mask layer to N is; changing the value of the mask layer to be N at the anchor point, wherein the number of pixels is 0; if the secant is a closed curve which does not comprise the anchor point, the values of the mask layers on the two sides of the secant can be changed into N at any position of the secant, and the number of pixels is T; where T may be a preset threshold, which may be manually adjusted in the user interface.
In one example, after the search, it is determined that the mask layer file corresponding to the image layer file is saved, but there is no dividing line layer file corresponding to the image layer file, step 304 is performed to automatically generate the dividing line layer file.
For example, according to the image layer file and the mask layer file corresponding to the image layer file, the mask range can be automatically adjusted by using an N-map-based method according to a preset boundary threshold, and then the cutting line layer file is automatically generated according to the mask boundary, so that the cutting line layer and the mask layer are automatically aligned.
In one example, if it is determined after searching that the dividing line layer file corresponding to the image layer file is saved, but there is no mask layer file corresponding to the image layer file, step 305 is executed to automatically generate a mask layer file.
For example, according to the image layer file and the segmentation layer file corresponding to the image layer file, the user can observe the edge of the image, manually adjust the anchor point of the segmentation layer, and automatically adjust the segmentation position of the segmentation layer by using an anchor point traction gradient ridge running method; and then, automatically generating a mask layer file to enable the mask layer to be automatically aligned with the cutting line layer.
Step 306, the three layer files can be displayed in an overlapping manner to allow a user to edit the image segmentation.
Step 307, the user can select an image for image segmentation and editing; for example, if the user selects the mask layer file to perform the adjustment of image segmentation, step 308 and step 309 are executed; if the user selects the slice-level file to adjust the image segmentation, step 310 and step 311 are executed.
Step 308, adjust the mask layer file.
For example, the mask layer file may be adjusted by the N-map method shown in fig. 4.
Step 309, performing a dividing line layer file update on the updated mask layer file, i.e. the updated mask layer file and the dividing line layer file are aligned synchronously.
And step 310, adjusting the cutting line layer file.
For example, the anchor point of the cut line layer file can be manually adjusted by observing the edge of the image by a user; or automatically adjust the secant position of the secant layer file using the anchor pull gradient ridge running algorithm as described later with reference to fig. 9 and 10.
And 311, updating the mask layer file of the updated secant layer file, namely, synchronously aligning the updated secant layer file with the mask layer file.
Exemplarily, as shown in fig. 5, wherein (a) in fig. 5 is shown as an original image, and (b) in fig. 5 is shown as a pixel gradient map corresponding to the original image shown in (a) in fig. 5; the user can observe the original image (e.g. color image), click 6 anchor points (e.g. 1-6) in the original image by mouse, and the positions of the 6 anchor points can be mapped on the pixel gradient map; on the pixel gradient map, a partition line can be run out by dragging an anchor point along the ridge direction of the pixel gradient map between 2 adjacent anchor points, 6 partition lines can form 1 closed curve, the inside of the curve can be a foreground, and the outside of the curve can be a background.
It should be understood that only the original image may be displayed on the annotation tool interface, typically, without displaying the pixel gradient map.
Further, in the embodiment of the present application, since the anchor point in the image to be processed is marked in the image to be processed manually by the user, there may be a certain deviation in the position of the anchor point; in order to make the position of the anchor point more accurate and improve the accuracy of the segmentation line of the image to be processed, the anchor point marked manually by the user can be optimized in position.
For example, fig. 6 is a schematic flowchart of a method for optimizing anchor point positions according to an embodiment of the present application. The method shown in fig. 6 includes steps 401 to 406, which are described in detail below.
Step 401, displaying an image layer and a cut line layer in a Graphical User Interface (GUI).
Step 402, the user edits the anchor point location.
For example, the user may generate an anchor point by clicking on the image, or the user may drag an existing anchor point to generate an updated anchor point.
And 403, acquiring the original coordinates of the anchor point.
For example, the original coordinates of anchor point a are (x1, y 1).
And step 404, searching ridge according to the four-direction gradient to obtain the optimized anchor point position.
Exemplarily, a four-way convolution kernel provided by the embodiment of the present application is illustrated in fig. 7, wherein (a) in fig. 7 illustrates a V-direction gradient convolution kernel; fig. 7 (b) shows an H-direction gradient convolution kernel; shown in fig. 7 (c) is an L-direction gradient convolution kernel; fig. 7 (d) shows an R-direction gradient convolution kernel.
For example, the method of optimizing an anchor is exemplified by the V-direction gradient ridge search position shown in (e) of fig. 7 and the R-direction gradient ridge search position shown in (f) of fig. 7, and a gradient ridge is searched in a direction in which the absolute value of the four-direction gradient is maximum; for example, the homodromous gradient is respectively calculated at the positions of A-1, A-2, A-3 and A-4 and the positions of A +1, A +2, A +3 and A +4, and if the position with the opposite sign of the homodromous gradient at the anchor point A appears, the search is immediately stopped; and then taking the position with the maximum absolute value of the gradient as the optimized anchor point position A at the position with the same gradient sign as the anchor point A.
Step 405, anchor point data in the secant is adjusted.
Step 406, displaying the optimized anchor points (x2, y2) in a graphical user interface.
Fig. 8 is a schematic flowchart of an image segmentation method provided in an embodiment of the present application. The method may be performed by the server or the client shown in fig. 1, and the method shown in fig. 8 includes steps 510 and 520, which are described in detail below.
Step 510, obtaining the first image and position information of an anchor point in the first image, where the anchor point may include a start anchor point and a target anchor point.
The first image may refer to an image having an image segmentation requirement.
Illustratively, a pixel gradient map of the first image may also be acquired in step 510.
And step 520, obtaining a second image according to the first image and the anchor point.
The second image is obtained by subjecting the first image to image segmentation processing, and the second image may include a dividing line between the start anchor point and the target anchor point, and the dividing line may be obtained by moving through a boundary point in a pixel gradient map of the first image with the start anchor point as a start position and the target anchor point as a target position.
It should be understood that the start anchor point and the target anchor point may be locations in the first image that do not change location, and a division line between the start anchor point and the target anchor point in the first image may be obtained by moving a dividing point from the start anchor point to the target anchor point, the division line coinciding with a natural boundary of a different object in the first image.
For example, the above mentioned boundary point may be a start point as a start position, and the target point as a target position runs out a dividing line along the ridge of the pixel gradient map of the first image, that is, the dividing line coincides with the dividing line in the ridge direction in the pixel gradient map of the first image.
It should be noted that the ridge direction in the pixel gradient map of the first image may refer to a curve formed by local maxima of gradient in the pixel gradient map.
Optionally, in an embodiment of the present application, obtaining the second image according to the first image and the anchor point may include: and obtaining a second image according to the pixel gradient map of the first image, the anchor point and the anchor point traction model, wherein the anchor point traction model can be used for indicating the moving direction of the demarcation point.
Exemplarily, if the boundary point is currently located in a region without ridge in the pixel gradient map, the moving direction of the boundary point is determined according to an included angle between a first line and a second line, where the first line is a straight line in which each of the eight azimuths is located, and the second line is a straight line between the current position of the boundary point and the target anchor point; or,
if the boundary point is located in a region with ridge and bifurcation in the pixel gradient map, the moving direction of the boundary point is determined according to an included angle between a first connecting line and a second connecting line and a distance parameter, wherein the first straight line refers to a straight line in which each of eight azimuths is located, the second straight line refers to a connecting line between the current position of the boundary point and the target anchor point, and the distance parameter refers to a distance between the current position of the boundary point and the target anchor point; or,
if the boundary point is currently located in the pixel gradient map with ridge and no bifurcation area, the moving direction of the boundary point is determined according to the ridge direction of the pixel gradient map.
For example, as shown in FIG. 13, a strong gravity weight w for each orientation can be calculated from the gravity modeliAnd weak gravitational offset bi. For the strong gravity model and the weak gravity model, the smaller the connecting line included angle between the 8 directions and the anchor point AB is, the larger the gravity is; for example, the orientation gravity with an angle of 0 ° with the anchor point AB line among the 8 orientations is the largest, and the orientation gravity with an angle of 180 ° with the anchor point AB line is the smallest. The strong and weak gravity models differ in that the weak gravity model is independent of distance dis; the strong gravity model has the slowest speed of gravity attenuation along with the increase of the included angle when dis is d0, and the faster the dis deviates from the d0 attenuation speed.
Further, in order to compensate for an error of the boundary point when moving along the ridge direction of the gradient map, in a case where the moving direction of the boundary point at the previous time is the same as the moving direction of the current time, the boundary point may be moved in a preset direction, that is, the moving direction of the boundary point is determined according to the absolute value of the gradient of different moving azimuths.
In the embodiment of the application, because the position of the anchor point is generated by clicking in the image through the mouse by the user, the position of the anchor point may have a deviation and is not located on the gradient map corresponding to the image, and in order to enable the anchor point to accurately obtain the dividing line of the image according to the gradient map, the position of the anchor point can be optimized.
Illustratively, the position of the anchor point may be optimized by a quadriversal gradient convolution kernel as shown in fig. 6 in the embodiments of the present application; for example, the position of the anchor point may be optimized according to the absolute values of the gradients of the anchor point in different directions, so as to obtain the optimized position information of the anchor point.
Fig. 9 shows a schematic flowchart of an image segmentation method provided by an embodiment of the present application, which may be executed by the server or the client shown in fig. 1. The method shown in fig. 9 includes steps 601 to 609, which are described in detail below.
Step 601, obtaining an anchor point position A.
The anchor point position a may be an anchor point selected by the user in the image, or a new anchor point generated by dragging an existing anchor point by the user.
For example, the user may click on the image with a mouse to generate an anchor point, or the user may drag a new anchor point generated by an existing anchor point with a mouse.
Further, the position information of the anchor point a on the picture can be obtained through a marking tool.
And step 602, optimizing the anchor point position A.
It should be understood that, since the anchor point position a is generated by the user clicking in the image through the mouse, the anchor point position a may have a deviation and is not located on the gradient map corresponding to the image, and the anchor point position a may be optimized in order to enable the anchor point to accurately obtain the segmentation line of the image according to the gradient map.
Illustratively, anchor point position a may be optimized in embodiments of the present application by a four-way gradient convolution kernel as shown in fig. 6.
For example, by performing convolution on the images by the convolution kernels shown in fig. 7, the quadriversal gradients (for example, V direction, H direction, L direction, and R direction) of the anchor point a can be obtained, the gradient ridge is searched in the direction with the maximum absolute value of the quadriversal gradient, and if a position with a sign opposite to that of the homodromous gradient at the anchor point a appears, the search is immediately stopped; and then taking the position with the maximum absolute value of the gradient as the optimized anchor point position A at the position with the same gradient sign as the anchor point A.
And step 603, acquiring an anchor point position B.
The anchor point position a may refer to a starting point of image segmentation, the anchor point position B may refer to a target point of image segmentation, and a segmentation line of the image may be obtained through connection between the anchor point position a and the anchor point position B.
Similarly, anchor position B may be an anchor selected by the user in the image, or the user may drag a new anchor generated by an existing anchor.
For example, the user may click on the image with a mouse to generate anchor point B, or the user may drag a new anchor point generated by an existing anchor point with a mouse.
And step 604, optimizing the anchor point position B.
It should be noted that the specific process for optimizing the anchor point position B is similar to the step 602, and is not described herein again.
It should be understood that step 601 and step 603 may be executed simultaneously, or step 601 may be executed first and then step 603 is executed; similarly, step 602 and step 604 may be executed simultaneously, or step 602 may be executed first and then step 604 is executed, which is not limited in this application.
Step 605, a plurality of candidate partition lines are generated according to the optimized anchor position a and the optimized anchor position B.
And executing a process of performing anchor-based traction gradient ridge running according to the optimized anchor position a and the optimized anchor position B, wherein the specific process refers to a flowchart shown in fig. 10.
In one example, the optimized anchor point position a and the anchor point position B perform bidirectional running, that is, the optimized anchor point position a takes the position a as a starting point and the optimized anchor point position B as a target point to perform running; the optimization anchor point position B takes the position B as a starting point, and the optimization anchor point position A as a target point to execute running points; two dividing lines L1 and L2 are obtained, wherein the number of the break points is N1 and N2, respectively, and the break point may mean that the gradient value of a certain running point is lower than a preset threshold.
In one example, running from optimization anchor position B to optimization anchor position A, we get a split line L3, where the number of breakpoints is N3.
In one example, going from optimization anchor position a to optimization anchor position B, we get a split line L4, where the number of breakpoints is N4.
And step 606, preferably selecting the partition line with the minimum break point.
For example, the segment line with the smallest number of break points is selected from the plurality of candidate segment lines based on the obtained segment lines L1 to L4 and the break points N1 to N4.
Step 607, judging whether the selection of the dividing line is successful; if successful, go to step 608 to end the process; if not, the user manually selects 609.
Illustratively, counting the number of breakpoints of each partition line, and preferably selecting the partition line with the smallest number of breakpoints; if the number of breakpoints of the partition line with the minimum number of breakpoints is not greatly different from the number of breakpoints of other partition lines, a plurality of partition lines can be presented for a user to manually select.
FIG. 10 is a schematic flow chart of anchor-based pull gradient ridge based running provided by an embodiment of the present application. The method may be performed by a server or a client as shown in fig. 1. The method shown in fig. 10 includes steps 701 to 710, which are described in detail below.
Step 701, sending from an anchor point position A.
For example, anchor position a may be an anchor selected by the user in the image, or the user may drag a new anchor generated by an existing anchor.
For example, a preset step size may be set before starting from the anchor point position a, that is, a distance offset by one step from the anchor point position a to the target anchor point B.
It should be understood that the anchor point position a may be a starting anchor point manually marked in the image by the user, or may also refer to an anchor point position in the process of moving from the starting anchor point to the target anchor point, which is not limited in this application.
And step 702, updating the starting point coordinates.
Updating the starting point coordinate can mean optimizing the anchor point position A, so that the accuracy of the dividing line is improved; the specific process of optimizing the anchor point position a can be seen in fig. 7, and is not described herein again.
It should be understood that, in the embodiment of the present application, the dividing line of the image may be obtained by moving a boundary point in a pixel gradient map corresponding to the image with a start anchor point as a start position and a target anchor point as a target position, where the running point may refer to a point on the dividing line where the boundary point is moved by an algorithm according to a preset step length, and the running point may be moved from the position of the start anchor point to the position of the target anchor point according to the preset step length and a selected running direction, so as to obtain the dividing line of the image between the start anchor point and the target anchor point.
Step 703, selecting the run-out direction.
It should be understood that the above-mentioned running-out direction may refer to a moving direction in which the running point moves by one step according to a preset step length.
In the embodiment of the present application, the running-out direction of the running point may be selected according to the preset step length according to the following several ways: the first method is as follows: and determining the running-out direction of the running point based on the calculated gradient values of different directions.
For example, a schematic view of an 8-way orientation shown in (a) in fig. 11; shown in fig. 11 (b) is the oa azimuthal gradient convolution kernel; shown in fig. 11 (c) is the ob azimuth gradient convolution kernel; shown in fig. 11 (d) is the oab azimuthal gradient convolution kernel; FIG. 11 (e) shows the ocd azimuthal gradient convolution kernel; if the running-in direction of the running point is below the fob direction, an oab gradient convolution kernel can be adopted; if the running direction of the running point is above the fob direction, ocb gradient convolution kernels can be adopted; if the running direction of the running point is fo, the larger of the oab gradient and the ocb gradient may be used.
In an embodiment of the present application, no back-run is allowed to occur during anchor points along ridge running points of a gradient map; for example, if the previous step is from ao direction, the next step is not allowed to go out from oa direction; therefore, in order to determine the run-out direction of the next step, it is necessary to calculate gradients in the remaining 7 directions different from the run-in direction, for example, if the previous step is run-in from the ao direction, 7-direction gradients such as ob, oc, od, oe, of, og, oh, etc. are calculated, and the next run-out step is selected from 7 to the direction with the largest absolute value of the gradients.
The second method comprises the following steps: and determining the running-out direction of the running point based on the anchor point traction model.
Illustratively, first, a distance dis of the running point from the anchor point position B may be calculated, for example, a distance d0 between the anchor point position a and the anchor point position B; then, the towing weights wi and bi of the anchor point a can be calculated to obtain an anchor point towing model.
The anchor traction model can be regarded as being composed of a strong gravitation model and a weak gravitation model; for example, assume that the distance between the running point and the target anchor point is dis, the distance between anchor point a and anchor point B is d0, and the angle between the connection lines of 8 azimuths and anchor point AB is θiThe strong gravity weight w for each orientation can be calculated from the gravity model shown in FIG. 13iAnd weak gravitational offset bi. For the strong gravity model and the weak gravity model, the smaller the connecting line included angle between the 8 directions and the anchor point AB is, the larger the gravity is; for example, the orientation gravity with an angle of 0 ° with the anchor point AB line among the 8 orientations is the largest, and the orientation gravity with an angle of 180 ° with the anchor point AB line is the smallest. The strong and weak gravity models differ in that the weak gravity model is independent of distance dis; the strong gravity model has the slowest speed of gravity attenuation along with the increase of the included angle when dis is d0, and the faster the dis deviates from the d0 attenuation speed.
In an embodiment of the present application, the weighted calculation of the gradient may be performed by the following equation:
D’i=wi*(Di+bi);
wherein, D'iA weighted 7-way gradient representing the ith azimuth; diAn unweighted 7-way gradient representing the ith azimuth; w is aiA strong gravity weight representing the ith orientation; biA weak gravity weight representing the ith orientation.
For example, when a running point is located in a region without an apparent ridge, the weak gravity model may provide explicit direction guidance for the running point; when the running point is located at a ridge bifurcation of the ridge, the strong gravity model can provide clear direction guidance for the running point; when the running point is located on a distinct ridge of the ridge and has no bifurcation, the path of the running point can be primarily determined by the gradient map.
For example, as shown in fig. 13, a strong gravity weight wi and a weak gravity offset bi for each orientation may be calculated; wherein (a) in fig. 13 shows different anchor point directions; fig. 13 (b) is a schematic diagram showing a strong gravitational force model; fig. 13 (c) is a schematic diagram of the weak gravitational force model. For example, the schematic image shown in fig. 13 (b) includes a straight line 1, a straight line 2, and a straight line 3, where the straight line 1 may represent a strong gravity model when dis is 0 or dis is 2d 0; line 2 may represent a strong gravity model when dis is 0.4d0 or 1.6d 0; line 3 may represent the strong gravity model when dis — d 0; as can be seen from the 3 straight lines shown in fig. 13 (b), the greater the slope of the straight line, the stronger the traction force to the running point; the included angle between the strong gravitation model and the connecting line between the anchor point AB and different directions and the distance between the running point and the target anchor point are dis correlation; the weak gravity model is associated with the connecting line clip angle of the anchor point AB at different orientations.
In the embodiment of the application, the moving direction of each step of the running point can be calculated according to the first and second modes, so that the next running direction of the running point is obtained.
Step 704, judging whether the running-out direction and the running-in direction of the running point are the same; if yes, go to step 705; if not, go to step 709 to determine whether anchor point B is reached.
If the selected running-out direction is different from the running-in direction and the running point reaches the anchor point position B, execute step 710 to end the running point process, i.e. end the moving process of the demarcation point; if the selected run-out direction is different from the run-in direction and the running point does not reach the anchor point position B, the process returns to step 702.
Further, in the embodiment of the present application, in order to compensate for the error of the running point in moving along the pixel gradient map, step 705 may be performed.
Step 705, determine the drift direction.
For example, if the running point runs in from the eo direction and runs out from the oa direction, three positions a, a1, a2 are used as the alternative lateral drift directions. For example, as shown in (a) of fig. 12, a position having a sign opposite to that of the oa-direction gradient may be excluded by calculating the o1a 1-direction gradient and the o2a 2-direction gradient as shown in (b) of fig. 12, and the position having the largest absolute value of the gradient may be selected as the drift direction among the remaining positions.
Step 706, judging whether the drift is continuous equidirectional drift; if the continuous equidirectional drift is detected, step 708 is executed to cancel the drift; if the direction is not continuous equidirectional drift, step 707 is executed to perform drift.
For example, the continuous equidirectional drift refers to that the running point moves in the drift direction when the running point executes the preset steps, and in this case, in order to ensure that the running point can reach the target anchor point position (i.e., anchor point position B), the drift may be cancelled, and the running direction of the running point is determined again in one of the above manners or in the above manner.
It is to be understood that the above description is intended to assist those skilled in the art in understanding the embodiments of the present application and is not intended to limit the embodiments of the present application to the particular values or particular scenarios illustrated. It will be apparent to those skilled in the art from the foregoing description that various equivalent modifications or changes may be made, and such modifications or changes are intended to fall within the scope of the embodiments of the present application.
The image segmentation method according to the embodiment of the present application is described in detail above with reference to fig. 1 to 13, and the device embodiment of the present application is described in detail below with reference to fig. 14 to 16. It should be understood that the image segmentation apparatus in the embodiment of the present application may perform the various image segmentation methods in the embodiments of the present application, that is, the following specific working processes of various products, and reference may be made to the corresponding processes in the embodiments of the foregoing methods.
Fig. 14 is a schematic block diagram of an image segmentation apparatus provided in an embodiment of the present application. It should be understood that the image segmentation apparatus 800 may perform the image segmentation method illustrated in fig. 6 and fig. 8 to 13. The image segmentation apparatus 800 includes: a detection unit 810 and a processing unit 820.
The detection unit 810 is configured to detect a first operation of manually marking anchor points in a first image by a user, where the anchor points include a start anchor point and a target anchor point; detecting a second operation of automatically segmenting the first image indicated by the user; the processing unit 820 is configured to display a second image on the display screen in response to the second operation, where the second image is an image obtained by the first image after the second operation, and the second image includes a division line between the start anchor point and the target anchor point, where the division line is obtained by moving a division point in the first image with the start anchor point as a start position and the target anchor point as a target position.
Optionally, as an embodiment, the dividing line coincides with a dividing line in a ridge direction in a pixel gradient map of the first image.
Optionally, as an embodiment, the processing unit 820 is specifically configured to:
searching a mask image and a secant image corresponding to the first image according to the first image, wherein the mask image is used for representing different objects in the first image, and the secant image is used for representing the boundaries of the different objects in the first image; and displaying the first image, the mask image and the superposed image of the secant image on the display screen.
Optionally, as an embodiment, the detecting unit 810 is further configured to:
detecting a third operation of the user indicating that the second image is subjected to segmentation processing through the mask image or the secant image.
Optionally, as an embodiment, the second image is obtained according to a pixel gradient map of the first image and an anchor point traction model, where the anchor point traction model is used to indicate a moving direction of the demarcation point.
Optionally, as an embodiment, when the dividing point is currently located in a region without ridges in the pixel gradient map, the moving direction of the dividing point is determined according to an included angle between a first line and a second line, where the first line refers to a straight line in which each of the eight azimuths is located, and the second line refers to a line between the current position of the dividing point and the target anchor point; or
When the demarcation point is located in a region with ridge and bifurcation in the pixel gradient map, the moving direction of the demarcation point is determined according to an included angle between a first connecting line and a second connecting line and a distance parameter, wherein the first connecting line is a straight line in which each azimuth in eight azimuths is located, the second connecting line is a connecting line between the current position of the demarcation point and the target anchor point, and the distance parameter is a distance between the current position of the demarcation point and the target anchor point; or
When the boundary point is currently located in a region having ridge and no bifurcation in the pixel gradient map, the moving direction of the boundary point is determined according to the ridge direction of the pixel gradient map.
Optionally, as an embodiment, in a case that the moving direction of the demarcation point at the previous time is the same as the moving direction of the demarcation point at the current time, the moving direction of the demarcation point is determined according to absolute values of gradients of different azimuths.
Optionally, as an embodiment, the anchor point is obtained by optimizing an initial anchor point, where the initial anchor point is an anchor point manually marked in the first image by a user.
Fig. 15 is a schematic block diagram of an image segmentation apparatus provided in an embodiment of the present application. It should be understood that the image segmentation apparatus 900 may perform the image segmentation methods illustrated in fig. 2 to 13. The image segmentation apparatus 900 includes: an acquisition unit 910 and a processing unit 920.
The acquiring unit 910 is configured to acquire a first image and position information of anchors in the first image, where the anchors include a start anchor and a target anchor; the processing unit 920 is configured to obtain a second image according to the first image and the anchor point, where the second image is obtained by image segmentation of the first image, and the second image includes a dividing line between the start anchor point and the target anchor point, where the dividing line is obtained by moving a boundary point in a pixel gradient map of the first image with the start anchor point as a start position and the target anchor point as a target position.
Optionally, as an embodiment, the segmentation line coincides with a segmentation line in a ridge direction in the pixel gradient map.
Optionally, as an embodiment, the processing unit 920 is specifically configured to:
and obtaining the second image according to the pixel gradient map, the anchor point and an anchor point traction model, wherein the anchor point traction model is used for indicating the moving direction of the demarcation point.
Optionally, as an embodiment, if the boundary point is currently located in a region without ridges in the pixel gradient map, the moving direction of the boundary point is determined according to an included angle between a first line and a second line, where the first line is a straight line in which each of the eight azimuths is located, and the second line is a line between the current position of the boundary point and the target anchor point; or,
if the demarcation point is located in a region with ridge and bifurcation in the pixel gradient map, the moving direction of the demarcation point is determined according to an included angle between a first connecting line and a second connecting line and a distance parameter, wherein the first connecting line is a straight line in which each azimuth in the eight azimuths is located, the second connecting line is a connecting line between the current position of the demarcation point and the target anchor point, and the distance parameter is a distance between the current position of the demarcation point and the target anchor point; or,
if the boundary point is currently located in the pixel gradient map with ridge and no bifurcation area, the moving direction of the boundary point is determined according to the ridge direction of the pixel gradient map.
Optionally, as an embodiment, the processing unit is further configured to:
and if the moving direction of the previous moment of the demarcation point is the same as the moving direction of the current moment, determining the moving direction of the demarcation point according to the gradient absolute values of different moving directions.
Optionally, as an embodiment, the anchor point is obtained by optimizing an initial anchor point, where the initial anchor point is an anchor point manually marked in the first image by a user.
The image dividing apparatus 800 and the image dividing apparatus 900 are embodied as functional units. The term "unit" herein may be implemented in software and/or hardware, and is not particularly limited thereto.
For example, a "unit" may be a software program, a hardware circuit, or a combination of both that implement the above-described functions. The hardware circuitry may include an Application Specific Integrated Circuit (ASIC), an electronic circuit, a processor (e.g., a shared processor, a dedicated processor, or a group of processors) and memory that execute one or more software or firmware programs, a combinational logic circuit, and/or other suitable components that support the described functionality.
Accordingly, the units of the respective examples described in the embodiments of the present application can be realized in electronic hardware, or a combination of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
Fig. 16 is a schematic hardware configuration diagram of an image segmentation apparatus according to an embodiment of the present application.
As shown in fig. 16, the image segmentation apparatus 1000 (the image segmentation apparatus 1000 may be specifically a computer device) includes a memory 1001, a processor 1002, a communication interface 1003, and a bus 1004. The memory 1001, the processor 1002, and the communication interface 1003 are communicatively connected to each other via a bus 1004.
The memory 1001 may be a Read Only Memory (ROM), a static memory device, a dynamic memory device, or a Random Access Memory (RAM). The memory 1001 may store a program, and when the program stored in the memory 1001 is executed by the processor 1002, the processor 1002 is configured to perform the steps of the image segmentation method according to the embodiment of the present application, for example, perform the steps illustrated in fig. 2 to 13.
It should be understood that the image segmentation apparatus shown in the embodiment of the present application may be a server, for example, a server in a cloud, or may also be a chip configured in the server in the cloud.
The processor 1002 may be a general-purpose Central Processing Unit (CPU), a microprocessor, an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits, and is configured to execute related programs to implement the image segmentation method according to the embodiment of the present application.
The processor 1002 may also be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the image segmentation method of the present application may be implemented by integrated logic circuits of hardware or instructions in the form of software in the processor 1002.
The processor 1002 may also be a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, or discrete hardware components. The various methods, steps, and logic blocks disclosed in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in the memory 1001, and the processor 1002 reads information in the memory 1001, and completes functions required to be executed by units included in the image segmentation apparatus shown in fig. 14 or fig. 15 in the embodiments of the present application in combination with hardware thereof, or executes the image segmentation method shown in fig. 2 to fig. 13 in the embodiments of the method of the present application.
The communication interface 1003 enables communication between the image segmentation apparatus 1200 and other devices or communication networks using a transceiver device such as, but not limited to, a transceiver.
The bus 1004 may include a path that transfers information between various components (e.g., the memory 1001, the processor 1002, the communication interface 1003) of the image segmentation apparatus 1000.
It should be noted that although the image segmentation apparatus 1000 described above only shows memories, processors, and communication interfaces, in a specific implementation, those skilled in the art will appreciate that the image segmentation apparatus 1000 may also include other devices necessary to achieve normal operation. Meanwhile, it will be understood by those skilled in the art that the image segmentation apparatus 1000 may further include hardware components for implementing other additional functions according to specific needs.
Furthermore, it should be understood by those skilled in the art that the image segmentation apparatus 1000 may also include only the components necessary to implement the embodiments of the present application, and not necessarily all of the components shown in fig. 16.
It is to be understood that the above description is intended to assist those skilled in the art in understanding the embodiments of the present application and is not intended to limit the embodiments of the present application to the particular values or particular scenarios illustrated. It will be apparent to those skilled in the art from the foregoing description that various equivalent modifications or changes may be made, and such modifications or changes are intended to fall within the scope of the embodiments of the present application.
It should be understood that the term "and/or" herein is merely one type of association relationship that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
It should be understood that, in the various embodiments of the present application, the sequence numbers of the above-mentioned processes do not mean the execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional modules in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (29)

1. An image segmentation method is applied to a terminal device with a display screen, and comprises the following steps:
detecting a first operation of manually marking anchor points in a first image by a user, wherein the anchor points comprise a starting anchor point and a target anchor point;
detecting a second operation of automatically segmenting the first image indicated by the user;
displaying a second image on the display screen in response to the second operation,
the second image is obtained after the first image is subjected to the second operation, the second image comprises a division line between the starting anchor point and the target anchor point, and the division line is obtained by moving a demarcation point in the first image by taking the starting anchor point as a starting position and taking the target anchor point as a target position.
2. The image segmentation method according to claim 1, wherein the segmentation line coincides with a segmentation line in a ridge direction in a pixel gradient map of the first image.
3. The image segmentation method according to claim 1 or 2, wherein the displaying the second image on the display screen in response to the second operation comprises:
searching a mask image and a secant image corresponding to the first image according to the first image, wherein the mask image is used for representing different objects in the first image, and the secant image is used for representing the boundaries of the different objects in the first image;
and displaying the first image, the mask image and the superposed image of the secant image on the display screen.
4. The image segmentation method of claim 3, further comprising:
detecting a third operation of the user indicating to process the second image through the mask image or the secant image.
5. The image segmentation method according to any one of claims 1 to 4, wherein the second image is obtained from a pixel gradient map of the first image and an anchor pull model indicating a direction of movement of the demarcation point.
6. The image segmentation method according to claim 5, wherein when the demarcation point is currently located in a region without ridge in the pixel gradient map, the movement direction of the demarcation point is determined according to an included angle between a first straight line and a second straight line, wherein the first straight line is a straight line in which each of the eight orientations is located, and the second straight line is a connecting line between the current position of the demarcation point and the target anchor point; or
When the demarcation point is located in a region with ridge and bifurcation in the pixel gradient map, the moving direction of the demarcation point is determined according to an included angle between a first connecting line and a second connecting line and a distance parameter, wherein the first straight line refers to a straight line in which each azimuth in eight azimuths is located, the second straight line refers to a connecting line between the current position of the demarcation point and the target anchor point, and the distance parameter refers to a distance between the current position of the demarcation point and the target anchor point; or
When the boundary point is currently located in a region having ridge and no bifurcation in the pixel gradient map, the moving direction of the boundary point is determined according to the ridge direction of the pixel gradient map.
7. The image segmentation method according to claim 6, wherein the moving direction of the boundary point is determined according to an absolute value of a gradient in a different azimuth in a case where the moving direction of the boundary point at the previous time is the same as the moving direction of the boundary point at the current time.
8. The image segmentation method of any one of claims 1 to 7 wherein the anchor point is obtained by optimizing an initial anchor point, wherein the initial anchor point is an anchor point manually marked by a user in the first image.
9. An image segmentation method, comprising:
acquiring a first image and position information of an anchor point in the first image, wherein the anchor point comprises an initial anchor point and a target anchor point;
and obtaining a second image according to the first image and the anchor point, wherein the second image is obtained after the first image is subjected to image segmentation processing, the second image comprises a division line between the starting anchor point and the target anchor point, and the division line is obtained by moving a boundary point in a pixel gradient map of the first image by taking the starting anchor point as a starting position and taking the target anchor point as a target position.
10. The image segmentation method according to claim 9, wherein the segmentation line coincides with a segmentation line in a ridge direction in the pixel gradient map.
11. The image segmentation method according to claim 9 or 10, wherein the obtaining a second image according to the first image and the anchor point comprises:
and obtaining the second image according to the pixel gradient map, the anchor point and an anchor point traction model, wherein the anchor point traction model is used for indicating the moving direction of the demarcation point.
12. The image segmentation method according to claim 11, wherein if the boundary point is currently located in a region without ridge in the pixel gradient map, the moving direction of the boundary point is determined according to an included angle between a first line and a second line, wherein the first line is a straight line in which each of the eight orientations is located, and the second line is a straight line between the current position of the boundary point and the target anchor point; or,
if the boundary point is located in a region with ridge and bifurcation in the pixel gradient map, the moving direction of the boundary point is determined according to an included angle between a first connecting line and a second connecting line and a distance parameter, wherein the first straight line refers to a straight line in which each of eight azimuths is located, the second straight line refers to a connecting line between the current position of the boundary point and the target anchor point, and the distance parameter refers to a distance between the current position of the boundary point and the target anchor point; or,
if the boundary point is currently located in the pixel gradient map with ridge and no bifurcation area, the moving direction of the boundary point is determined according to the ridge direction of the pixel gradient map.
13. The image segmentation method of claim 12, further comprising:
and if the moving direction of the previous moment of the demarcation point is the same as the moving direction of the current moment, determining the moving direction of the demarcation point according to the gradient absolute values of different moving directions.
14. The image segmentation method of any one of claims 9 to 13 wherein the anchor point is obtained by optimizing an initial anchor point, wherein the initial anchor point is an anchor point manually marked by a user in the first image.
15. An image segmentation apparatus, characterized in that the image segmentation apparatus has a display screen, comprising:
the detection unit is used for detecting a first operation of manually marking anchor points in a first image by a user, wherein the anchor points comprise an initial anchor point and a target anchor point; detecting a second operation of automatically segmenting the first image indicated by the user;
a processing unit for displaying a second image on the display screen in response to the second operation,
the second image is obtained after the first image is subjected to the second operation, the second image comprises a division line between the starting anchor point and the target anchor point, and the division line is obtained by moving a demarcation point in the first image by taking the starting anchor point as a starting position and taking the target anchor point as a target position.
16. The image segmentation apparatus according to claim 15, wherein the segmentation line coincides with a segmentation line in a ridge direction in a pixel gradient map of the first image.
17. The image segmentation apparatus according to claim 15 or 16, wherein the processing unit is specifically configured to:
searching a mask image and a secant image corresponding to the first image according to the first image, wherein the mask image is used for representing different objects in the first image, and the secant image is used for representing the boundaries of the different objects in the first image;
and displaying the first image, the mask image and the superposed image of the secant image on the display screen.
18. The image segmentation apparatus as set forth in claim 17, wherein the detection unit is further configured to:
detecting a third operation of the user indicating to process the second image through the mask image or the secant image.
19. The image segmentation apparatus according to any one of claims 15 to 18, wherein the second image is obtained from a pixel gradient map of the first image and an anchor point tractional model for indicating a moving direction of the demarcation point.
20. The image segmentation apparatus according to claim 19, wherein when the boundary point is currently located in a region without ridge in the pixel gradient map, the moving direction of the boundary point is determined according to an included angle between a first line and a second line, wherein the first line is a straight line in which each of the eight orientations is located, and the second line is a straight line between the current position of the boundary point and the target anchor point; or
When the demarcation point is located in a region with ridge and bifurcation in the pixel gradient map, the moving direction of the demarcation point is determined according to an included angle between a first connecting line and a second connecting line and a distance parameter, wherein the first straight line refers to a straight line in which each azimuth in eight azimuths is located, the second straight line refers to a connecting line between the current position of the demarcation point and the target anchor point, and the distance parameter refers to a distance between the current position of the demarcation point and the target anchor point; or
When the boundary point is currently located in a region having ridge and no bifurcation in the pixel gradient map, the moving direction of the boundary point is determined according to the ridge direction of the pixel gradient map.
21. The image segmentation apparatus according to claim 20, wherein the moving direction of the boundary point is determined according to an absolute value of a gradient in a different azimuth when the moving direction of the boundary point at the previous time is the same as the moving direction of the boundary point at the current time.
22. The image segmentation apparatus according to any one of claims 15 to 21 wherein the anchor point is obtained by optimizing an initial anchor point, wherein the initial anchor point is an anchor point manually marked by a user in the first image.
23. An image segmentation apparatus, comprising:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a first image and position information of an anchor point in the first image, and the anchor point comprises an initial anchor point and a target anchor point;
and the processing unit is used for obtaining a second image according to the first image and the anchor point, wherein the second image is obtained by image segmentation processing of the first image, the second image comprises a dividing line between the starting anchor point and the target anchor point, and the dividing line is obtained by moving a dividing point in a pixel gradient map of the first image by taking the starting anchor point as a starting position and taking the target anchor point as a target position.
24. The image segmentation apparatus as set forth in claim 23, wherein the segmentation line coincides with a segmentation line in a ridge direction in the pixel gradient map.
25. The image segmentation apparatus according to claim 23 or 24, wherein the processing unit is specifically configured to:
and obtaining the second image according to the pixel gradient map, the anchor point and an anchor point traction model, wherein the anchor point traction model is used for indicating the moving direction of the demarcation point.
26. The image segmentation apparatus according to claim 25, wherein if the boundary point is currently located in a region without ridge in the pixel gradient map, the moving direction of the boundary point is determined according to an included angle between a first connection line and a second connection line, wherein the first connection line is a connection line between the start anchor point and the target anchor point, and the second connection line is a connection line between the current location of the boundary point and the target anchor point; or,
if the boundary point is located in a region with ridge and bifurcation in the pixel gradient map, the moving direction of the boundary point is determined according to an included angle between a first connecting line and a second connecting line and a distance parameter, wherein the first straight line refers to a straight line in which each of eight azimuths is located, the second straight line refers to a connecting line between the current position of the boundary point and the target anchor point, and the distance parameter refers to a distance between the current position of the boundary point and the target anchor point; or,
if the boundary point is currently located in the pixel gradient map with ridge and no bifurcation area, the moving direction of the boundary point is determined according to the ridge direction of the pixel gradient map.
27. The image segmentation apparatus of claim 26, wherein the processing unit is further to:
and if the moving direction of the previous moment of the demarcation point is the same as the moving direction of the current moment, determining the moving direction of the demarcation point according to the gradient absolute values of different moving directions.
28. The image segmentation apparatus of any one of claims 23 to 27 wherein the anchor point is obtained by optimizing an initial anchor point, wherein the initial anchor point is an anchor point manually marked by a user in the first image.
29. A computer-readable storage medium, characterized in that the computer-readable medium stores a program code for device execution, the program code comprising instructions for performing the image segmentation method according to any one of claims 1 to 8 or 9 to 14.
CN201911411574.7A 2019-12-31 2019-12-31 Image segmentation method and image segmentation device Pending CN113129307A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201911411574.7A CN113129307A (en) 2019-12-31 2019-12-31 Image segmentation method and image segmentation device
PCT/CN2020/140570 WO2021136224A1 (en) 2019-12-31 2020-12-29 Image segmentation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911411574.7A CN113129307A (en) 2019-12-31 2019-12-31 Image segmentation method and image segmentation device

Publications (1)

Publication Number Publication Date
CN113129307A true CN113129307A (en) 2021-07-16

Family

ID=76686519

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911411574.7A Pending CN113129307A (en) 2019-12-31 2019-12-31 Image segmentation method and image segmentation device

Country Status (2)

Country Link
CN (1) CN113129307A (en)
WO (1) WO2021136224A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114140488A (en) * 2021-11-30 2022-03-04 北京达佳互联信息技术有限公司 Video target segmentation method and device and training method of video target segmentation model
CN114511566B (en) * 2022-04-19 2022-07-19 武汉大学 Method and related device for detecting basement membrane positioning line in medical image
CN117655563B (en) * 2024-01-31 2024-05-28 成都沃特塞恩电子技术有限公司 Laser cutting path planning method and device, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040008886A1 (en) * 2002-07-02 2004-01-15 Yuri Boykov Using graph cuts for editing photographs
CN101329763A (en) * 2007-06-22 2008-12-24 西门子公司 Method for segmenting structures in image data records and image processing unit
CN101859224A (en) * 2010-04-30 2010-10-13 陈铸 Method and system for scratching target object from digital picture

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040008886A1 (en) * 2002-07-02 2004-01-15 Yuri Boykov Using graph cuts for editing photographs
CN101329763A (en) * 2007-06-22 2008-12-24 西门子公司 Method for segmenting structures in image data records and image processing unit
CN101859224A (en) * 2010-04-30 2010-10-13 陈铸 Method and system for scratching target object from digital picture

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
WILLIAM A. BARRETT 等: "Interactive Live-Wire Boundary Extraction", 《MEDICAL IMAGE ANALYSIS》, vol. 1, no. 4, pages 2 *

Also Published As

Publication number Publication date
WO2021136224A1 (en) 2021-07-08

Similar Documents

Publication Publication Date Title
CN112017189B (en) Image segmentation method and device, computer equipment and storage medium
US11238606B2 (en) Method and system for performing simultaneous localization and mapping using convolutional image transformation
Carvalho et al. Deep depth from defocus: how can defocus blur improve 3D estimation using dense neural networks?
KR102480245B1 (en) Automated generation of panning shots
Jian et al. The extended marine underwater environment database and baseline evaluations
CN113674416B (en) Three-dimensional map construction method and device, electronic equipment and storage medium
CN113129307A (en) Image segmentation method and image segmentation device
CN110689562A (en) Trajectory loop detection optimization method based on generation of countermeasure network
US11367195B2 (en) Image segmentation method, image segmentation apparatus, image segmentation device
CN110910437B (en) Depth prediction method for complex indoor scene
CN109858547A (en) A kind of object detection method and device based on BSSD
CN112528974B (en) Distance measuring method and device, electronic equipment and readable storage medium
CN112927279A (en) Image depth information generation method, device and storage medium
CN107948586B (en) Trans-regional moving target detecting method and device based on video-splicing
CN111383204A (en) Video image fusion method, fusion device, panoramic monitoring system and storage medium
CN110544268A (en) Multi-target tracking method based on structured light and SiamMask network
CN114022531A (en) Image processing method, electronic device, and storage medium
CN115210773A (en) Method for detecting object in real time by using object real-time detection model and optimization method
CN110120012B (en) Video stitching method for synchronous key frame extraction based on binocular camera
CN110717593A (en) Method and device for neural network training, mobile information measurement and key frame detection
CN114241194A (en) Instrument identification and reading method based on lightweight network
CN110390724A (en) A kind of SLAM method with example segmentation
CN113096016A (en) Low-altitude aerial image splicing method and system
Shao A Monocular SLAM System Based on the ORB Features
CN116883897A (en) Low-resolution target identification method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination