File Exchange

## Region Growing

version 1.0 (54.7 KB) by

Segmentation by growing a region from seed point using intensity mean measure

Updated

Simple but effective example of "Region Growing" from a single seed point.

The region is iteratively grown by comparing all unallocated neighbouring pixels to the region. The difference between a pixel's intensity value and the region's mean, is used as a measure of similarity. The pixel with the smallest difference measured this way is allocated to the region.

This process stops when the intensity difference between region mean and new pixel becomes larger than a certain treshold

wei zhang

Miguel Escalona

### Miguel Escalona (view profile)

to solve the problem :
Error in regiongrowing (line 69)
dist = abs(neg_list(1:neg_pos,3)-reg_mean);
you need to read the image as:
the problem is the format of the matrix , but if you change it by double, it totally works.

Aidan Murray

### Aidan Murray (view profile)

How do I avoid the following error:
Error using -
Integers can only be combined with integers of the same class, or scalar doubles.

Error in regiongrowing (line 69)
dist = abs(neg_list(1:neg_pos,3)-reg_mean);

Farnaz Kh.

### Farnaz Kh. (view profile)

Hi, I would like to extract the regions with close means as a separate matrix and then compute some values in that regions. Can you please tell me how this possible to be implemented in your function?

sahai james

### sahai james (view profile)

how can i run this program

Taein Jeon

Thanks

Sangita Pal

ignatious vs

### ignatious vs (view profile)

thanks for the explanation

Trista Chao

### Trista Chao (view profile)

works well

vasanthselvakumar R

### vasanthselvakumar R (view profile)

help me to extract particular area of an image in automatic

it works well

Mary

### Mary (view profile)

Hi can any one help please ?
i tried this code and i get the following error:
Not enough input arguments.

Error in regiongrowing (line 29)
if(exist('y','var')==0), figure, imshow(I,[]); [y,x]=getpts; y=round(y(1)); x=round(x(1));
end

Iago Batista Oliveira

iza

### iza (view profile)

how to make one of the seed automatically grow in interested region?..anyone know?

MANIKANDAN RAJAGOPAL

### MANIKANDAN RAJAGOPAL (view profile)

how to solve this.. help me,...Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be
aware that exceeding your available stack space can crash MATLAB and/or your computer.

bushra mughal

### bushra mughal (view profile)

while using this code [x,y] =getpts(fig)or [y,x] =getpts(fig)does not work plz help me how to calculate x and y value

hdchina2010

### hdchina2010 (view profile)

Thanks for the great work, but there exists a small bug in this code, Matlab uses horizontal axis (towards right) as X direction and vertical axis (towards bottom) as Y, and we get seem from Matlab document, [x, y] = getpts(fig), not [y,x] = getpts(fig) you wrote in the code, which could be quite misleading and take me hours to figure it out!

Navneet Multani

### Navneet Multani (view profile)

where can i get description for this code??

asia malik

### asia malik (view profile)

good job...thanks

RahulDate

### RahulDate (view profile)

While using the code with given sample code and example (Line 21), I encountered following error:
Maximum recursion limit of 700 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding

Error in ismember>ismemberBuiltinTypes

Can anyone help me with it?

MATLAB R2014a

charuleelaa vanilavarasu

### charuleelaa vanilavarasu (view profile)

hi,
Can someone tell me how to run this code?
I keep getting an error.(Extremely new to matlab)

LUCKY AGARWAL

wasim akhtar

### wasim akhtar (view profile)

hi,
i am doing project on touchless fingerprint detection, can anybody help me with the region growing matlab code

ramesh thangaraj

Aldo Zaimi

ellen ellen

### ellen ellen (view profile)

hi All
i run this code, but i face following Error:

??? Input argument "I" is undefined.

Error in ==> regiongrowing at 29
if(exist('y','var')==0), figure, imshow(I,[]); [y,x]=getpts;
y=round(y(1)); x=round(x(1)); end

does anyone khow how can i solve this?
thanks

Mohamed

### Mohamed (view profile)

