Ignore:
Timestamp:
Feb 17, 2017, 2:51:46 PM (7 years ago)
Author:
g7moreau
Message:
  • Remove tab
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/toolbox_calib/ima_read_calib.m

    r926 r1000  
    11
    22if ~exist('calib_name')|~exist('format_image'),
    3    data_calib;
    4    return;
     3    data_calib;
     4    return;
    55end;
    66
     
    88
    99if ~exist('n_ima'),
    10    data_calib;
    11    return;
     10    data_calib;
     11    return;
    1212end;
    1313
    1414check_active_images;
    15 
    1615
    1716images_read = active_images;
     
    1918
    2019if exist('image_numbers'),
    21    first_num = image_numbers(1);
     20    first_num = image_numbers(1);
    2221end;
    23 
    2422
    2523% Just to fix a minor bug:
    2624if ~exist('first_num'),
    27    first_num = image_numbers(1);
     25    first_num = image_numbers(1);
    2826end;
    29 
    3027
    3128image_numbers = first_num:n_ima-1+first_num;
     
    3633
    3734while (i <= n_ima), % & (~no_image_file),
    38    
    39    if active_images(i),
    40    
    41         %fprintf(1,'Loading image %d...\n',i);
    42    
    43         if ~type_numbering,   
    44         number_ext =  num2str(image_numbers(i));
    45         else
    46         number_ext = sprintf(['%.' num2str(N_slots) 'd'],image_numbers(i));
    47         end;
    48        
    49       ima_name = [calib_name  number_ext '.' format_image];
    50      
    51       if i == ind_active(1),
    52          fprintf(1,'Loading image ');
    53       end;
    54      
    55       if exist(ima_name),
    56          
    57          fprintf(1,'%d...',i);
    58          
    59          if format_image(1) == 'p',
    60             if format_image(2) == 'p',
    61                Ii = double(loadppm(ima_name));
     35
     36    if active_images(i),
     37
     38        %fprintf(1,'Loading image %d...\n',i);
     39
     40        if ~type_numbering,
     41            number_ext =  num2str(image_numbers(i));
     42        else
     43            number_ext = sprintf(['%.' num2str(N_slots) 'd'],image_numbers(i));
     44        end;
     45
     46        ima_name = [calib_name  number_ext '.' format_image];
     47
     48        if i == ind_active(1),
     49            fprintf(1,'Loading image ');
     50        end;
     51
     52        if exist(ima_name),
     53
     54            fprintf(1,'%d...',i);
     55
     56            if format_image(1) == 'p',
     57                if format_image(2) == 'p',
     58                    Ii = double(loadppm(ima_name));
     59                else
     60                    Ii = double(loadpgm(ima_name));
     61                end;
    6262            else
    63                Ii = double(loadpgm(ima_name));
     63                if format_image(1) == 'r',
     64                    Ii = readras(ima_name);
     65                else
     66                    Ii = double(imread(ima_name));
     67                end;
    6468            end;
    65          else
    66             if format_image(1) == 'r',
    67                Ii = readras(ima_name);
    68             else
    69                Ii = double(imread(ima_name));
     69
     70            if size(Ii,3)>1,
     71                Ii = 0.299 * Ii(:,:,1) + 0.5870 * Ii(:,:,2) + 0.114 * Ii(:,:,3);
    7072            end;
    71          end;
    7273
    73        
    74                 if size(Ii,3)>1,
    75             Ii = 0.299 * Ii(:,:,1) + 0.5870 * Ii(:,:,2) + 0.114 * Ii(:,:,3);
    76                 end;
    77    
    78                 eval(['I_' num2str(i) ' = Ii;']);
    79          
    80       else
    81          
    82          %fprintf(1,'%d...no image...',i);
    83          
    84          images_read(i) = 0;
    85          
    86          %no_image_file = 1;
    87          
    88       end;
    89      
    90    end;
    91    
    92    i = i+1;   
    93    
     74            eval(['I_' num2str(i) ' = Ii;']);
     75
     76        else
     77
     78            %fprintf(1,'%d...no image...',i);
     79
     80            images_read(i) = 0;
     81
     82            %no_image_file = 1;
     83
     84        end;
     85
     86    end;
     87
     88    i = i+1;
     89
    9490end;
    9591
     
    9894
    9995
     96if isempty(ind_read),
     97
     98    fprintf(1,'\nWARNING! No image were read\n');
     99
     100    no_image_file = 1;
     101
     102else
     103    %fprintf(1,'\nWARNING! Every exsisting image in the directory is set active.\n');
     104
     105    if no_image_file,
     106
     107        %fprintf(1,'WARNING! Some images were not read properly\n');
     108    end;
    100109
    101110
    102 if isempty(ind_read),
    103    
    104    fprintf(1,'\nWARNING! No image were read\n');
    105    
    106    no_image_file = 1;
    107    
    108    
    109 else
    110    
     111    fprintf(1,'\n');
    111112
    112    %fprintf(1,'\nWARNING! Every exsisting image in the directory is set active.\n');
     113    if size(I_1,1)~=480,
     114        small_calib_image = 1;
     115    else
     116        small_calib_image = 0;
     117    end;
    113118
    114    
    115    if no_image_file,
    116      
    117         %fprintf(1,'WARNING! Some images were not read properly\n');
    118      
    119    end;
    120      
    121    
    122    fprintf(1,'\n');
     119    [Hcal,Wcal] = size(I_1);     % size of the calibration image
    123120
    124    if size(I_1,1)~=480,
    125         small_calib_image = 1;
    126         else
    127         small_calib_image = 0;
    128         end;
    129    
    130    [Hcal,Wcal] = size(I_1);     % size of the calibration image
    131    
    132    [ny,nx] = size(I_1);
    133    
    134    clickname = [];
    135    
    136    map = gray(256);
    137    
    138         %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';
     121    [ny,nx] = size(I_1);
    139122
    140         %eval(string_save);
     123    clickname = [];
    141124
    142         disp('done');
    143         %click_calib;
     125    map = gray(256);
     126
     127    %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';
     128
     129    %eval(string_save);
     130
     131    disp('done');
     132    %click_calib;
    144133
    145134end;
Note: See TracChangeset for help on using the changeset viewer.