-3

Can any one please suggest a matlab code for implementation of random walk algorithm, for image segmentation, specifically CT images.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Parth Sehgal
  • 139
  • 1
  • 1
  • 7

1 Answers1

1

I suggest having a look at Leo Grady's Graph Analysis Toolbox as well as the corresponding Addon for Image Segmentation using Random Walks, see here. Download the Graph Analysis Toolbox and the Random Walker code, and save the files as follows:

praphAnalysisToolbox/
README.txt
random_walker_example.m
random_walker.bmp
axial_CT_slice.bmp

Include graphAnalysisToolbox in your path to be able to call the demo, i.e. ranomd_walker_example.m. The demo should segment the provided image. In your case you might have to set the seeds differently depending on the application and your images.

As example, the seeds can be placed in a superpixel-like fashion:

% Read image into the variable image ...
img = im2double(image);
[height, width, channels] = size(img);

seeds = [];
seed_labels = [];

label = 1;
i = floor(region_height/2);
while i < height

    j = floor(region_width/2);
    while j < width
        seeds = [seeds, sub2ind([height, width], i, j)];
        seed_labels = [seed_labels, label];

        label = label + 1;
        j = j + region_width;
    end;

    i = i + region_height;
end;

%Apply the random walker algorithms
[labels, ~] = random_walker(img, seeds, seed_labels, beta);

See the comments in random_walker.m for more details.

David Stutz
  • 2,578
  • 1
  • 17
  • 25