CN110363779B - Digital image segmentation and parallelization method - Google Patents

Digital image segmentation and parallelization method Download PDF

Info

Publication number
CN110363779B
CN110363779B CN201910649115.6A CN201910649115A CN110363779B CN 110363779 B CN110363779 B CN 110363779B CN 201910649115 A CN201910649115 A CN 201910649115A CN 110363779 B CN110363779 B CN 110363779B
Authority
CN
China
Prior art keywords
node
memory
image segmentation
calculating
reading
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.)
Active
Application number
CN201910649115.6A
Other languages
Chinese (zh)
Other versions
CN110363779A (en
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.)
Northeastern University China
Original Assignee
Northeastern University China
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 Northeastern University China filed Critical Northeastern University China
Priority to CN201910649115.6A priority Critical patent/CN110363779B/en
Publication of CN110363779A publication Critical patent/CN110363779A/en
Application granted granted Critical
Publication of CN110363779B publication Critical patent/CN110363779B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/194Segmentation; Edge detection involving foreground-background segmentation

Abstract

The invention provides a digital image segmentation and parallelization method, which comprises the following steps: reading image data; calculating an energy matrix; invoking PushKernel () kernel; calling a PullKernel () function, repeatedly calling the PullKernel () function m times, calling a RelabelKernel () kernel function, and reading a node height value; and judging whether the node height can be re-marked or not according to the iteration layer number k, if so, updating the height value, and updating the node state to an Active state. The technical scheme of the invention starts the constant memory according to the characteristics of the GPU, thereby achieving the effect of improving the whole bandwidth. And the task allocation is carried out by utilizing the characteristics of the memory so as to achieve the complete matching of the size of the memory and the number of parallel threads and improve the efficiency. For the second step of image segmentation, the original pressing operation is divided into two steps, namely Push and Pull operations, so that the subsequent operation is facilitated; and a new re-marking process is introduced, the heights of all nodes are globally re-marked in a breadth-first traversal mode, the integral iteration times of the algorithm are reduced, and the operation efficiency of the algorithm is obviously improved.

Description

