function u=EStep_LGMM(f,r,c,sigma,b,RegTerm,G,M,N)

K=size(sigma,3);
MN=size(f,1);
V=size(f,2);
B=reshape(b,[M N]);
B2=B.^2;
GB=imfilter(1./B,G,'symmetric');
GB2=imfilter(1./B2,G,'symmetric');
GB=GB(:);
GB2=GB2(:);

for k=1:K
  Ck=repmat(c(k,:),[MN 1]);
  Temp1=sum(f.*(f/sigma(:,:,k)),2).*GB2-2*sum(Ck.*(f/sigma(:,:,k)),2).*GB+sum(Ck.*(Ck/sigma(:,:,k)),2);
  RR=RegTerm(:,:,k);
  p(:,k)=r(k)/(sqrt(det(sigma(:,:,k)))+eps).*exp(-0.5*Temp1-RR(:));
end
sp=sum(p,2);
u=p./repmat(sp,[1 K]);