Code covered by the BSD License  

Highlights from
Region Growing (2D/3D grayscale)


5.0 | 11 ratings Rate this file 236 Downloads (last 30 days) File Size: 289 KB File ID: #32532
image thumbnail

Region Growing (2D/3D grayscale)



14 Aug 2011 (Updated )

Recursive region growing algorithm for 2D/3D grayscale images with polygon and binary mask output

| Watch this File

File Information

A recursive region growing algorithm for 2D and 3D grayscale image sets with polygon and binary mask output. The main purpose of this function lies on clean and highly documented code.

[P, J] = regionGrowing(cIM, initPos, thresVal, maxDist, tfMean, tfFillHoles, tfSimplify)

- cIM: 2D/3D grayscale matrix
- initPos: Coordinates for initial seed position
- thresVal: Absolute threshold level to be included
- maxDist: Maximum distance to the initial position in [px]
- tfMean: Updates the initial value to the region mean (slow)
- tfFillHoles: Fills enclosed holes in the binary mask
- tfSimplify: Reduces the number of vertices with line simplification

- P: VxN array (with V number of vertices, N number of dimensions). P is the enclosing polygon for all associated pixel/voxel
- J: Binary mask (with the same size as the input image) indicating 1 (true) for associated pixel/voxel and 0 (false) for being outside


Region Growing and Line Simplification inspired this file.

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.12 (R2011a)
Other requirements Optional: Line Simplifcation by Wolfgang Schwanghart
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (22)
20 Oct 2014 Lena Veis

Nice work..

26 Sep 2014 Ander Biguri  
01 Dec 2013 adi

Hi, I tried to run the code and the segmentation I get is in a circle shape and not exactly the shape of the segment.
Is this the way the code works? because according the picture it looks like a free shape

10 May 2013 Daniel

Please contact me via 'braggpeaks|a|', since my deposited address is expired. Thanks, Daniel.

25 Mar 2013 Isabel  
10 Jan 2013 gang

thks very much good job!

05 Dec 2012 Hanbo Chen  
03 Aug 2012 Yang  
13 May 2012 Omer Demirkaya

The following two statements should be replaced.
sumSQR = meanI*meanI; % sum of squares

stdI = sqrt((sumSQR - N*meanI*meanI)/(N-1)); % update standard deviation

13 May 2012 Omer Demirkaya

Daniel good work.
I have a suggestion about an efficient mean and standard deviation calculations within your while loop.

Here is the inintilization of the parameters outside the loop.

meanI = regVal; % Mean intensity
sumSQR = 0; % sum of squares
stdI = 0; % Standard deviation
N = 1; % number of pixels

And then within your while loop after the statement,

J(xv+i, yv+j, zv+k) = true;

one can add the following lines of code to progessively calculate mean and standard deviation
gI = cIM(xv+i, yv+j, zv+k);
sumSQR = sumSQR + gI*gI;
meanI = (N*meanI + gI)/(N+1); % update mean
N = N+1; % increment number of pixels
stdI = (sumSQR - N*meanI*meanI)/(N-1); % update standard deviation


04 May 2012 Daniel

Hello Michael. Unfortunately, that's true. I think the easiest way is to give over a handle to the desired axis as an additional input argument.

04 May 2012 Michael

Hey Daniel, running the 2d example with no initial seed produces an error if multiple figures are open, because get(himage,'XData') returns a cell array, and is then used in axes2pix() which accepts only numerical arrays. I'm not sure of the best way to deal with this, aside from including a 'close all' in the code.

03 Apr 2012 maram

i want to segment a mammographic image(from mias database. after choosing the seed the result is like a curve!

02 Apr 2012 Daniel

Hello moram, could you please provide some further informations (e.g. what exactly are you trying to do)?

02 Apr 2012 maram

it works very well with the example associated!!but once i tried on another image i failed!

03 Mar 2012 Daniel

The selection of a seeding position currently works only for 2D input images, since the function does not know, in which slice you may set the initial point. One (easy) way is to check whether the input image is 3D and show up the medial (or a random) slice.

27 Feb 2012 Gomathi C

when i try this code for a 3d image setting the initpos value as [] while calling, it gets the input seed point from me. But, unfortunately I get the following error.

??? Attempted to access initPos(3); index out of bounds because

Kindly help me to figure out what I have to do to make the program run.

01 Dec 2011 Ramachandran M.G.

good work

01 Dec 2011 Ramachandran M.G.  
19 Nov 2011 Daniel

Hello marwa. I'm sorry, i am not sure what you mean with "the same characteristics". Do you mean within the same intensity-range? You are welcome to contact me via mail. With regards, Daniel

17 Nov 2011 marwa hadhoud

this is a good work, but i need to ask you, if there is a possibility to make this code search on all the image about all the separated regions in the image that have the same charactristics.

29 Aug 2011 Jerod Rasmussen

This is great! Worked intuitively right out of the box! Could use an academic reference if available.

15 Aug 2011

some cosmetic changes, attached example.mat

Contact us