source: trunk/src/toolbox_calib/ima_read_calib.m @ 903

Last change on this file since 903 was 810, checked in by g7moreau, 10 years ago
  • Add license
File size: 3.6 KB
Line 
1%=======================================================================
2% Copyright 2008-2014, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France
3%   http://www.legi.grenoble-inp.fr
4%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
5%
6%     This file is part of the toolbox UVMAT.
7%
8%     UVMAT is free software; you can redistribute it and/or modify
9%     it under the terms of the GNU General Public License as published
10%     by the Free Software Foundation; either version 2 of the license,
11%     or (at your option) any later version.
12%
13%     UVMAT is distributed in the hope that it will be useful,
14%     but WITHOUT ANY WARRANTY; without even the implied warranty of
15%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16%     GNU General Public License (see LICENSE.txt) for more details.
17%=======================================================================
18
19if ~exist('calib_name')|~exist('format_image'),
20   data_calib;
21   return;
22end;
23
24check_directory;
25
26if ~exist('n_ima'),
27   data_calib;
28   return;
29end;
30
31check_active_images;
32
33
34images_read = active_images;
35
36
37if exist('image_numbers'),
38   first_num = image_numbers(1);
39end;
40
41
42% Just to fix a minor bug:
43if ~exist('first_num'),
44   first_num = image_numbers(1);
45end;
46
47
48image_numbers = first_num:n_ima-1+first_num;
49
50no_image_file = 0;
51
52i = 1;
53
54while (i <= n_ima), % & (~no_image_file),
55   
56   if active_images(i),
57   
58        %fprintf(1,'Loading image %d...\n',i);
59   
60        if ~type_numbering,   
61        number_ext =  num2str(image_numbers(i));
62        else
63        number_ext = sprintf(['%.' num2str(N_slots) 'd'],image_numbers(i));
64        end;
65       
66      ima_name = [calib_name  number_ext '.' format_image];
67     
68      if i == ind_active(1),
69         fprintf(1,'Loading image ');
70      end;
71     
72      if exist(ima_name),
73         
74         fprintf(1,'%d...',i);
75         
76         if format_image(1) == 'p',
77            if format_image(2) == 'p',
78               Ii = double(loadppm(ima_name));
79            else
80               Ii = double(loadpgm(ima_name));
81            end;
82         else
83            if format_image(1) == 'r',
84               Ii = readras(ima_name);
85            else
86               Ii = double(imread(ima_name));
87            end;
88         end;
89
90       
91                if size(Ii,3)>1,
92            Ii = 0.299 * Ii(:,:,1) + 0.5870 * Ii(:,:,2) + 0.114 * Ii(:,:,3);
93                end;
94   
95                eval(['I_' num2str(i) ' = Ii;']);
96         
97      else
98         
99         %fprintf(1,'%d...no image...',i);
100         
101         images_read(i) = 0;
102         
103         %no_image_file = 1;
104         
105      end;
106     
107   end;
108   
109   i = i+1;   
110   
111end;
112
113
114ind_read = find(images_read);
115
116
117
118
119if isempty(ind_read),
120   
121   fprintf(1,'\nWARNING! No image were read\n');
122   
123   no_image_file = 1;
124   
125   
126else
127   
128
129   %fprintf(1,'\nWARNING! Every exsisting image in the directory is set active.\n');
130
131   
132   if no_image_file,
133     
134        %fprintf(1,'WARNING! Some images were not read properly\n');
135     
136   end;
137     
138   
139   fprintf(1,'\n');
140
141   if size(I_1,1)~=480,
142        small_calib_image = 1;
143        else
144        small_calib_image = 0;
145        end;
146   
147   [Hcal,Wcal] = size(I_1);     % size of the calibration image
148   
149   [ny,nx] = size(I_1);
150   
151   clickname = [];
152   
153   map = gray(256);
154   
155        %string_save = 'save calib_data n_ima type_numbering N_slots image_numbers format_image calib_name Hcal Wcal nx ny map small_calib_image';
156
157        %eval(string_save);
158
159        disp('done');
160        %click_calib;
161
162end;
163
164if ~(exist('map')==1), map = gray(256); end;
165
166active_images = images_read;
167
Note: See TracBrowser for help on using the repository browser.