How to plot many images in a loop

6 次查看(过去 30 天)
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