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

12 visualizaciones (últimos 30 días)
Paulina Maldonado
Paulina Maldonado el 22 de Jun. de 2018
Respondida: Walter Roberson el 22 de Jun. de 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 comentario
Walter Roberson
Walter Roberson el 22 de Jun. de 2018
We do not know what size() of your palette* variables is.
What class is your image array when you start?

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 22 de Jun. de 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.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by