Image processing (iii) image segmentation (1) Random walks Segmentation _ Image Processing

Source: Internet
Author: User
An image segmentation algorithm based on random walk

The algorithm of image segmentation based on random walk is one of the methods of graph theory segmentation, this algorithm is relatively biased, online paper relatively few, just started to learn to find a data is not easy, in fact, the principle of this algorithm is to solve an adjacency matrix equations, with three-dimensional space triangular mesh surface harmonic field solution is a bit similar.

1, before the beginning of the algorithm, a brief description of the random walk model

One-dimensional random walk problem: Set a particle (random walk) to move along a straight line, a unit of time can only move one unit length, and can only stay in the line of the integer points, assuming at the moment T, the particle is located in the line of point I, then in the moment T +1, the position of the particle is three possible: ① P The probability jumps to the integer point I-1,② or jumps to the probability of the Q I+1,③ or to the probability of r=1-p-q to stay in the dot I, since the results of each step are independent, and the probability of each occurrence is 1, the process obeys the Bernoulli distribution, called the Bernoulli random walk process. When p=q=0.5, the probability that a particle reaches its adjacent point at the next moment is equal, which is called a simple random walk.

Example 1: As shown in the following figure, suppose a point in the position of a particle in the scale 2, the probability of the particle moving around is 0.5, then the next moment the particle may go to the left, it is possible to go to the right, when the particle movement to position 0, 5 position, the particle stops moving, the particle to the final movement to the position of 5 probability. The problem is random walk.

For one dimensional simple random walk problem, satisfy:


,

where x is the current position point, x-1, and X+1 are the left and right neighboring vertices of position x. According to the formula, we can list n equations composed of n unknowns, and we can find that the coefficients matrix of the equation group is the Laplace adjacency matrix. The Laplace matrix is not full rank matrix, it needs to add the boundary constraint condition, the equation group only has the unique solution.

For example 1, set the add boundary constraint:


Finally, we can list the following equations to find out the probability of each point to position 5.


2. Image segmentation algorithm based on random walk

① reference: "Random walks for Image segmentation"

② Literature Overview: Random walk algorithm is a segmentation algorithm based on graph theory, which belongs to an interactive image segmentation. Its segmentation idea is that the pixel of the image is the vertex of the graph, the neighborhood domain or eight neighborhood relationship between adjacent pixels is the edge of the graph, and the weights of each edge in the graph are defined according to the similarity between the pixel attributes and the characteristics of the neighboring pixels to construct the network diagram, and then manually specify the foreground and background markers by the user. That is, the seed pixels of the foreground object and the background object, with the weight of the edge as the transfer probability, the unlabeled pixel node as the initial point, the probability of the first arrival of each unlabeled node to the various sub-pixel pixels, according to the probability size, divide the unmarked node and get the final segmentation result.

Example 2: As shown in the figure below, the small circle in the figure represents each pixel point on the image. L1,l2,l3 Three seed points are entered interactively by the user as the seed point of the marker. Now we want to divide the image into the corresponding three parts.

③ Algorithm Flow:

A. The weights of any point in the calculation diagram of the connection between VI and its adjacent vertices:


Among them, the gray value of the pixel, or the texture information and other parameters;

B. For the probability of any point VI in the graph, it satisfies the random walk probability formula:


Among them, ni is the adjacency vertex of VI Point (can be neighborhood vertex or eight adjacent vertex), according to the formula, can construct the Laplace matrix of the graph, but Laplace is not full rank matrix, need to add boundary constraint condition, can solve the probability of each unknown point according to the equation group. The problem of image segmentation is transformed into Dirichlet problem.

C. Add boundary constraints: The probability of the unknown point to each class is solved by using the labeled K-class vertex as the boundary constraint condition. As shown in the following figure: to solve the probability of each unknown point wandering to L1, the probability of an unknown point can be obtained as a constraint condition, as shown in the following figure:

Probability of reaching L1

Probability of reaching L2

Probability of reaching L3

(5) Each unmarked point, according to the value of the membership of the K-class mark, if the number of unmarked points to the K-class probability is the largest, then the unmarked node vi discriminant to belong to category K, complete segmentation.

Finally, post some important function code that you wrote:

[cpp]  View Plain  copy//According to adjacency, construct Laplace matrix    Void crandomwalk::computecoff ()    {        int height=m_image->Height;       int  width=m_image->Width;       m_a.resize (height*width,width*height);        int vn=height*width;       typedef eigen: :triplet<double> tri;       std::vector<Tri> tripletList;        for  (int i=0;i

This article addresses:http://blog.csdn.net/hjimce/article/details/45201263     Author: hjimce     Contact qq:1393852684
More resources please watch my blog:http://blog.csdn.net/hjimce                   Original articles, all rights reserved, reproduced please indicate the source. References: 1, Random walks for image segmentation 2, "Random Walk Image segmentation algorithm" The effect of this algorithm is not very good, so the effect is not pasted, specific can look at the original document

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.