/normxcorr/trunk

To get this branch, use:
bzr branch http://suren.me/webbzr/normxcorr/trunk

« back to all changes in this revision

Viewing changes to filelist_generator.m

  • Committer: Suren A. Chilingaryan
  • Date: 2009-01-15 13:50:29 UTC
  • Revision ID: csa@dside.dyndns.org-20090115135029-wleapicg9a4593tp
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [FileNameBase,PathNameBase,filenamelist]=filelist_generator
 
2
 
 
3
% Code to construct a list of 9999 or less filenames
 
4
% Programmed by Rob, changed by Chris. Automatic filelist generation 
 
5
% and image time aquisition added by Chris.
 
6
% Last revision: 12/25/06
 
7
 
 
8
filenamelistmode = menu(sprintf('How do you want to create the filenamelist?'),...
 
9
    'Manually','Automatically','Cancel');
 
10
if filenamelistmode==3
 
11
    return
 
12
end
 
13
if filenamelistmode==2
 
14
    [FileNameBase,PathNameBase,filenamelist]=automatically;
 
15
end
 
16
if filenamelistmode==1
 
17
    [FileNameBase,PathNameBase,filenamelist]=manually;
 
18
end
 
19
 
 
20
[FileNameBase,PathNameBase,filenamelist]=imagetime(FileNameBase,PathNameBase,filenamelist);
 
21
 
 
22
%  -------------------------------------------------------
 
23
 
 
24
function [Firstimagename,ImageFolder,filenamelist]=automatically
 
25
 
 
26
[Firstimagename ImageFolder]=uigetfile('*.tif','Open First Image');
 
27
if Firstimagename~~[];
 
28
    cd(ImageFolder);
 
29
end
 
30
 
 
31
if Firstimagename~~[];
 
32
    % Get the number of image name
 
33
    letters=isletter(Firstimagename);
 
34
    Pointposition=findstr(Firstimagename,'.');
 
35
    Firstimagenamesize=size(Firstimagename);
 
36
    counter=Pointposition-1;
 
37
    counterpos=1;
 
38
    letterstest=0;
 
39
    while letterstest==0
 
40
        letterstest=letters(counter);
 
41
        if letterstest==1
 
42
            break
 
43
        end
 
44
        Numberpos(counterpos)=counter;
 
45
        counter=counter-1;
 
46
        counterpos=counterpos+1;
 
47
        if counter==0
 
48
            break
 
49
        end
 
50
    end
 
51
 
 
52
    Filename_first = Firstimagename(1:min(Numberpos)-1);
 
53
    Firstfilenumber=Firstimagename(min(Numberpos):max(Numberpos));
 
54
    Lastname_first = Firstimagename(max(Numberpos)+1:Firstimagenamesize(1,2));
 
55
    Firstfilenumbersize=size(Firstfilenumber);
 
56
    onemore=10^(Firstfilenumbersize(1,2));
 
57
    filenamelist(1,:)=Firstimagename;
 
58
 
 
59
    Firstfilenumber=str2num(Firstfilenumber);
 
60
    u=1+onemore+Firstfilenumber;
 
61
    ustr=num2str(u);
 
62
    filenamelist(2,:)=[Filename_first ustr(2:Firstfilenumbersize(1,2)+1) Lastname_first];
 
63
    numberofimages=2;
 
64
 
 
65
    counter=1;
 
66
    
 
67
    while exist(filenamelist((counter+1),:),'file') ==2;
 
68
        counter=counter+1;
 
69
        u=1+u;
 
70
        ustr=num2str(u);
 
71
        filenamelist(counter+1,:)=[Filename_first ustr(2:Firstfilenumbersize(1,2)+1) Lastname_first];
 
72
        if exist(filenamelist((counter+1),:),'file') ==0;
 
73
            warning('Last image detected')
 
74
            filenamelist(counter+1,:)=[];
 
75
            break
 
76
        end
 
77
    end
 
78
end
 
79
[FileNameBase,PathNameBase] = uiputfile('filenamelist.mat','Save as "filenamelist" in image directory (recommended)');
 
