MATLAB implementation of Random Walk

Source: Internet
Author: User

<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:14PX;" >% random Walk produces image effect, random walk similar to Brownian motion, is random to go in all directions </span>
<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:14PX;" ><span style= "Color:rgb (68, 68, 68); line-height:21px; " >random Walker algorithm is not to really carry out the "walk" of this process, but to directly calculate "from any point, first reached which initial point of higher probability." In this case, the results are basically deterministic. It's like asking "a man with a 10kg weight on his foot, a race with a man without heavy weights, who wins the odds"? It is true that the former is not likely to win, but if you compare probabilities, the results are obvious. </span></span>
<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:14PX;" ><span style= "Color:rgb (68, 68, 68); line-height:21px; " > Random Walk is a semi-automatic segmentation algorithm based on graph theory </span></span>
Random walk algorithm has a lot of applications, such as: Based on random walk image segmentation, based on random walk video denoising Clear all;clc;n=100000;% walk step number, is also the number of pixels in the image, all directly related to the size of the image, some locations may be repeated, so white pixels less than or equal to n       the initial position of the x=0;y=0;% Walk           Pixel=zeros (n,2); the pixel coordinates produced by the% Walk neighbour=[-1-1;-1 0;-1 1;0-1;0 1;1-1;1 0;1 1];% Walk Eight directions for i=1:n    R=floor (1+8*rand ());% eight neighborhood randomly choose one to go        y=y+neighbour (r,1);%y Direction Walk         x=x+ Neighbour (r,2),%x direction Walk, swim the continuous    pixel (i,:) =[y x];         Endminy=min (Pixel (:, 1));         Minx=min (Pixel (:, 2));% image coordinates can not be negative, so find the minimum value and then the overall promotion to positive    pixel (:, 1) =pixel (:, 1)-miny+1;   Pixel (:, 2) =pixel (:, 2)-minx+1;maxy=max (Pixel (:, 1));         Maxx=max (Pixel (:, 2));% find the size of the image that the random walk gets Img=zeros (Maxy,maxx);       For I=1:n                      img (Pixel (i,1), Pixel (i,2)) =1;endimshow (IMG)
Description: The source of the article from http://blog.csdn.net/songzitea/article/details/8797424

MATLAB implementation of Random Walk

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.