"index exceeds array bounds " error. Don't know whats wrong

12 vues (au cours des 30 derniers jours)
Paulina Maldonado
Paulina Maldonado le 22 Juin 2018
Having trouble fixing this issue. Please help
for i = 1:1:4800
% Because in MATLAB/Octave indexing starts from 1
if image(i) < 255
image(i) = image(i) + 1;
end
alphaLSH = uint32(bitshift(255, 24));
redLSH = uint32(bitshift(paletteR(image(i)), 16));
greenLSH = uint32(bitshift(paletteG(image(i)), 8));
blueLSH = uint32(bitshift(paletteB(image(i)), 0));
image(i) = typecast(bitor(bitor(alphaLSH, redLSH), bitor(greenLSH, blueLSH)), ...
'int32');
end
Command window shows:
Index exceeds array bounds.
Error in matlab_example_create_image3 (line 116)
redLSH = uint32(bitshift(paletteR(image(i)), 16));
  1 commentaire
Walter Roberson
Walter Roberson le 22 Juin 2018
We do not know what size() of your palette* variables is.
What class is your image array when you start?

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 22 Juin 2018
It looks to me as if you are re-arranging bytes. You should look at using byteswap(). Or you should typecast() to uint8, reshape to 4 x N, use indexing to re-arrange the rows, then typecast() back to uint32.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by