"'WriteMode' and 'append' when using imwrite function to save multiple images in specific folder" - this was a bad advice. Appending let you store multiple images in one file, not folder. This works e.g. for TIFF, HDF4 and GIF images, but not for BMPs.
The solution is easy: Omit the 'WriteMode' argument.
Good programming practice:
- Use fullfile instead of strcat to concatenate file names.
- This is inefficient:
You create an array of zeros with 227*227 elements in double format, which requires 412 kB of RAM. The next line creates an UINT8 array of the same size using 51 kB and copies the converted values. The direct approach is faster and nicer:
I12=zeros(227, 227, 'uint8');
- What is the purpose of this part:
obj=imresize(obj,[227 227]);
else I12(i,j,t)=obj(i,j,t);
? You have limited the size of obj to be a [227 x 227] image before already. So the elementwise copy to I12 is a complete waste of time. Faster and cleaner:
I12 = zeros(227, 227, 'uint8');
I12(1:m, 1:n, 1:t) = uint8(obj);