필터 지우기
필터 지우기

??? Subscript indices must either be real positive integers or logicals.

조회 수: 2 (최근 30일)
Tomas
Tomas 2014년 4월 27일
편집: Image Analyst 2014년 4월 28일
Hello, i need help. I will be grateful for any advice.
I have to clustering grayscale image.
I enclose my code The main function is kmnsImage.
error in :
??? Subscript indices must either be real positive integers
or logicals.
Error in ==> KMNSimage at 542
cluster(Z{ii}) = ii;
I must to clustering grayscale image,so that the pixels in a similar intensities were in one cluster.
Please help me.
Thank you for your help
  댓글 수: 3
Geoff Hayes
Geoff Hayes 2014년 4월 27일
편집: Geoff Hayes 2014년 4월 27일
Hi Tomas,
Try putting in some breakpoints in and around line 542 and check to see what your value of ii is being set to. Given the error, it sounds like your ii is being set to zero or some rational (or fraction of a) number.
If there are several iterations of the loop (over ii) then it may take some time to step through all iterations until the failure occurs. Sometimes, what I do, is to wrap the trouble spot in a try catch block and then just put the breakpoint in the catch. So when the error occurs, the code pauses in the catch:
try
cluster(X{ii}) = ii;
catch
fprintf('error!');
end
The breakpoint will be on the line of the fprintf, and you can debug here to see what the value of ii is.
Geoff
Tomas
Tomas 2014년 4월 27일
Thank you for your answers, I am having trouble, I do not know that the resulting cells to portray the image back,

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2014년 4월 27일
Then try this:
try
whos X
whos ii
fprintf('X{%d} = %d\n', ii, X{ii});
index = X{ii}
cluster(index) = ii;
catch ME
errorMessage = sprintf('Error in function %s() at line %d.\n\nError Message:\n%s', ...
ME.stack(1).name, ME.stack(1).line, ME.message);
fprintf(1, '%s\n', errorMessage);
uiwait(warndlg(errorMessage));
end
  댓글 수: 15
Tomas
Tomas 2014년 4월 28일
i want to find points on the image, I do not care background, the thing is ,when the points are near yourself but have different intesity not to be in single cluster,points that are far from yourself a have similar intesity were in one cluster.
Image Analyst
Image Analyst 2014년 4월 28일
편집: Image Analyst 2014년 4월 28일
So like I said, you want to label the image. All pixels in spot #1 should be labeled 1, and all pixels in spot #2 should be labeled #2, and so on. This is precisely what bwlabel does in one line, and what the kmeans code that I gave over in your duplicate question does, reproduced below here:
classifiedImage = zeros(size(I), 'int32');
for p = 1 : length(IDX)
row = P(p, 1);
column = P(p, 2);
% Set this pixel of the classified image
% to the class it identified for that pixel.
classifiedImage(row, column) = IDX(p);
end

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by