??? Attempted to access cmtx(1.00024,1); index must be a positive integer or logical.

1 view (last 30 days)
hello sir, I am working with a image . and i am applying entropic thresholding on the image ,and i get the error. how to solve this error
"??? Attempted to access cmtx(1.00024,1); index must be a positive integer or logical."
Error in ==> file1>GABOR_Callback at 809
cmtx(fix(rt(m,n))+1,fix(rt(m,n+1))+1) = cmtx(rt(m,n)+1,rt(m+1,n+1)+1) + 1
here rt is my image
and my thresholding code is
[M,N] =size(rt);
cmtx = zeros(256,256);
for m = 1:M-1
for n = 1:N-1
cmtx(rt(m,n)+1,rt(m,n+1)+1) = cmtx(rt(m,n)+1,rt(m+1,n+1)+1) + 1;
end
end
scmtx = sum(cmtx(:)); prob = cmtx/scmtx;
emax = -100; for i=1:255
probA = 0;
probC = 0;
subProbA = prob(1:i,1:i);
probA = sum(subProbA(:));
HA(i) = -0.5*(probA*log2(probA+0.0000001));
subProbC = prob(i+1:256,i+1:256);
probC = sum(subProbC(:));
HC(i) = -0.5*(probC*log2(probC+0.0000001));
e1(i) = HA(i) + HC(i);
if e1(i) >= emax
emax = e1(i);
tt1 = i;
end
end
end

Accepted Answer

David Sanchez
David Sanchez on 22 Nov 2013
your sentece:
cmtx(fix(rt(m,n))+1,fix(rt(m,n+1))+1) = cmtx(rt(m,n)+1,rt(m+1,n+1)+1) + 1
returns a value for
rt(m,n)+1 = 1.00024
you can only access integer values when dealing with matrices. Try to round the values of both rt(m,n)+1 and rt(m+1,n+1)+1 or modify your rt function in order to avoid decimals:
round(rt(m,n)+1) = 1
  4 Comments
vidya
vidya on 24 Nov 2013
rt is constructed by convolution . my first image is rgb image and next i apply gabor filter on it ..after that i apply convolution on my image and that is my rt..now i apply entropic thresholding on my image
vidya
vidya on 24 Nov 2013
sir i solved the problem by using rt = fix(rt) and the i pass this rt into cmtx.b= but now i get a blank output with a small dot..i think this is because of the fix function.. and for the worst part even i remove fix function ..out put is same(a smalll dot) ...can u please temme what may the reason for this

Sign in to comment.

More Answers (0)

Categories

Find more on Images 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!