I have a iterate undistorttImage function question for version 2016a
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen

I also posted the question here if you prefer : http://stackoverflow.com/questions/38907782/iterate-function-for-matlab-r2016a
2 Kommentare
Andrew Nault
am 16 Aug. 2016
Bearbeitet: Andrew Nault
am 16 Aug. 2016
Andrew Nault
am 20 Aug. 2016
Antworten (1)
Image Analyst
am 12 Aug. 2016
Then don't pass in the image, pass in the index and the cell array
function output = undistortImage(filenames, i)
try
output = []; % Initialize
filename = filenames{i};
originalImage = imread(filename);
% More code....
DO NOT have the output variable change it's name with the loop index - bad bad idea. See http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F
Put the output image into a cell array if you really, really need to keep it after your loop exits.
allImages{k} = undistortImage(filenames, k); % Save image into a cell array and use up a huge amount of memory.
Normally one would just call it thisImage and consume it during the same iteration and overwrite it on every iteration
thisImage = undistortImage(filenames, k); % thisImage will get replaced every iteration and is more memory efficient.
By the way, don't use i and j as loop iterators because they stand for the imaginary variable. That's why I suggest using k instead.
Diese Frage ist geschlossen.
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!