Array indices must be positive integers or logical values Error
古いコメントを表示
rgb = inp(:,:,[1 1 1]);
red = rgb(:,:,1);
red(tumorOutline)= 255;
green = rgb(:,:,2);
green(tumorOutline)= 0;
blue = rgb(:,:,3);
blue(tumorOutline)= 0;
tumorOutlineInserted(:,:,1) = red;
tumorOutlineInserted(:,:,2) = green;
tumorOutlineInserted(:,:,3) = blue;
axes(handles.axes6);
imshow(tumorOutlineInserted);
Why this code give error that array in
dices must be positive integers or logical values
Error in line 3
3 件のコメント
Star Strider
2021 年 6 月 29 日
... because ‘TumorOutline’ is not a logical index or a positive integer.
It is not obvious what it is.
Please post the complete error message. I would reveal, which line is falling. Either Star Strider's idea is the problem, or this line, if you have redefined "axes" as a local variable:
axes(handles.axes6);
Shindujah Arudchelvan
2021 年 6 月 30 日
編集済み: Jan
2021 年 6 月 30 日
採用された回答
その他の回答 (1 件)
Image Analyst
2021 年 6 月 30 日
You can't assign certain locations of tumorOutline to be zero when you haven't defined the array.
tumorOutline (erodedImage)=0; // error line
Assuming erodedImage is a logical image of true and false, you're saying that you want the true parts of erodedImage to be black in tumorOutline. Essentially you want tumorOutline to be black where erodedImage is not black. However is the first element is at, say (30, 50) what is it supposed to do with the prios elements, and where is (30,50) in the image? It has not seen tumorOutline before so it has no idea how many rows or columns it has. To fix that particular error, you can declare it somehow, like
tumorOutline = true(size(erodedImage)); % Declare in advance so it knows the size of tumorOutline.
tumorOutline (erodedImage)=0; % No error now;
However there may be other errors and it still may not do what you want due to errors in your algorithm.
カテゴリ
ヘルプ センター および File Exchange で Image Arithmetic についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!