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

조회 수: 3 (최근 30일)
Rasha
Rasha 2014년 10월 17일
댓글: Rasha 2014년 10월 20일
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