Permalink
Browse files

Add supportedImageFormats

  • Loading branch information...
sometimesfood committed Jun 23, 2011
1 parent 3f18c26 commit c0a91f27723cceb1c1b597e7b8ef1ba1c24f7ba3
Showing with 21 additions and 0 deletions.
  1. +14 −0 flatten.m
  2. +7 −0 supportedImageFormats.m
View
@@ -0,0 +1,14 @@
+% Flatten a nested cell array, taken from
+% http://groups.google.com/group/comp.soft-sys.matlab/browse_thread/thread/83e6ad0772bf68b8
+function flatCell = flatten(cellArray)
+flatCell{1} = []; %#ok<*AGROW>
+for i=1:numel(cellArray)
+ if iscell(cellArray{i})
+ currentCell = flatten(cellArray{i});
+ [flatCell{end+1:end+length(currentCell)}] = deal(currentCell{:});
+ else
+ flatCell{end+1} = cellArray{i};
+ end
+end
+flatCell(1) = [];
+end
View
@@ -0,0 +1,7 @@
+function formats = supportedImageFormats
+supportedFormats = imformats;
+supportedFormats = flatten({ supportedFormats.ext });
+formats = cellfun(@(x) ['*.' x ';'], supportedFormats, ...
+ 'UniformOutput', false);
+formats = cell2mat(formats);
+end

0 comments on commit c0a91f2

Please sign in to comment.