필터 지우기
필터 지우기

Prevent Overwrite Image in loop

조회 수: 3 (최근 30일)
Ashley Lewis
Ashley Lewis 2018년 8월 7일
편집: Stephen23 2018년 8월 7일
I am trying to load all 16 images. When I run my code now, Only the last image is saved and can be displayed. Even when I include "loadedimage= imread(Image)" and "imshow(loadedimage)" in the for loop this still occurs. Thanks for any help!
for k=1:16 fileName = strcat('image',num2str(k),'.bmp'); Image= char(fileName); end loadedimage= imread(Image); imshow(loadedimage)
  댓글 수: 2
Magdy Saleh
Magdy Saleh 2018년 8월 7일
You are overwriting the image variable at every iteration of the loop
Ashley Lewis
Ashley Lewis 2018년 8월 7일
Ok thanks! Any way I can avoid this?

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

채택된 답변

Stephen23
Stephen23 2018년 8월 7일
편집: Stephen23 2018년 8월 7일
N = 16;
C = cell(1,N);
for k = 1:N
F = sprintf('image%d.bmp',k);
C{k} = imread(F);
end
All of the images will be in cell array C.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by