Array indices must be positive integers or logical values Error
Afficher commentaires plus anciens
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 commentaires
Star Strider
le 29 Juin 2021
... 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
le 30 Juin 2021
Modifié(e) : Jan
le 30 Juin 2021
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 30 Juin 2021
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.
Catégories
En savoir plus sur Image Arithmetic dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!