From: Vasu D on
Hello,

I was able to read bulk images using dir('*.urformat').I am specially thankful to Steve.

A new problem is faced today.

I've taken snaps of a video for every 10 seconds and I've given them names like- img00001,img00002 etc...when the number in the image name reached to 6 digits like img100001 image order was not in sequence the images(having name) with higher number are coming first in the sequence , that is img100001.png,img100002.png...........img100012.png,img00001.png,img00002.png...etc.....

Here I have 12 images which contain 6 digits in their name which come first in the sequence and remaining all followed them.This lead to reversal of the desired sequence.

Is it a bug?? or am I went wrong??

Could any one suggest me.

regards,
Vasu D.


From: us on
"Vasu D" <funnybooknpen(a)gmail.com> wrote in message <i1vedb$bu7$1(a)fred.mathworks.com>...
> Hello,
>
> I was able to read bulk images using dir('*.urformat').I am specially thankful to Steve.
>
> A new problem is faced today.
>
> I've taken snaps of a video for every 10 seconds and I've given them names like- img00001,img00002 etc...when the number in the image name reached to 6 digits like img100001 image order was not in sequence the images(having name) with higher number are coming first in the sequence , that is img100001.png,img100002.png...........img100012.png,img00001.png,img00002.png...etc.....
>
> Here I have 12 images which contain 6 digits in their name which come first in the sequence and remaining all followed them.This lead to reversal of the desired sequence.
>
> Is it a bug?? or am I went wrong??
>
> Could any one suggest me.
>
> regards,
> Vasu D.

one of the solutions
- sort your images according to their creation time...

flst=dir('img*');
[ix,ix]=sort([flst.datenum]);
flst={flst(ix).name}.';

us
From: Vasu D on
"us " <us(a)neurol.unizh.ch> wrote in message <i1vj57$1b0$1(a)fred.mathworks.com>...
> "Vasu D" <funnybooknpen(a)gmail.com> wrote in message <i1vedb$bu7$1(a)fred.mathworks.com>...
> > Hello,
> >
> > I was able to read bulk images using dir('*.urformat').I am specially thankful to Steve.
> >
> > A new problem is faced today.
> >
> > I've taken snaps of a video for every 10 seconds and I've given them names like- img00001,img00002 etc...when the number in the image name reached to 6 digits like img100001 image order was not in sequence the images(having name) with higher number are coming first in the sequence , that is img100001.png,img100002.png...........img100012.png,img00001.png,img00002.png...etc.....
> >
> > Here I have 12 images which contain 6 digits in their name which come first in the sequence and remaining all followed them.This lead to reversal of the desired sequence.
> >
> > Is it a bug?? or am I went wrong??
> >
> > Could any one suggest me.
> >
> > regards,
> > Vasu D.
>
> one of the solutions
> - sort your images according to their creation time...
>
> flst=dir('img*');
> [ix,ix]=sort([flst.datenum]);
> flst={flst(ix).name}.';
>
> us


===========================================
===========================================

Hello us,
Thankyou for your reply.I tried the code as you said.I am giving it below.

==>
indir = uigetdir();
cd(indir);
allimages=dir('*.png');
[ai,ix]=sort([allimages.datenum]);
len = length(ai);
msgbox(num2str(len));
len1 = length(ix);
msgbox(num2str(len1));
%flst={flst(ix).name}.';
% for i=1:len
% aiout = ai(i);
% ixout = ix(i);
% x=num2str(aiout);
% y=num2str(ixout);
% msgbox(strcat(x,y));
% end
for k = 1:length(allimages)
fileno = ix(k);
filename = allimages(fileno).name;
data1 = imread(filename);
figure,imshow(data1);
end

I am getting an error as below.

==>
??? Reference to non-existent field 'datenum'.

Error in ==> newproblem at 5
[ai,ix]=sort([allimages.datenum]);

Could you help me in this.

regards,
Vasu D.
From: us on
"Vasu D"
> Hello us,
> Thankyou for your reply.I tried the code as you said.I am giving it below.
>
> ==>
> indir = uigetdir();
> cd(indir);
> allimages=dir('*.png');
> [ai,ix]=sort([allimages.datenum]);

> I am getting an error as below.
> ==>
> ??? Reference to non-existent field 'datenum'.
> Error in ==> newproblem at 5
> [ai,ix]=sort([allimages.datenum]);
>
> Could you help me in this.

well... you seem to run an older ML ver...

one of the solutions
- create the .datenum data from the .date field, eg,

d=dir('*.png');
dn=datenum({d.date});
[ai,ix]=sort(dn);
% ...

us
From: Jan Simon on
Dear Vasu D,

> allimages=dir('*.png');
> [ai,ix]=sort([allimages.datenum]);

> ??? Reference to non-existent field 'datenum'.
> Error in ==> newproblem at 5
> [ai,ix]=sort([allimages.datenum]);

Which Matlab version do you use?
In general it is a good idea to read the documentation of commands, which fail. Try "help dir". If you use an old version of Matlab, you find the field "date" only, but you can use DATENUM to convert it to the needed serial number:
D = dir('*.*');
Dnum = datenum({D.date}, 'dd-mmm-yyyy HH:MM:SS');
If you use Matlab 5.3, DATENUM cannot handle cell strings, as far as I remember. Then you could download:
http://www.mathworks.com/matlabcentral/fileexchange/28093
or
http://www.mathworks.com/matlabcentral/fileexchange/25594
(Both not tested with Matlab 5.3, but it could work...)

Good luck, Jan