summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/TUTORIALS/matlabPyrTools.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/TUTORIALS/matlabPyrTools.m')
-rwxr-xr-xSD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/TUTORIALS/matlabPyrTools.m145
1 files changed, 145 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/TUTORIALS/matlabPyrTools.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/TUTORIALS/matlabPyrTools.m
new file mode 100755
index 0000000..44c27ce
--- /dev/null
+++ b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/TUTORIALS/matlabPyrTools.m
@@ -0,0 +1,145 @@
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%%% Some examples using the tools in this distribution.
3%%% Eero Simoncelli, 2/97.
4%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5
6%% Add directory to path (YOU'LL NEED TO ADJUST THIS):
7path('/lcv/matlab/lib/matlabPyrTools',path);
8
9%% Load an image, and downsample to a size appropriate for the machine speed.
10oim = pgmRead('einstein.pgm');
11tic; corrDn(oim,[1 1; 1 1]/4,'reflect1',[2 2]); time = toc;
12imSubSample = min(max(floor(log2(time)/2+3),0),2);
13im = blurDn(oim, imSubSample,'qmf9');
14clear oim;
15
16%%% ShowIm:
17%% 3 types of automatic graylevel scaling, 2 types of automatic
18%% sizing, with or without title and Range information.
19help showIm
20clf; showIm(im,'auto1','auto','Al')
21clf; showIm('im','auto2')
22clf; showIm(im,'auto3',2)
23
24%%% Statistics:
25mean2(im)
26var2(im)
27skew2(im)
28kurt2(im)
29entropy2(im)
30imStats(im)
31
32%%% Synthetic images. First pick some parameters:
33sz = 200;
34dir = 2*pi*rand(1)
35slope = 10*rand(1)-5
36int = 10*rand(1)-5;
37orig = round(1+(sz-1)*rand(2,1));
38expt = 0.8+rand(1)
39ampl = 1+5*rand(1)
40ph = 2*pi*rand(1)
41per = 20
42twidth = 7
43
44clf;
45showIm(mkRamp(sz,dir,slope,int,orig));
46showIm(mkImpulse(sz,orig,ampl));
47showIm(mkR(sz,expt,orig));
48showIm(mkAngle(sz,dir));
49showIm(mkDisc(sz,sz/4,orig,twidth));
50showIm(mkGaussian(sz,(sz/6)^2,orig,ampl));
51showIm(mkZonePlate(sz,ampl,ph));
52showIm(mkAngularSine(sz,3,ampl,ph,orig));
53showIm(mkSine(sz,per,dir,ampl,ph,orig));
54showIm(mkSquare(sz,per,dir,ampl,ph,orig,twidth));
55showIm(mkFract(sz,expt));
56
57
58%%% Point operations (lookup tables):
59[Xtbl,Ytbl] = rcosFn(20, 25, [-1 1]);
60plot(Xtbl,Ytbl);
61showIm(pointOp(mkR(100,1,[70,30]), Ytbl, Xtbl(1), Xtbl(2)-Xtbl(1), 0));
62
63
64%%% histogram Modification/matching:
65[N,X] = histo(im, 150);
66[mn, mx] = range2(im);
67matched = histoMatch(rand(size(im)), N, X);
68showIm(im + sqrt(-1)*matched);
69[Nm,Xm] = histo(matched,150);
70nextFig(2,1);
71 subplot(1,2,1); plot(X,N); axis([mn mx 0 max(N)]);
72 subplot(1,2,2); plot(Xm,Nm); axis([mn mx 0 max(N)]);
73nextFig(2,-1);
74
75%%% Convolution routines:
76
77%% Compare speed of convolution/downsampling routines:
78noise = rand(400); filt = rand(10);
79tic; res1 = corrDn(noise,filt(10:-1:1,10:-1:1),'reflect1',[2 2]); toc;
80tic; ires = rconv2(noise,filt); res2 = ires(1:2:400,1:2:400); toc;
81imStats(res1,res2)
82
83%% Display image and extension of left and top boundaries:
84fsz = [9 9];
85fmid = ceil((fsz+1)/2);
86imsz = [16 16];
87
88% pick one:
89im = eye(imsz);
90im = mkRamp(imsz,pi/6);
91im = mkSquare(imsz,6,pi/6);
92
93% pick one:
94edges='reflect1';
95edges='reflect2';
96edges='repeat';
97edges='extend';
98edges='zero';
99edges='circular';
100edges='dont-compute';
101
102filt = mkImpulse(fsz,[1 1]);
103showIm(corrDn(im,filt,edges));
104line([0,0,imsz(2),imsz(2),0]+fmid(2)-0.5, ...
105 [0,imsz(1),imsz(1),0,0]+fmid(1)-0.5);
106title(sprintf('Edges = %s',edges));
107
108%%% Multi-scale pyramids (see pyramids.m for more examples,
109%%% and explanations):
110
111%% A Laplacian pyramid:
112[pyr,pind] = buildLpyr(im);
113showLpyr(pyr,pind);
114
115res = reconLpyr(pyr, pind); % full reconstruction
116imStats(im,res); % essentially perfect
117
118res = reconLpyr(pyr, pind, [2 3]); %reconstruct 2nd and 3rd levels only
119showIm(res);
120
121%% Wavelet/QMF pyramids:
122filt = 'qmf9'; edges = 'reflect1';
123filt = 'haar'; edges = 'qreflect2';
124filt = 'qmf12'; edges = 'qreflect2';
125filt = 'daub3'; edges = 'circular';
126
127[pyr,pind] = buildWpyr(im, 5-imSubSample, filt, edges);
128showWpyr(pyr,pind,'auto2');
129
130res = reconWpyr(pyr, pind, filt, edges);
131clf; showIm(im + i*res);
132imStats(im,res);
133
134res = reconWpyr(pyr, pind, filt, edges, 'all', [2]); %vertical only
135clf; showIm(res);
136
137%% Steerable pyramid:
138[pyr,pind] = buildSpyr(im,4-imSubSample,'sp3Filters');
139showSpyr(pyr,pind);
140
141%% Steerable pyramid, constructed in frequency domain:
142[pyr,pind] = buildSFpyr(im,5-imSubSample,4); %5 orientation bands
143showSpyr(pyr,pind);
144res = reconSFpyr(pyr,pind);
145imStats(im,res);