version 1.0.0.0 (54.7 KB) by
Dirk-Jan Kroon

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

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

Dirk-Jan Kroon (2021). Region Growing (https://www.mathworks.com/matlabcentral/fileexchange/19084-region-growing), MATLAB Central File Exchange. Retrieved .

Created with
R2007b

Compatible with any release

**Inspired:**
Region Growing (2D/3D grayscale)

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!Create scripts with code, output, and formatted text in a single executable document.

sai swetha paruchurianyone could you please say how can we rectify this error

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

Leonardo BedoyaMohammad Heydarimohd akmal masudhow to know the area region growing

Shounak ChakrabortyZHOGN GUANIs this code have corresponding paper？

Omar AlmaqtariManuel Casal GuisandeAYOUB AOULALAYVladislav Eroshenkomanimekalai elumalaiI= (im2double(imread('mdb005.pgm')));

figure, imshow(I);

x=200; y=750;

J = regiongrowing(I,x,y,0.2);

i am getting this error :

Undefined function 'regiongrowing' for input arguments of type 'double'.

Error in (line 4)

J = regiongrowing(I,x,y,0.2);

Vaishalee LMarcelo Saval Calvoasmae mama: if you read the example in the code, you have to convert the input data to double,

"I = im2double(imread('medtest.png'));"

hongfei wangasmae mamahello,i m biginner in matlab ,i have this algo,but it would'nt run;

I= (rgb2gray(imread('image.jpg')));

figure, imshow(I );

x=205; y=2562;

J = regiongrowing(I,x,y,0.2);

How do I avoid this error:

Undefined function 'regiongrowing' for input arguments of type 'uint8'.

Veronika SmékalováJobs SteveTamil mani DivyaAkib AhmedHello, I am new in here. My PC system is MAC OS 10.10.5, NVIDIA GeForce GT 640M 512 MB. Whenever I run your code, it keeps running and my PC gets slow. But no output comes out.

Shaked Elias-ZadaI am running this algor

JurgenGiven this has 40K+ downloads I think I should mention the cluster distance metric is wrong. Specifically, I think the mean is calculated incorrectly. The variable reg_size is updated *before* the mean calculation, it should be happening *after*.

Sapna SHi...Its simple and easy to understand. Is there any possible way in which we can compute the threshold automatically rather than hard coding it?

wei zhangMiguel Escalonato 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:

Im=double(rgb2gray(imread('title.format')));

the problem is the format of the matrix , but if you change it by double, it totally works.

Aidan MurrayHow 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.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 jameshow can i run this program

Taein JeonThanks

Sangita Palitz helpful..

ignatious vsthanks for the explanation

Trista Chaoworks well

vasanthselvakumar Rhelp me to extract particular area of an image in automatic

Chada Keatmaneeit works well

MaryHi 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 Oliveiraizahow to make one of the seed automatically grow in interested region?..anyone know?

MANIKANDAN RAJAGOPALhow 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 mughalwhile 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

hdchina2010Thanks 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 Multaniwhere can i get description for this code??

asia malikgood job...thanks

RahulDateWhile 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

your available stack space can crash MATLAB and/or your computer.

Error in ismember>ismemberBuiltinTypes

Can anyone help me with it?

MATLAB R2014a

charuleelaa vanilavarasuhi,

Can someone tell me how to run this code?

I keep getting an error.(Extremely new to matlab)

LUCKY AGARWALyes i can help you mr wasim...

wasim akhtarhi,

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

ramesh thangarajAldo Zaimiellen ellenhi 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

MakrimThe 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 ?

sallyi 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??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;

MaziyarVery nice job.

Can anyone let me know how can we change color of region?

Michael SkocikExcellent algorithm; thank you!

DENNIS DietzSimple program, easy to use on medical images.

bo xiahi thanks want details

Mohammed ashraf??? 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 umarI 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 Rwant details

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

adiIn order to avoid this error, you have to convert your image to type of double by:

I=im2double(I); (I is the image)

Sandy??? 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 Amaluddinguys can u share the correct code?

Ana DjuricicHi,

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

Greets,

Ana

Gaurav MittalWorked like charm, thanks for providing this code.

FrancescoHi... 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 !

Preetikindly 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.

linwell good！

Rajesh GothwalHi... 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 !

nayanai 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

PreetiI 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 ACan you give me some example parameters?

Deonne CI can't download the file as well. Some one please help?

dingHi,

Thank you

Geneaspirin crocini cant download d file....help me!!!

DeepakThq 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 RanHi,

How can I make it work for 3D images?

Thank you

fsdm fsdmkalarmagoWhat 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.

saifthank you

Xin Hevery helpful thanks!

michikovery helpful!Thank you very much!!!

paramveer srani 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

crash MATLAB and/or your computer.

Error in ==> isstruct at 99

thanx

myriam robertI change reg_maxdist to 10 and it's ok.

Does anybody have find how use the region growing for 3D matrix ?

thank you

myriam robertI 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.

can you help me please?

Aravindcan somebody explain how to segment a carotid artery ?

Hank WillThis 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 KneepkensThank you a lot!

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

Natarajancode 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 RVery useful piece of code.

tacciniHello 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 lumbersiti 85cannot download.. why?

Torres Chhetriits 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.

Jagthanks, 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 puriHi, 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 puriHi 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 Haggstromrasool shaikgood

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

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

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

Roberto MantiaIt does what it should do. Very good !

balamurugan samyuseful

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

Xin LiuIt's very helpful. Thanks!