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

조회 수: 12 (최근 30일)
Paulina Maldonado
Paulina Maldonado 2018년 6월 22일
답변: Walter Roberson 2018년 6월 22일
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
Walter Roberson
Walter Roberson 2018년 6월 22일
We do not know what size() of your palette* variables is.
What class is your image array when you start?

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 6월 22일
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.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by