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

3 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Stalin Samuel
Stalin Samuel am 17 Okt. 2014
  1 Kommentar
Rasha
Rasha am 20 Okt. 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?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Modify Image Colors finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by