how to use conditional entropy thresholding on 2D gray scal image?

3 visualizzazioni (ultimi 30 giorni)
Hi, I want to segment an image with spatial-Pal automatic thresholding method "conditional entropy", I found this code but I confused about the inputs, I suppose that "x" mean the input image, but I couldn't find what "y" is?
function z = conditionalEntropy (x, y)
% Compute conditional entropy H(x|y) of two discrete variables x and y.
% Written by Mo Chen (mochen80@gmail.com).
assert(numel(x) == numel(y));
n = numel(x);
x = reshape(x,1,n);
y = reshape(y,1,n);
l = min(min(x),min(y));
x = x-l+1;
y = y-l+1;
k = max(max(x),max(y));
idx = 1:n;
Mx = sparse(idx,x,1,n,k,n);
My = sparse(idx,y,1,n,k,n);
Pxy = nonzeros(Mx'*My/n); %joint distribution of x and y
Hxy = -dot(Pxy,log2(Pxy+eps));
Py = mean(My,1);
Hy = -dot(Py,log2(Py+eps));
% conditional entropy H(x|y)
z = Hxy-Hy;
end
thanks

Risposta accettata

Stalin Samuel
Stalin Samuel il 17 Ott 2014
  1 Commento
Rasha
Rasha il 20 Ott 2014
stalin samuel, thanks so much for your answer.
but I still don't understand how can I input the image into the program through variables X and Y?

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Modify Image Colors in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by