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

3 次查看(过去 30 天)
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

采纳的回答

Stalin Samuel
Stalin Samuel 2014-10-17
  1 个评论
Rasha
Rasha 2014-10-20
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?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Modify Image Colors 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by