The measure of similarity is the difference between a pixel's intensity value and the region's mean currently being processed, so it is relative. Does this kind of region growing algorithm has a name ? like progressive or adaptive ? or this is just a different similarity measure ?

sally

### sally (view profile)

i have a grey scale lung CT image which ranges between 0-256 with regions of the values : 0 , 52 , then values > 90 which i want to segment .. i give the threshold value = 75 but still the resultant mask includes all the image, not the inner part with values > 75 only ..
what's wrong here ?

ABIN joy

### ABIN joy (view profile)

??Attempted to access neg_list(0,:); index must be a positive integer or logical.

Error in ==> regiongrowing at 80
neg_list(index,:)=neg_list(neg_pos,:); neg_pos=neg_pos-1;

Maziyar

### Maziyar (view profile)

Very nice job.
Can anyone let me know how can we change color of region?

Michael Skocik

### Michael Skocik (view profile)

Excellent algorithm; thank you!

DENNIS Dietz

### DENNIS Dietz (view profile)

Simple program, easy to use on medical images.

bo xia

### bo xia (view profile)

hi thanks want details

Mohammed ashraf

### Mohammed ashraf (view profile)

??? Subscript indices must either be real positive integers or logicals.

Error in ==> regiongrowing at 34
reg_mean = I(x,y); % The mean of the segmented region

how could this problem be solved please response ASAP

syed umar

### syed umar (view profile)

I am getting an error: "Not enough input arguments" Please help me how to solve the problem, Please tell me How to pass input arguments?

NITHYA V R

want details

Luke Xie

### Luke Xie (view profile)

Thanks for the function. Good code to have in your image processing toolbox.

In order to avoid this error, you have to convert your image to type of double by:
I=im2double(I); (I is the image)

Sandy

### Sandy (view profile)

??? Error using ==> minus
Class of operand is not supported.

Error in ==> regiongrowing at 69
dist = abs(neg_list(1:neg_pos,3)-reg_mean);

How could this problem be solved?

Fitroh Amaluddin

### Fitroh Amaluddin (view profile)

guys can u share the correct code?

Ana Djuricic

### Ana Djuricic (view profile)

Hi,

if someone knows example for region growing using multiple seed points, please share! Thank you!

Greets,
Ana

Gaurav Mittal

### Gaurav Mittal (view profile)

Worked like charm, thanks for providing this code.

Francesco

### Francesco (view profile)

Hi... I found an error executing this code. The details of error are follows:

Error using -
Integers can only be combined with integers of the same class, or scalar doubles.

Error in regiongrowing (line 69)
dist = abs(neg_list(1:neg_pos,3)-reg_mean);

Thanks !

Preeti

### Preeti (view profile)

kindly reply to my question. I have sent u many mails that this code is not working fine for me as i am getting a white image only. I need the ROI which i selected with seed point. Please reply.

lin

well good！

Rajesh Gothwal

### Rajesh Gothwal (view profile)

Hi... I have found an error when i am executing this code. The details of error are follows:

??? Error using ==> minus
Integers can only be combined with integers of the same class, or
scalar doubles.
dist = abs(neg_list(1:neg_pos,3)-reg_mean);
Thanks !

nayana

### nayana (view profile)

i should say that this is very helpful for beginners like me, but i have a doubt, on what basis can we determine the value to reg_max distance
if we choose to segment a particular region

Preeti

### Preeti (view profile)

I have tried the code on image size 512*512. after providing the x and y values, i get J of same size 512*512 with all white image. No segmentation has been done. Please suggest!

Mauro A

### Mauro A (view profile)

Can you give me some example parameters?

Deonne C

ding

Hi,
Thank you

Gene

aspirin crocin

Deepak

### Deepak (view profile)

Thq Dirk-Jan Kroon for such short code.I am working dicom image.I convert it into JPG.i have a problem over run time.

??? Undefined function or method 'regiongrowing' for input
arguments of type 'double'.

I even defined im2double() fnc.but i got an error...

Sivan Ran

### Sivan Ran (view profile)

Hi,
How can I make it work for 3D images?

Thank you

