MATLAB: Writing a sequence of images inside a for loop using matix jishnu i have sequence of images formed by processing inside a for loop. I need to write them into a new folder using the concept of matrix Best Answer Jishnu - since your code produces a new image at each iteration of the for loop, then you could do something like the following % initialize the folder/path folderToSaveImg = '/Users/myName/someDirectory/images'; % do your loop for k=1:100 % do the processing to create the image named img img = randi(255,100,100,3); % example only % create the file name fileName = sprintf('image%d.mat',k); % join the file name to the folder name fileDestination = fullfile(folderToSaveImg, fileName); % save the image as a matrix save(fileDestination,'img'); endThe above code (example only) will save 100 images from the sequence to individual mat files where the data stored in the file is a three dimensional matrix. Related SolutionsMATLAB: How to conver folder (images) from GRB to Gary and save them in Output folder with the same original names You need to use fullfile() to make a name with the output folder prefixing the base file name:outputFileName = fullfile(outputFolder, filename);imwrite(img, outputFileName);See the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F MATLAB: Save resize images to a folder Right after you call imresize() make up the output filename and call imwrite():fullOutputFileName = fullfile(OutputFolder1, filenames(n).name);imwrite(rez1, fullOutputFilename); Related QuestionWhat changes are to be made in the following code to convert all the images in grayscaleHow to convert MNIST data from CSV file to imagesWrite an image name to particular folder using imwrite
Best Answer