How to plot many images in a loop
9 次查看(过去 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
0 个评论
采纳的回答
ANKUR KUMAR
2021-3-17
for i=1:5
imwrite(randi(255,250,205)/255,sprintf('Image_%d.png',i))
end
10 个评论
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 Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!