80
cd(PathNameBase)
 
81
save(FileNameBase,'filenamelist');
 
82
 
 
83
%  -------------------------------------------------------
 
84
function [FileNameBase,PathNameBase,filenamelist]=manually;
 
85
% Prompt user for images to be used for analysis  
 
86
 
 
87
prompt = {'Enter number of first image (i.e. "3" for PIC00003):','Enter number of last image (i.e. "100" for PIC00100):'};
 
88
dlg_title = 'Input images to be used for the analysis';
 
89
num_lines= 1;
 
90
def     = {'1','100'};
 
91
answer = inputdlg(prompt,dlg_title,num_lines,def);
 
92
F2 = str2num(cell2mat(answer(1,1)));
 
93
F = str2num(cell2mat(answer(2,1)));
 
94
 
 
95
if F >= 10000
 
96
    error0 = menu('!!! ERROR - Code will only work properly for 9999 or less picture files !!!','Restart');
 
97
    return
 
98
end
 
99
 
 
100
% Choose first name of images
 
101
G = 'PIC1';
 
102
prompt = {'Enter Image Name (first 4 letters):'};
 
103
dlg_title = 'Input images to be used for the analysis';
 
104
num_lines= 1;
 
105
def     = {'PIC1'};
 
106
answer = inputdlg(prompt,dlg_title,num_lines,def);
 
107
G = cell2mat(answer(1,1));
 
108
 
 
109
E='.tif';
 
110
 
 
111
namelist(1:F-F2+1,1)=G(1,1);
 
112
namelist(1:F-F2+1,2)=G(1,2);
 
113
namelist(1:F-F2+1,3)=G(1,3);
 
114
namelist(1:F-F2+1,4)=G(1,4);
 
115
 
 
116
% create the numberlist
 
117
num=((10000+F2):(10000+F))';
 
118
 
 
119
% Creation of final results
 
120
filenamelist=namelist;
 
121
str=num2str(num);
 
122
filenamelist(:,5:8)=str(:,2:5);
 
123
 
 
124
filenamelist(1:F-F2+1,9)=E(1,1);
 
125
filenamelist(1:F-F2+1,10)=E(1,2);
 
126
filenamelist(1:F-F2+1,11)=E(1,3);
 
127
filenamelist(1:F-F2+1,12)=E(1,4);
 
128
 
 
129
 
 
130
% Save results
 
131
[FileNameBase,PathNameBase] = uiputfile('filenamelist.mat','Save as "filenamelist" in image directory (recommended)');
 
132
cd(PathNameBase)
 
133
save(FileNameBase,'filenamelist');
 
134
 
 
135
 
 
136
%  ----------------------------------------
 
137
% Extract the time from images?
 
138
 
 
139
function [FileNameBase,PathNameBase,filenamelist]=imagetime(FileNameBase,PathNameBase,filenamelist)
 
140
 
 
141
selection_time_image = menu(sprintf('Do you also want to extract the time from images to match stress and strain?'),'Yes','No');
 
142
 
 
143
if selection_time_image==1
 
144
  
 
145
    % Loop through all images in imagetimelist to get all image capture times
 
146
    
 
147
    [ri,ci]=size(filenamelist);
 
148
    
 
149
    o=waitbar(0,'Extracting the image capture times...');
 
150
    
 
151
    for q=1:ri
 
152
        
 
153
        waitbar(q/ri);
 
154
        info=imfinfo(filenamelist(q,:));
 
155
        time=datevec(info.FileModDate,13);
 
156
        seconds(q)=time(1,4)*3600+time(1,5)*60+time(1,6);
 
157
        
 
158
    end
 
159
    
 
160
    close(o)
 
161
    
 
162
    % Configure and then save image number vs. image capture time text file
 
163
    
 
164
    im_num_im_cap_time=[(1:ri)' seconds'];
 
165
    save time_image.txt im_num_im_cap_time -ascii -tabs
 
166
    
 
167
end
 
 
b'\\ No newline at end of file'