Digital image segmentation and parallelization method
Technical Field
The invention relates to the technical field of digital image processing, in particular to a digital image segmentation and parallelization method.
Background
Image segmentation is the process of segmenting an image into several specific regions of different significance and extracting the object of interest. In practical applications, a general user only has interest in certain specific areas of the image, such as extracting the license plate number of a vehicle to realize vehicle positioning and real-time monitoring. In order to achieve the above purpose, it is necessary to acquire a region of interest by image segmentation, and then perform subsequent identification, analysis, and understanding. With the development of society, the quality of images acquired by image acquisition equipment is greatly improved, the requirements and expectations of people for image processing are correspondingly increased, and particularly, higher requirements on the processing speed are met.
For many years, image segmentation has been the focus and key content of the image processing field, and hundreds of image segmentation algorithms have been proposed successively. However, after years of research work, a general image segmentation theory cannot be obtained, and the proposed segmentation algorithm is usually directed at a certain specific problem, and is not suitable for various images.
Disclosure of Invention
In light of the above-mentioned technical problems, a method for segmenting and parallelizing digital images is provided. On the basis of an image segmentation algorithm based on graph theory, aiming at the defect of low running speed of the existing algorithm, the invention improves two steps of the algorithm, designs and realizes the algorithm flow by utilizing the parallelization idea, and achieves the purpose of improving the running efficiency of the algorithm.
The technical means adopted by the invention are as follows:
a digital image segmentation and parallelization method comprises the following steps:
step S1: reading image data;
step S2: calculating an energy matrix;
and step S3: storing the weight peak of the edge in a global memory, storing node state information in a constant memory, and storing height information of the node in a texture memory;
and step S4: reading the weight information of the edge and the excess flow of the node into a shared memory from a global memory, calling PushKernel () kernel function, and reading the height information of the current node and the surrounding neighbor nodes from a texture memory; acquiring node state information of a current node and an adjacent half thread bundle from a constant memory; judging whether the current node can press in excess flow like a neighbor from the obtained height information and node state information, and if so, keeping the pressed in excess flow in a global memory;
step S5: calling a PullKernel () function, reading the data kept in the global memory in the step S4, judging whether the current node is associated with the data, namely judging whether the excess flow of the current node needs to be updated, and if so, modifying the excess flow of the node;
step S6: and after repeating the step S5 for m times, calling a RelabeKernel () kernel function, reading the height values of the current node and the neighbor nodes of the current node from the texture memory by the RelabeKernel, judging whether the height of the current node can be re-marked or not according to the current iteration layer number k, if yes, updating the height value in the texture memory, and updating the node state to an Active state.
Further, the specific process of calculating the energy matrix in step S2 is as follows:
step S21: copying the image data read in the step S1 from the CPU mode to the GPU;
step S22: according to the characteristics of the GPU, simultaneously carrying out the same operation on all pixels, calculating boundary terms of all the pixels, initializing the edge formed by q and p of adjacent pixels, and calculating B according to a formula {p·q}
Step S23: calculating the region term if the pixel point p i For foreground, then initialize the edge (s, p) i ) Setting the weight value as a maximum value K; if pixel point p i For background, then initialize edge (p) i T), and setting the weight value as a maximum value K; other pixel points are compared with R' p (0) And R' p (1) Taking the larger of the two, calculating the corresponding lambda R' p (1);
Step S24: and copying the data from the GPU back to the CPU to obtain the energy matrix.
Further, the area term calculated in step S23 has the following formula:
Figure BDA0002134579670000021
in the above formula, mu is a new coefficient provided to neutralize the probability P that the pixel point P belongs to the foreground obj Probability P of belonging to the background bkg ,l p Segmenting a pixel point p<xnotran> , L = { l </xnotran> 1 ,l 2 ,...l p L '(L) is a modified regional calculation, R' p (l p ) Assigning labels l to pixels p p The penalty of (1), namely the area energy, P is a pixel point set, T is a background pixel set, and S is a foreground pixel set.
Further, the relationship table of the weight values is as follows:
Figure BDA0002134579670000031
wherein the foreground seed point is
Figure BDA0002134579670000032
And background seed points of
Figure BDA0002134579670000033
Manual injection is performed during interaction.
Compared with the prior art, the invention has the following advantages:
1. the digital image segmentation and parallelization method provided by the invention achieves the purpose of improving the operation efficiency of the algorithm by improving two steps of the image segmentation algorithm of the graph theory and designing the algorithm by utilizing the parallelization idea.
2. The digital image segmentation and parallelization method provided by the invention starts the constant memory according to the characteristics of the GPU, and achieves the effect of improving the whole bandwidth. And the task allocation is carried out by utilizing the characteristics of the memory so as to achieve the complete matching of the size of the memory and the number of parallel threads and improve the efficiency.
3. According to the digital image segmentation and parallelization method provided by the invention, for the second step of image segmentation, the original pressing-in operation is divided into two steps, namely Push and Pull operations, so that the subsequent operation is facilitated;
4. according to the digital image segmentation and parallelization method, a new re-labeling process is introduced, the heights of all nodes are globally re-labeled in a breadth-first traversal mode, the integral iteration times of the algorithm are reduced, and the operation efficiency of the algorithm is obviously improved.
Based on the reasons, the invention can be widely popularized in the fields of digital image processing and the like.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a flow chart of the method of the present invention.
Fig. 2 is a diagram illustrating the operation of Push and Pull according to an embodiment of the present invention.
Detailed Description
In order to make those skilled in the art better understand the technical solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Examples
As shown in FIG. 1, the present invention provides a digital image segmentation and parallelization method, comprising:
step S1: reading image data;
step S2: calculating an energy matrix;
the specific process of calculating the energy matrix in step S2 is as follows:
step S21: copying the image data read in the step S1 from the CPU mode to the GPU;
step S22: according to the characteristics of the GPU, simultaneously carrying out the same operation on all the pixels, and calculating the boundary items of all the pixels
Figure BDA0002134579670000051
Wherein
Figure BDA0002134579670000052
Initializing the edge formed by adjacent pixel points q and p, and calculating B according to a formula {p·q} (ii) a The weight used to determine the n-link edge between adjacent nodes:
Figure BDA0002134579670000053
step S23: calculating the region item, if the pixel point p i For foreground, then initialize the edge (s, p) i ) Setting the weight value as a maximum value K; if the pixel point p i For background, then initialize edge (p) i T), and setting the weight value as a maximum value K; comparing R 'for other pixel points' p (0) And R' p (1) Taking the larger of the two, calculating the corresponding lambda R' p (1);
Specifically, the formula of the area term calculated in step S23 is as follows:
Figure BDA0002134579670000054
in the above formula, mu is a new coefficient provided to neutralize the probability P that the pixel point P belongs to the foreground obj Probability P of belonging to the background bkg ,l p <xnotran> p , L = { l </xnotran> 1 ,l 2 ,...l p L '(L) is a modified regional calculation, R' p (l p ) Assigning labels l to pixels p p The penalty of (1), i.e. the area energy, P is the set of pixels, T is the background set of pixels, and S is the foreground set of pixels.
The relationship of the weights is as follows:
Figure BDA0002134579670000055
wherein the foreground seed point is
Figure BDA0002134579670000056
And background seed points of
Figure BDA0002134579670000057
Manual injection is performed during interaction.
Step S24: and copying the data from the GPU back to the CPU to obtain the energy matrix.
And step S3: storing the weight vertex of the edge in a global memory, storing node state information in a constant memory, and storing height information of the node in a texture memory;
in order to perform the push operation in parallel, the whole push operation is divided into two processes, which are respectively embodied as PushKernel () and PullKernel (), wherein PullKernel () stores the excess flow in a global array. Specifically, the method comprises the following steps:
and step S4: reading the weight information of the edge and the excess flow of the node into a shared memory from a global memory, calling PushKernel () kernel function, and reading the height information of the current node and the surrounding neighbor nodes from a texture memory; acquiring node state information of a current node and an adjacent half thread bundle from a constant memory; judging whether the current node can press in excess flow like a neighbor from the obtained height information and node state information, and if so, keeping the pressed in excess flow in a global memory;
in the embodiment, a PushKernel () kernel function is called, height information and excess flow information of each node u in the graph are read into a shared memory from a global memory, synchronization is carried out to ensure that all threads are loaded completely, whether the height of each neighbor of u meets a pressing-in condition is judged, if yes, the excess flow is recorded and stored in a global memory F for use in the next stage;
step S5: the purpose of the Pull operation is to modify the information of the node. Calling a PullKernel () function, reading the data held in the global memory in the step S4, judging whether the current node is associated with the data, namely judging whether the excess flow of the current node needs to be updated, and if so, modifying the excess flow of the node;
in this embodiment, a PullKernel () function is called, for each node u in the graph, the excess flow which is pushed by its neighbor to it is read from the global memory F, and then a new excess flow e (u) of the node u is obtained by accumulating the values; as shown in FIG. 2, which is a graphical illustration of the operation of Push, which causes each node to send an excess flow to its surrounding nodes, and Pull, which causes each node to obtain an excess flow from its surrounding nodes. The parallel re-marking operation is to re-correct the heights of all nodes from the global perspective and set the height of the sink to 0 by the idea of breadth-first traversal. And in each iteration, the height of the node is equal to the minimum value of the heights of all the neighbors of the current node plus one, and finally the whole iteration process is completed.
Step S6: and repeating the step S5 m times, calling a RelabeLKernel () kernel function, reading the height values of the current node and the neighbor nodes thereof from the texture memory by the RelabeLKernel, judging whether the height of the current node can be re-marked or not according to the number k of the current iteration layers, if so, updating the height value in the texture memory, and updating the node state to an Active state.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (4)

1. A digital image segmentation and parallelization method, comprising:
step S1: reading image data;
step S2: calculating an energy matrix;
and step S3: storing the weight vertex of the edge in a global memory, storing node state information in a constant memory, and storing height information of the node in a texture memory;
and step S4: reading the weight information of the edge and the excess flow of the node into a shared memory from a global memory, calling PushKernel () kernel function, and reading the height information of the current node and the surrounding neighbor nodes from a texture memory; acquiring node state information of a current node and an adjacent half thread bundle from a constant memory; judging whether the current node can press in excess flow like a neighbor from the acquired height information and node state information, and if so, keeping the pressed in excess flow in a global memory;
step S5: calling a PullKernel () function, reading the data held in the global memory in the step S4, judging whether the current node is associated with the data, namely judging whether the excess flow of the current node needs to be updated, and if so, modifying the excess flow of the node;
step S6: and repeating the step S5 m times, calling a RelabeLKernel () kernel function, reading the height values of the current node and the neighbor nodes thereof from the texture memory by the RelabeLKernel, judging whether the height of the current node can be re-marked or not according to the number k of the current iteration layers, if so, updating the height value in the texture memory, and updating the node state to an Active state.
2. The digital image segmentation and parallelization method according to claim 1, wherein the specific process of calculating the energy matrix in step S2 is as follows:
step S21: copying the image data read in the step S1 from the CPU mode to the GPU;
step S22: according to the characteristics of the GPU, simultaneously carrying out the same operation on all pixels, calculating boundary terms of all pixel points, initializing the edge formed by adjacent pixel points q and p, and calculating B according to a formula {p·q}
Step S23: calculating the region item, if the pixel point p i For foreground, then initialize the edge (s, p) i ) Setting the weight value as a maximum value K; if pixel point p i For background, then initialize edge (p) i T), and setting the weight value as a maximum value K; other pixel points are compared with R' p (0) And R' p (1) Taking the larger of the two, calculating the corresponding lambda R' p (1);
Step S24: and copying the data from the GPU back to the CPU to obtain the energy matrix.
3. The digital image segmentation and parallelization method according to claim 1 or 2, wherein the region term calculated in step S23 is expressed by the following formula:
Figure FDA0002134579660000021
in the above formula, mu is a new coefficient provided to neutralize the probability P that the pixel point P belongs to the foreground obj Probability P of belonging to the background bkg ,l p For the label after the pixel point p is segmented, the final result of the image segmentation can be represented as L = { L = { (L) } 1 ,l 2 ,...l p L '(L) is a modified regional calculation, R' p (l p ) Assigning labels l to pixels p p The penalty of (1), i.e. the area energy, P is the set of pixels, T is the background set of pixels, and S is the foreground set of pixels.
4. The digital image segmentation and parallelization method according to claim 1 or 2, wherein the relationship table of the weights is as follows:
Figure FDA0002134579660000022
wherein the foreground seed point is
Figure FDA0002134579660000023
And background seed points of
Figure FDA0002134579660000024
Manual injection is performed during interaction.
CN201910649115.6A 2019-07-18 2019-07-18 Digital image segmentation and parallelization method Active CN110363779B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910649115.6A CN110363779B (en) 2019-07-18 2019-07-18 Digital image segmentation and parallelization method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910649115.6A CN110363779B (en) 2019-07-18 2019-07-18 Digital image segmentation and parallelization method

Publications (2)

Publication Number Publication Date
CN110363779A CN110363779A (en) 2019-10-22
CN110363779B true CN110363779B (en) 2022-11-25

Family

ID=68221223

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910649115.6A Active CN110363779B (en) 2019-07-18 2019-07-18 Digital image segmentation and parallelization method

Country Status (1)

Country Link
CN (1) CN110363779B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013189101A1 (en) * 2012-06-20 2013-12-27 浙江大学 Hair modeling and portrait editing method based on single image
CN104463843A (en) * 2014-10-31 2015-03-25 南京邮电大学 Interactive image segmentation method of android system
CN105701832A (en) * 2016-01-19 2016-06-22 苏州大学 PET-CT lung tumor segmentation method combining three dimensional graph cut algorithm with random walk algorithm
WO2016101279A1 (en) * 2014-12-26 2016-06-30 中国海洋大学 Quick detecting method for synthetic aperture radar image of ship target

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013189101A1 (en) * 2012-06-20 2013-12-27 浙江大学 Hair modeling and portrait editing method based on single image
CN104463843A (en) * 2014-10-31 2015-03-25 南京邮电大学 Interactive image segmentation method of android system
WO2016101279A1 (en) * 2014-12-26 2016-06-30 中国海洋大学 Quick detecting method for synthetic aperture radar image of ship target
CN105701832A (en) * 2016-01-19 2016-06-22 苏州大学 PET-CT lung tumor segmentation method combining three dimensional graph cut algorithm with random walk algorithm

Also Published As

Publication number Publication date
CN110363779A (en) 2019-10-22

Similar Documents

Publication Publication Date Title
JP3740065B2 (en) Object extraction device and method based on region feature value matching of region-divided video
Carreira-Perpinan Acceleration strategies for Gaussian mean-shift image segmentation
CN112163634A (en) Example segmentation model sample screening method and device, computer equipment and medium
CN110866896B (en) Image saliency target detection method based on k-means and level set super-pixel segmentation
Khotanzad et al. Image segmentation by a parallel, non-parametric histogram based clustering algorithm
CN108629783B (en) Image segmentation method, system and medium based on image feature density peak search
JP5117670B2 (en) Image and method for representing image group, method for comparing image or image group, method for retrieving image or image group, apparatus and system for executing each method, program, and computer-readable storage medium
WO2011001398A2 (en) Method circuit and system for matching an object or person present within two or more images
JP6100300B2 (en) Method and system for image matting and foreground estimation based on hierarchical graph
CN108491856B (en) Image scene classification method based on multi-scale feature convolutional neural network
JP4098021B2 (en) Scene identification method, apparatus, and program
CN113128478B (en) Model training method, pedestrian analysis method, device, equipment and storage medium
US20220392019A1 (en) Method for denoising videos and electronic device therefor
Xia et al. Knowledge distillation based degradation estimation for blind super-resolution
CN111274964B (en) Detection method for analyzing water surface pollutants based on visual saliency of unmanned aerial vehicle
Kuzovkin et al. Descriptor-based image colorization and regularization
CN110751191A (en) Image classification method and system
Mseddi et al. Real-time scene background initialization based on spatio-temporal neighborhood exploration
CN110363779B (en) Digital image segmentation and parallelization method
JP2008084076A (en) Image processor, method, and program
CN109784379B (en) Updating method and device of textile picture feature library
US8478032B2 (en) Segmenting an image
Liu et al. Segmentation by weighted aggregation and perceptual hash for pedestrian detection
CN109299295B (en) Blue printing layout database searching method
CN102298699A (en) Methods of representing and analysing images

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
GR01 Patent grant
GR01 Patent grant