How to plot many images in a loop
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Tsitsos Dimitris
am 17 Mär. 2021
Kommentiert: Rik
am 18 Mär. 2021
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 Kommentare
Akzeptierte Antwort
ANKUR KUMAR
am 17 Mär. 2021
for i=1:5
imwrite(randi(255,250,205)/255,sprintf('Image_%d.png',i))
end
10 Kommentare
Rik
am 18 Mär. 2021
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!