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".
Athi (2021). color Image Segmentation (https://www.mathworks.com/matlabcentral/fileexchange/25257-color-image-segmentation), MATLAB Central File Exchange. Retrieved .
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.
Hi.
Athi, I need your help.
Run your file and have the result in grey colour.
Don't understand...
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. :)
Thanks for this, it is really helpfull
How can i get matlab code in colour image segmentation.
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
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!!!
fff
hi athi,
i need to find the center of a colored region if u can help me,plz?
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
hi athi
thnx dude
can you plz send me the Literature of this program
it will help me in myproject
thnx
amit
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 ?
if the illustration algorithm is more specific, this program will be more honorable!
thank you so much! it's useful!
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
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
Hi, I tried your program but got lot of errors, like not in the loop, unused variables. Can you fix it?
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);
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);
Its working fine. It helps me to understand color histogram fuzzification. Thanks a lot.
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?
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