File Exchange

image thumbnail

color Image Segmentation

version 1.1 (16.4 KB) by

Segments a color image into regions.

4.15385
14 Ratings

57 Downloads

Updated

View License

This program segments a color image into different regions.
The steps followed for segmentation in this program is as follows:

1. The input color image will be coarsely represented using 25 bins.
2. Coarse representation uses the spatial information from a Histogram based windowing process.
3. K-Means is used to cluster the coarse image data.

Those who are new to Matlab Programming can see the "SampleUsage.m" file for the usage of the script "colImgSeg.m".

Those who are already familiar with Matlab Programming can directly use the script "colImgSeg.m".

Comments and Ratings (26)

Mohamed Asif

hi Athi,
ı need more explanation about your codes.
so if its possible give me a more more details?
actually ım so new for matlab but ı have a homework about this subject. so pls help me if you can.

more details. more comment about codes. :)

ELIJAH JOSEPH

Thanks for this, it is really helpfull

Ashraful Alam

How can i get matlab code in colour image segmentation.

Manini

Manini (view profile)

Hi Athi
I have implemented your code..
i am getting correct output when i run it first time..but when i try to run it next time i am getting this error..
Index exceeds matrix dimensions.

Error in colImgSeg (line 22)
temp((n+1):(end-n),(n+1):(end-n),2)=inImg(:,:,2);

Error in nbinsusage (line 19)
outImg = colImgSeg(inImg, nBins, winSize, nClass);

please help me to resolve the same..
thanks

ljklpsy

May i ask if there is a way to keep the same color for the same region of an image if running kmeans several times? thanks a lot!!!

lbrce

lbrce (view profile)

fff

waseem ahmad

hi athi,
i need to find the center of a colored region if u can help me,plz?

Thendral

Hi Athi
When i am running this code i am getting error like this

Error in ==> colImgSeg at 24
s = size(inImg);
Plz help me

AMIT

AMIT (view profile)

hi athi
thnx dude
can you plz send me the Literature of this program
it will help me in myproject

thnx
amit

Saravanan

Its good,

fusedMap = kmeans(inImg_1D,nClass, 'EmptyAction', 'singleton');

I am working on medical images, where the fusedMap becomes NULL.

Whether its for particular type of images ?

Biao

Biao (view profile)

if the illustration algorithm is more specific, this program will be more honorable!

Biao

Biao (view profile)

thank you so much! it's useful!

Juan Du

Hi Athi,

Thank you. This is very useful tool. I also want to segmenting HSI images. But it does not work with this code. This code seems only works on RGB image. Can you help me to solve the problem?

Thanks.
JD

zhao qiang

zhao qiang

Hi Athi,
Nice contribution.
your program is unstabe ,this is because of the function kmeans,you can try it.
and i want konw what is the meaning of the following statements?

lab = floor(mat(i,j,1)/divis)*(nBins*nBins);
lab = lab + floor(mat(i,j,2)/divis)*(nBins);
lab = lab + floor(mat(i,j,3)/divis);
lab = lab + 1;
TabLabel(lab) = TabLabel(lab) + 1;
sum_lab = sum_lab + lab;
i think this is a weighted action?but why?
look for your reply~
regards,
zq

Farie

Farie (view profile)

Hi, I tried your program but got lot of errors, like not in the loop, unused variables. Can you fix it?

Ashok Kumar

hi Athi

when i am running the code,
Why i have notification like this

??? Input argument "inImg" is undefined.

Error in ==> colImgSeg at 24
s = size(inImg);

jichao zhao

why I have the following error, I do not have Image Processing Toolbox?

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

Error in ==> colImgSeg at 81
fusedMap = kmeans(inImg_1D,nClass, 'EmptyAction', 'singleton');

Error in ==> SampleUsage at 18
outImg = colImgSeg(inImg, nBins, winSize, nClass);

Vignesh

Its working fine. It helps me to understand color histogram fuzzification. Thanks a lot.

Athi

Athi (view profile)

Dear Ramana Murthy,

The output matrix will be same.
But the coloring may differ. Because of default color usage & K-Means.
Am I answered your question?

Venkat R

Venkat R

Hi Athi,
Nice contribution.
When we run the program on same image, different results are coming. It appears there is some bug in your terminating criterion in clustering. Can you fix it.

regards,
ramana

Updates

1.1

Author Info Updated

MATLAB Release
MATLAB 6.5 (R13)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today