matlab - Image formats in a directory -


i have piece of code

imgpath = 'f:\sift\images\';  dcell = dir([imgpath '*.jpg']);  

here open directory , list of images of type jpg in dcell want not jpg other image formats png or tiff,etc considered...please help! thank you

assuming folder, f:\sift\images\ contains requisite image files, use:

imgpath = 'f:\sift\images\';    %specifies directory path string. dcell = dir(imgpath);    %gets entries in directory; similar `dir` command in windows or `ls` command in linux.  %by default, first 2 output entries of `dir` `.` , `..` refer current , parent directories respectively. dcell = dcell(3:end);    %eliminates default dir entries `.` , `..` truncating first 2 array elements. 

now results can accessed as:

dcell(1)    %entry corresponding first file. dcell(2)    %entry corresponding second file. 

and on.

each output entry of dcell struct following fields:

name date bytes isdir datenum 

to individual field, use:

dcell.name 

and on.

to individual field of particular output struct, use:

dcell(1).name dcell(3).date 

and on.

for more related information, can try help dir , help struct.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -