フィルターのクリア

??? 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