필터 지우기
필터 지우기

using loop and storing values in an array and get the out put image .

조회 수: 4 (최근 30일)
N/A
N/A 2022년 3월 20일
편집: DGM 2022년 3월 20일
I have an 2 images of dimensions 211 x 322. of rgb image . i want to know how to use for loop. i have 2 variables i and j . i want to write for loop such that i has to be 1 while the j has to be looped 322 times. then i should go to 2 and loop of j should to be repeated 322 such that i should go to up to i for 211 times and j for 322 times.and finally i should able to store the values of each in an array and display the image.
  댓글 수: 1
DGM
DGM 2022년 3월 20일
편집: DGM 2022년 3월 20일
You're describing two nested loops, but you haven't said what you want to do in the loops. You just say "store the values". What values?
In all likelihood, you don't need the loops at all.

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

채택된 답변

Burhan Burak AKMAN
Burhan Burak AKMAN 2022년 3월 20일
편집: DGM 2022년 3월 20일
You can convert rgb image to array.
path="https://pbs.twimg.com/profile_images/883859744498176000/pjEHfbdn_400x400.jpg";
% That image 400x400x3
matrixImage=imread(path);
imshow(matrixImage)
dimensions=size(matrixImage);
array=zeros(1,(dimensions*dimensions'));
indexarray=1;
for i=1:dimensions(1)
for j=1:dimensions(2)
for k=1:dimensions(3)
array(indexarray)=matrixImage(i,j,k);
indexarray=indexarray+1;
end
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by