I'm trying to read all files in a folder, rotatet them 90 degrees, then save them to the same folder. I need to do this 3 times (90, 180, 270 degrees).
The following is my code.
folder = "C:\Users\ME\Pictures\Filler\";S = dir(fullfile(folder,'*.png'));for k = 1:250currentfilename = fullfile(folder,S(k).name);I = imread(currentfilename);I2 = imrotate(I, 90);I2Name = sprintf('%d -1.png', k);I2Path = fullfile(folder, I2Name);imwrite(I2, I2Path);I3 = imrotate(I, 180);I3Name = sprintf('%d -2.png', k);I3Path = fullfile(folder, I3Name);imwrite(I3, I3Path);I4 = imrotate(I, 270);I4Name = sprintf('%d -3.png', k);I4Path = fullfile(folder, I4Name);imwrite(I4, I4Path);end
Running it seems to throw up some errors. Some of the files are repeated or rotated incorrectly. Can anyone spot the reason please? I don't really know enough about matlab to see what I've done wrong!