[926] | 1 | |
---|
| 2 | if ~exist('calib_name')|~exist('format_image'), |
---|
[1000] | 3 | data_calib; |
---|
| 4 | return; |
---|
[926] | 5 | end; |
---|
| 6 | |
---|
| 7 | check_directory; |
---|
| 8 | |
---|
| 9 | if ~exist('n_ima'), |
---|
[1000] | 10 | data_calib; |
---|
| 11 | return; |
---|
[926] | 12 | end; |
---|
| 13 | |
---|
| 14 | check_active_images; |
---|
| 15 | |
---|
| 16 | images_read = active_images; |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | if exist('image_numbers'), |
---|
[1000] | 20 | first_num = image_numbers(1); |
---|
[926] | 21 | end; |
---|
| 22 | |
---|
| 23 | % Just to fix a minor bug: |
---|
| 24 | if ~exist('first_num'), |
---|
[1000] | 25 | first_num = image_numbers(1); |
---|
[926] | 26 | end; |
---|
| 27 | |
---|
| 28 | image_numbers = first_num:n_ima-1+first_num; |
---|
| 29 | |
---|
| 30 | no_image_file = 0; |
---|
| 31 | |
---|
| 32 | i = 1; |
---|
| 33 | |
---|
| 34 | while (i <= n_ima), % & (~no_image_file), |
---|
[1000] | 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; |
---|
[926] | 62 | else |
---|
[1000] | 63 | if format_image(1) == 'r', |
---|
| 64 | Ii = readras(ima_name); |
---|
| 65 | else |
---|
| 66 | Ii = double(imread(ima_name)); |
---|
| 67 | end; |
---|
[926] | 68 | end; |
---|
[1000] | 69 | |
---|
| 70 | if size(Ii,3)>1, |
---|
| 71 | Ii = 0.299 * Ii(:,:,1) + 0.5870 * Ii(:,:,2) + 0.114 * Ii(:,:,3); |
---|
[926] | 72 | end; |
---|
| 73 | |
---|
[1000] | 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 | |
---|
[926] | 90 | end; |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | ind_read = find(images_read); |
---|
| 94 | |
---|
| 95 | |
---|
[1000] | 96 | if isempty(ind_read), |
---|
[926] | 97 | |
---|
[1000] | 98 | fprintf(1,'\nWARNING! No image were read\n'); |
---|
[926] | 99 | |
---|
[1000] | 100 | no_image_file = 1; |
---|
| 101 | |
---|
[926] | 102 | else |
---|
[1000] | 103 | %fprintf(1,'\nWARNING! Every exsisting image in the directory is set active.\n'); |
---|
[926] | 104 | |
---|
[1000] | 105 | if no_image_file, |
---|
[926] | 106 | |
---|
| 107 | %fprintf(1,'WARNING! Some images were not read properly\n'); |
---|
[1000] | 108 | end; |
---|
[926] | 109 | |
---|
| 110 | |
---|
[1000] | 111 | fprintf(1,'\n'); |
---|
[926] | 112 | |
---|
[1000] | 113 | if size(I_1,1)~=480, |
---|
| 114 | small_calib_image = 1; |
---|
| 115 | else |
---|
| 116 | small_calib_image = 0; |
---|
| 117 | end; |
---|
[926] | 118 | |
---|
[1000] | 119 | [Hcal,Wcal] = size(I_1); % size of the calibration image |
---|
| 120 | |
---|
| 121 | [ny,nx] = size(I_1); |
---|
| 122 | |
---|
| 123 | clickname = []; |
---|
| 124 | |
---|
| 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; |
---|
| 133 | |
---|
[926] | 134 | end; |
---|
| 135 | |
---|
| 136 | if ~(exist('map')==1), map = gray(256); end; |
---|
| 137 | |
---|
| 138 | active_images = images_read; |
---|
| 139 | |
---|