Cropping several images inside a for delivers empty cells

조회 수: 1 (최근 30일)
Adrián G.
Adrián G. 2023년 2월 27일
댓글: Adrián G. 2023년 2월 28일
Hi. Im trying to process several images at once.
For cropping this is the code I'm writing:
I is raw images and I_ are cropped raw images.
RECT=[0 400 1024 200];
for K=1:10
I_{k}=imcrop(I{k},RECT);
end
Images are 1024x1024 uint8 and are completely accesible and printable in variable I.
I_, after the code, is nothing more than a 1x10 empty cell.
When executing, for example,
% (in command window)
I_{1}=imcrop(I{1},RECT)
in the command window it works and writes the image in the variable spot I_{1} perfectly fine. I can do it one by one but the loop wont.

채택된 답변

Stephen23
Stephen23 2023년 2월 27일
편집: Stephen23 2023년 2월 27일
for K=1:10 % <- uppercase
I_{k}=imcrop(I{k},RECT);
end % ^ lowercase ^
MATLAB is case-sensitive, so you need to make the index the same as the loop iterator.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by