File Exchange

image thumbnail

EM image segmentation

version 1.0 (2.05 KB) by

Apllication of EM algorithm to segment a grey scale image on diferent classes

20 Ratings



View License

This program gets an image and the desidered number of partitions and fits the image histogram using a mixture of gaussian distributions and provides a clasified image

Comments and Ratings (26)

Yves Haxaire

THANK YOU!!!!!!!!!!!! THIS IS PERFECT! I needed it so much, you saved my life !

shameena k

shameena k

In how many iterations does the algorithm converges?

Shengnan Liu

Dear Prof. Jose Vicente Manjon Herrera,
In line 69, you set the stop criteria as:
if((nloglik-loglik)<0.0001) break; end;
Would this cause problem for very small negative nloglik?

I think you could just use values of mask, similar way to "Labeled Componentes Algorithm", remember ?. Every component is labeled with one single number like 1,2...etc. After that just multiply with original image

Aniway, Jose Vicente Do you think "ICA" or this method suits better for image segmentation?


rawan (view profile)


Good job!! I am starting my project on the same subject. But I can't understand your code exactly...could you please let me know what exactly explanation for the source code.
And I want to know means (red color line, blue color line, green color line, y-axis and x-axis)
MY e-mail address is

hui cheng

Mei Dong

very good job!


Jobaer (view profile)

please, sir , send me a source code on image segmentation. I want to segement weeds from soil.My email address is .


widdy (view profile)

Tong Chu

manas nag

manas nag (view profile)

after executing this it is declaring that k is undefined

Jason Rebello

Some people want to know how to view the segmented image. For example suppose you have two classes ie k=2; us the following code to view it
[row col] = size(ima);
final_img = zeros(row,col);
for i=1:row
for j=1:col
if mask(i,j)==1
This is a naive way of viewing it .. you may have to change somethings if k>2. Anywayz hope it helps. The mask basically stores the segmented image.


surya (view profile)

great job.i am using the same algorithm in my project for x-ray images.can u please tell how to view the segmented image


Sir, I am starting my project on the same subject. i was unable to find the algorithm psuedocode for em algorithm. kindly send me one at Also can u just tell me the explanation for the source code..


maria (view profile)

Hi, could you please explain how I can use "mask" to see result of segmentation??


Greetings Prof., Very nice .. could you please let me know what exactly does the mask variable store ? As what i see it classifies each pixel that falls within each class . Am i correct in that assumption?


darko brajicic

great job!

Bilo Bilo


smiled fisher

Karthik Raja T

HI, Greetings,can it for my color image segmentation ?

Mikel Rodriguez

carlos mas

Mohamed Sami

look when u make a code u must show us the output to see it then u read ur code .. try to explain that with output we can see bye

MATLAB Release
MATLAB 6.5.1 (R13SP1)

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

» Watch video