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

5 views (last 30 days)
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

Accepted Answer

Stalin Samuel
Stalin Samuel on 17 Oct 2014
  1 Comment
Rasha
Rasha on 20 Oct 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?

Sign in to comment.

More Answers (0)

Categories

Find more on Modify Image Colors in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!