Grouping images from multiple folders
Show older comments
I have 120 folders each containing 46 images belonging to 46 categories. I have to take these individual images and make 46 folders (each for a separate category). Kindly help me with the code for this. Thanks in advance.
3 Comments
Walter Roberson
on 13 Jan 2017
Is it known which file belongs to which category? For example is there a table that matches the file CRC-16 with the category ?
shivasakthi
on 14 Jan 2017
Edited: shivasakthi
on 14 Jan 2017
Walter Roberson
on 14 Jan 2017
I suspect that you are using MS Windows,and in particular an NTFS file system. NTFS does not document the order that it stores files, and I gather that it is permitted for disk optimization utilities to change the order of files within a directory. There is no real meaning to "consecutive images" in the system, or rather the order can change at any time.
I would suggest to you that you have been thinking that the files are arranged in alphabetical order. I speculate that the information about which class any given file belongs to is somehow represented as part of the file name. If that is correct then it would help if you could describe the structure of the file names and which part includes the needed information.
Answers (1)
Image Analyst
on 14 Jan 2017
"The first two images" is ambiguous.
But to create 23 folders, use sprintf() and mkdir()
for k = 1 : 23
folder = sprintf('Folder %d', k);
if ~exist(folder, 'dir')
mkdir(folder);
end
end
2 Comments
shivasakthi
on 14 Jan 2017
Image Analyst
on 14 Jan 2017
You should use one of the two code samples in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F Have the loop step in steps of 2 instead of 1.
Categories
Find more on Image Preview and Device Configuration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!