source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/ffw/test_main.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 2.6 KB
Line 
1clc;clear;
2% Load execution times for:
3% FFTrv FFT execution times for real 1D vectors
4% FFTiv FFT execution times for complex 1D vectors
5% IFFTiv IFFT execution times for complex 1D vectors
6% These times have been calculated with the script provatempo2.m
7% from length N = 3 up to length N = 2048.
8% A finer determination of such times can be done using PAPI for Matlab
9% http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=5445&objectType=File
10% or http://icl.cs.utk.edu/papi/
11load fftexecutiontimes
12%--------------------------------------------------------------------------
13%------------------------------------------------------ FAST 2D CONVOLUTION
14% Two arbitrary 2D matrices
15a = rand(234,222);
16b = rand(222,333);
17% Add a complex part
18% a=a+i*rand(size(a));
19% b=b+i*rand(size(b));
20 
21% Optimized parameters for 2D convolution
22opt = detbestlength2(FFTrv,FFTiv,IFFTiv,size(a),size(b),isreal(a),isreal(b));
23
24tic;
25y0  = fftolamopt2(a,b,opt);
26t   = toc;
27% equivalent to do y0 = conv2(a,b,'full');
28% Another example
29% y1 = fftolamopt2(a,b,opt,'same');
30% equivalent to do y1 = conv2(a,b,'same');
31disp('Time required for fast 2D convolution');
32disp(t);
33%--------------------------------------------------------------------------
34%--------------------------------------------------------------------------
35
36%--------------------------------------------------------------------------
37%-------------------------------------------------------- FAST 2D FILTERING
38I = imread('board.tif');
39I = rgb2gray(I);
40I = double(I);
41
42% If the kernel filter is too small it is convenient to work in time domain,
43% without any FFT!
44myfilter = rand(60,50);
45tic;
46If       = filter2(myfilter,I,'same');
47t0       = toc;
48
49% Rot90 of myfilter to make results consistent
50mf       = fliplr(flipud(myfilter));
51% equivalent to do mf = rot90(myfilter);
52
53% Optimized parameters for 2D filtering
54opt      = detbestlength2(FFTrv,FFTiv,IFFTiv,size(I),size(mf),isreal(I),isreal(mf));
55tic;
56If1      = fftolamopt2(I,mf,opt,'same');
57t1       = toc;
58
59disp('Time required by filter2');
60disp(t0);
61disp('Time required by fftolamopt2');
62disp(t1);
63disp('Max abs error');
64disp(max(max(abs(If-If1))));
65%--------------------------------------------------------------------------
66%---------------------------------------- FAST NORMALIZED CROSS-CORRELATION
67% This function can easily be used also for a fast
68% normalized cross-correlation.
69% See normxcorr2 function (Matlab Image Processing Toolbox) for more details.
70%--------------------------------------------------------------------------
71%--------------------------------------------------------------------------
72
73
74
75
76
77
Note: See TracBrowser for help on using the repository browser.