필터 지우기
필터 지우기

How to plot many images in a loop

조회 수: 11 (최근 30일)
Tsitsos Dimitris
Tsitsos Dimitris 2021년 3월 17일
댓글: Rik 2021년 3월 18일
Hello,
I am working with a Matlab code where I want to run a loop. In each loop, I will do some processing and then show an image based on the processed data. When I go to the next loop, I want the previously stored image to be closed and generate a new image based on the latest data.
A sum up from my code is this :
for ww= 0.4:0.2:2.6
**********************image processing code*********************************
t1=1-ww*(dark_channel1/A); % part that connect ww with the image processing code
**********************image processing code*********************************
out = pic;
figure;
imshow (out)
imwrite(out,sprintf('%d.jpg',ww));
End;
What I expect is many different images depend on the "ww", but the output that I take looks like in each iteration each image sticks to the previous one.
I think that somehow I can’t separate the output (image), and after each iteration I don't reset my loop. As a result I display a new image but stack on the previous. It is like in each iteration the new image sticks to the previous.
Any suggestions??
Thank you in advance

채택된 답변

ANKUR KUMAR
ANKUR KUMAR 2021년 3월 17일
for i=1:5
imwrite(randi(255,250,205)/255,sprintf('Image_%d.png',i))
end
  댓글 수: 10
Tsitsos Dimitris
Tsitsos Dimitris 2021년 3월 18일
편집: Tsitsos Dimitris 2021년 3월 18일
I undestand!
Give me some time and I will post my updated code here!
Thank you again
Rik
Rik 2021년 3월 18일
Regarding your email:
There must be a way to reproduce this problem. Try removing code line by line to see what happens when.
As an example:
for i=1:h
for j=1:w
dark_I(i,j)=min(img(i,j,:));
end
end
This sets some values to dark_I. Assuming img contains integers 0-255, you can replace this loop with this:
dark_I(1:h,1:w)=uint8(randi(255,h,w));
It is also possible to create a mat file containing dark_I wrapped in a cell with the values for the first 3 iterations. That should also be enough to replicate the result.
I don't do private consulting, there are other people you can hire for that. You need to find a way to reproduce your issue in fewer lines of code than you posted above. Unless there is a bug caused by a very specific condition (making it hard/impossible to reproduce on my end anyway), it is almost always possible to reduce the cause of such behavior down to code that fits on one screen.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by