Diah - it isn't clear to me why you have the inner for loop
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
currentImageArray = imread(fullFileName);
currentImage{k}=currentImageArray;
for i = 1 : 7
outputFolder = 'D:\DIAH\[MATLAB]cv1-fingerspelling-recognition-master\cv1-fingerspelling-recognition-master\Hasil Percobaan Lab';
outputFileName = fullfile(outputFolder, ['Hasil Citra Lab_' num2str(i) '.jpg']);
imwrite(currentImage{k}, outputFileName);
end
end
but it does explain why you are writing out the same file seven times and why all correspond to the last image that you read in. Note how in the outer loop you iterate over all jpgs (from the folder). Then, for each of these images, you have an inner loop that creates seven files (all with the same image currentImage{k}) across seven files named "Hasil Citra Lab_1.jpg", "Hasil Citra Lab_2.jpg",..., "Hasil Citra Lab_7.jpg". That means that on every iteration of the outer loop, you will overwrite the contents of these seven files (since they don't depend upon the k variable) with the image that has been read on the current iteration of the outer loop.
If you want to make sure that you don't overwrite the files, then you could add k to the file name
outputFileName = fullfile(outputFolder, sprintf('Hasil Citra Lab_%d_%d.jpg', k, i));
Otherwise, you may want to verify if you really need that inner loop (I'm not sure why you need to write the same image to seven different files).
Best Answer