/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 automate_image.m

  • Committer: Suren A. Chilingaryan
  • Date: 2009-12-15 20:10:31 UTC
  • Revision ID: csa@dside.dyndns.org-20091215201031-tx1m0yw1r5owbnzg
Optimization mode 5 for matlab: image loading in C code

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
%  2 - The CUDA matlab plugin is used to compute FFT's
45
45
%  3 - Most of computations are performed on NVidia card
46
46
%  4 - Optimize FFT sizes for better performance (affects precision)
 
47
%  5 - Load images in C code
47
48
% You can safely set an optimization level to 3. If NVidia card is not available
48
49
% the level will be automatically reduced to 1.
49
50
%
51
52
% 0 - in the end
52
53
% 1 - per iteration
53
54
 
54
 
OPTIMIZE = 4;
 
55
OPTIMIZE = 5;
55
56
CORRSIZE = 15;  
56
57
PRECISION = 1000;
57
58
SILENT = 1;
99
100
 
100
101
% Open new figure so previous ones (if open) are not overwritten
101
102
if (~SILENT)
 
103
    if OPTIMIZE > 4
 
104
        OPTIMIZE = 4
 
105
    end
 
106
    
102
107
    h=figure;
103
108
    imshow([imagedir, filenamelist(1,:)])           % show the first image
104
109
    title('Initial Grid For Image Correlation (Note green crosses)')        % put a title
169
174
    end
170
175
end
171
176
 
172
 
base = uint8(mean(double(imread([imagedir, filenamelist(1,:)])),3));            % read in the base image ( which is always  image number one. You might want to change that to improve correlation results in case the light conditions are changing during the experiment
173
177
 
174
178
if OPTIMIZE > 2
175
 
%    crop_dim = [min(base_points_x(:)) - 2*CORRSIZE, min(base_points_y(:)) - 2 * CORRSIZE, max(base_points_x(:)) + 2*CORRSIZE, max(base_points_y(:)) + 2 * CORRSIZE]
176
 
%    crop_size = (crop_dim(3) - crop_dim(1)) * (crop_dim(4) - crop_dim(2))
177
 
%    mesh_size = ncp * 4 * CORRSIZE * CORRSIZE
178
 
 
179
179
%    Verification of GPU local sum and denom computations
180
180
%    dic_basecorr3(CORRSIZE, PRECISION, OPTIMIZE, hwid, base_points_x, base_points_y, base);
181
181
 
182
 
    data_base = struct;
183
 
    base_points_for(:,1)=reshape(base_points_x,[],1);
184
 
    base_points_for(:,2)=reshape(base_points_y,[],1);
185
 
    for icp = 1:ncp
186
 
        data_base(icp).base_fractional_offset = base_points_for(icp,:) - round(base_points_for(icp,:)*PRECISION)/PRECISION;
187
 
    end
188
 
 
189
182
    normxcorr_hw(hwid, 3, base_points_x, base_points_y);
190
 
    normxcorr_hw(hwid, 4, base);
 
183
    if OPTIMIZE > 4
 
184
        normxcorr_hw(hwid, 4, strcat(imagedir, filenamelist(1,:)));
 
185
    else
 
186
        base = uint8(mean(double(imread([imagedir, filenamelist(1,:)])),3));            % read in the base image ( which is always  image number one. You might want to change that to improve correlation results in case the light conditions are changing during the experiment
 
187
        normxcorr_hw(hwid, 4, base);
 
188
    end 
191
189
else
 
190
  base = uint8(mean(double(imread([imagedir, filenamelist(1,:)])),3));            % read in the base image ( which is always  image number one. You might want to change that to improve correlation results in case the light conditions are changing during the experiment
192
191
  base_points_for(:,1)=reshape(base_points_x,[],1);
193
192
  base_points_for(:,2)=reshape(base_points_y,[],1);
194
193
 
269
268
    input_correl(:,2)=reshape(input_points_y,[],1);
270
269
end
271
270
 
272
 
input = uint8(mean(double(imread([imagedir, filenamelist((firstimage+1),:)])),3));       % read in the image which has to be correlated
273
271
for i=firstimage:(r-1)               % run through all images
274
272
    tic             % start the timer
275
273
 
276
 
%    input = uint8(mean(double(imread([imagedir, filenamelist((i+1),:)])),3));       % read in the image which has to be correlated
277
274
 
278
 
    if OPTIMIZE > 2
 
275
    if OPTIMIZE > 4
 
276
        normxcorr_hw(hwid, 13, strcat(imagedir, filenamelist((i+1),:)));
 
277
        input_correl = normxcorr_hw(hwid, 14);
 
278
    elseif OPTIMIZE > 2
279
279
        %Validate findpeak
280
280
        %dic_cpcorr3(CORRSIZE, PRECISION, OPTIMIZE, hwid, ncp, input);
 
281
 
 
282
        input = uint8(mean(double(imread([imagedir, filenamelist((i+1),:)])),3));       % read in the image which has to be correlated
281
283
        normxcorr_hw(hwid, 13, input)
282
 
        if i < (r-1)
283
 
            input = uint8(mean(double(imread([imagedir, filenamelist((i+2),:)])),3));       % read in the image which has to be correlated
284
 
        end
285
284
        input_correl = normxcorr_hw(hwid, 14);
286
285
    elseif OPTIMIZE > 0
 
286
        input = uint8(mean(double(imread([imagedir, filenamelist((i+1),:)])),3));       % read in the image which has to be correlated
287
287
        input_correl(:,:)=dic_cpcorr(CORRSIZE, PRECISION, OPTIMIZE, hwid, data_base, input_correl, input);
288
288
    else
 
289
        input = uint8(mean(double(imread([imagedir, filenamelist((i+1),:)])),3));       % read in the image which has to be correlated
289
290
        input_correl(:,:)=cpcorr(input_correl, base_points_for, input, base);
290
291
    end
291
292