save images inside a for loop at uneven intervals
Mostra commenti meno recenti
Hi,
I am trying to save images inside the Img array that is generated inside the for loop at uneven iteration numbers. For example sometimes image generated at 10th iteration, while sometimes it's at 150th iteration. How to handle this?
for i = 1:a
B = some process % my image
Img(:,:,) = B
end
Risposta accettata
Più risposte (2)
One way,
Img=nan(M,N,a);
Isubset=[10 47, 150,...,a]
for i = 1:a
B = some process % my image
if ismember(i,Isubset)
Img(:,:,i) = B;
end
end
1 Commento
Turbulence Analysis
il 25 Gen 2024
Spostato: Voss
il 25 Gen 2024
If you don't know in advance which and how many loop iterations you'll be storing, it would be best to accumulate them in a cell array, and then post-concatenate:
Img = cell(1,a);
for i = 1:a
B = some process % my image
if ... % if some condition says to store this B in Img
Img{i} = B;
end
end
Img=cat(3,Img{:}); %empty cells are discarded
Categorie
Scopri di più su Image Sequences and Batch Processing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!