What does the function 'ones' do to a matrix when trying to load an image?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Alexandar
am 8 Jul. 2022
Beantwortet: Image Analyst
am 9 Jul. 2022
I am just wondering why we need to put the ones for this code to work. When I get rid of the ones it does not work. Can I get an explanation of why this is?
BrainImage = ones(91, 109,'int8');
2 Kommentare
Akzeptierte Antwort
GandaBerunda
am 8 Jul. 2022
Hi Alexandr,
ones() returns an array or a matrix all the elements of which are the number 1. In your case, it will return a 91x109 int8 array all of whose elements are 1, which will be stored in BrainImage.
0 Kommentare
Weitere Antworten (1)
Image Analyst
am 9 Jul. 2022
If you don't, and you just do
BrainImage(:,:) = aalAtlas.tissue(:, :, 50)
then, since ":" means "all" it will try to take the 50th slice and put it into BrainImage. The problem is that since you used : it means 1:end but it doesn't know the size of BrainImage yet so it throws an error with that syntax. It would have worked if you just didn't try to reference any row and column range, like this:
BrainImage = aalAtlas.tissue(:, :, 50)
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!