From: Nitin Kumar on 6 Jun 2010 07:36 Hi all, I have a folder which contains 25 folders with 20 images each in .j2c format. Basically, each image is in .j2c format which I would like to convert to .bmp I can write the images to the .bmp format but my question is: Rather than doing it manually folder by folder , i would like to create a new folder automatically with 25 folders with 20 images each in .bmp format this time. So far I have done the following but I am sure there is a more practical way: clc; clear all; cd('C:\Documents and Settings\user\Desktop\Main_Folder\Subfolder13') files = dir('C:\Documents and Settings\user\Desktop\Main_Folder\Subfolder13\*.j2c'); for i= 1:numel(files) I= imread(files(i).name); imwrite(I,['C:\Documents and Settings\user\Desktop\Main_Folder2\Subfolder13' files(i).name,'.bmp']); end Any help is very appreciated... Cheers
From: ImageAnalyst on 6 Jun 2010 10:15 You can use the dir() function to get the name of folders also. Then you can go into each one and do what you're doing. Just have an outer loop over folders with the inner loop being over files inside that one folder. Or you can just change folder name manually in your string. This may be faster than you trying to program it up to do it automatically, especially if this is just a one-time thing that you need to do. In fact, if you had done that, you'd be done by now. By the way, you say you want to create 25 output folders. I'm not sure imwrite() will automatically create folders if they don't exist. If not, you would have to use mkdir().
From: Nitin Kumar on 6 Jun 2010 11:10 Thanks ImageAnalyst for your response. yes the mkdir() and the dir() seem to be a good idea Yes, I have actually already done it manually , but just thought if there could be a better solution to this ... Cheers,
|
Pages: 1 Prev: Polar Diagram Next: [Simulink] "Round" function in "General Expression Block" problem |