fsdm fsdm

kalarmago

### kalarmago (view profile)

What are x and y, I believe image(x,y) coordinate, but when I tested other x,y values (eg, x=308,y=244, I(x,y)=0.73) then the segmented result image is not desired.

saif

thank you

Xin He

michiko

paramveer sran

### paramveer sran (view profile)

i have downloaded this piece o code but when i tried to run on the same image i.e medtest.png i got the following error. could you plz tell me where is the problem and how to solve this
>> regiongrowing
??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack space can

Error in ==> isstruct at 99
thanx

myriam robert

### myriam robert (view profile)

I change reg_maxdist to 10 and it's ok.
Does anybody have find how use the region growing for 3D matrix ?
thank you

myriam robert

### myriam robert (view profile)

I have a MRI coup from a 3D data matrix "Y" so it's Y( : , : , 14) .
the algorithm doesn't work on this coup. In the result I have only one white pixel ( the seedpoint).
I change the line 70 but it doesn't change anything.

Aravind

### Aravind (view profile)

can somebody explain how to segment a carotid artery ?

Hank Will

### Hank Will (view profile)

This looks pretty cool! But I wonder processing larger images with this routine (e.g. satellite data). Any suggestions? In my case I don't get any error, but processing a 10 Bit panchromatic imagery subset of just 15 Mb leads to no valuable results.
Would highly appreciate any thoughts about workflows for matlab for this purpose!
Thanks!

Esther Kneepkens

Thank you a lot!

Jess

### Jess (view profile)

No need to change line 70 if use im2double with imread as given in the example (line 21 - comment section)

Natarajan

### Natarajan (view profile)

code works except as Ron did . got to change the line 70.

However the i didn't get a segmented/thresholded output for 16 bit grey scale! Thanks

Would be great if someone could give an idea of whats the issue!

anoop R

### anoop R (view profile)

Very useful piece of code.

taccini

### taccini (view profile)

Hello All,
first i want to thank Dirk about his work and all the matlab community because there are very helpful for me.
well i need to use the region growing for 3D matrix.
this code could be adapted or any one have some idea?
thanks.

jack lumber

siti 85

Torres Chhetri

### Torres Chhetri (view profile)

its was a great help, would you like to extend your for taking random seed pixels for a colorful image. if u do that, it would be so great.

Jag

### Jag (view profile)

thanks, seems like a handy piece of code.
On R2008b I had to change line 70 to

dist = abs(neg_list(1:neg_pos,3)-double(reg_mean));

to get it to run with the sample image.

ucd puri

### ucd puri (view profile)

Hi, I figured out what was the problem, my data set was in int16 format so, it was eaisy to make amendments, but i am not sure if my region is segmented correctly. Regards tanuj

ucd puri

### ucd puri (view profile)

Hi All, This is an excellent piece of code. I am just an intermediate matlab programmer and have a couple of questions on this code.
(1) It works perect on normal images. But i have a dicom int16 medical image, when i give it as an input, i get an output image with only one pixel (the seed pixel that i selected) . I changes the code a little bit for example instad of imread, i used dicomread, and in place of imshow(I,[]) i used imshow(I,'displayRange',[]).
(2) the file explaination reads '"This process stops when the intensity difference between region mean and
new pixel become larger than a certain treshold (t)" but this t is 0.2 which you have defined in the file, what if i want to use an grey intensity level of say 600 as threshold. As my image is int16 dicom, it has 2^16 , so it grey sclae ranges from -32768 to + 32768.
thanks a lot for help in advance.
tanuj

Ida Haggstrom

rasool shaik

### rasool shaik (view profile)

good

it works very good, so simple. need to de developed in other area

Paolo L

very good, simple to read, simple to understand, it works fine for a start, useful for student exercises

Zonglei Zhen

region growing is a very useful method for sgementation. This program is a good start of it.

Roberto Mantia

It does what it should do. Very good !

balamurugan samy

useful

jichao zhao

That is excellent one. I am wondering whether you can extend your work to colorful graph, not just gray scale.

Xin Liu