source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/vlutil/test/test_warp.m @ 37

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

Added original make3d

File size: 1.6 KB
Line 
1% TEST_WARP Test image warping routines
2
3% load test image
4I = imread('pu.png') ;
5I = im2double(I) ;
6[M,N,K] = size(I) ;
7
8% dense grid
9[x,y] = meshgrid(1:N,1:M);
10
11% control point grid
12xr=linspace(1,N,5) ;
13yr=linspace(1,M,5) ;
14[xc,yc]=meshgrid(xr,yr) ;
15
16% --------------------------------------------------------------------
17%                                              test affine defromation
18% --------------------------------------------------------------------
19A = [1 0 ; 0 1] ;
20T = [0;0] ;
21
22figure(100);clf;
23for i=1:10
24  % backward projection of dense grid
25  [wx,wy]=waffine(A,T,x,y) ;
26  J = imwbackward(1:N,1:M,I,wx,wy);
27 
28  % forward projection of control grid
29  [xg,yg]=waffine(inv(A),-inv(A)*T,xc,yc) ;
30
31  % change randomly the affine tf
32  A = A + .1*randn(2) ;
33  T = T + .1*randn(2,1)  ;
34 
35  % plot deformed image and grid
36  tightsubplot(10,i) ;imagesc(J) ;colormap gray;
37  plotgrid(xg,yg,'color','g','linewidth',4) ;axis off;
38end
39
40drawnow ;
41
42% --------------------------------------------------------------------
43%                                               test thin-plate spline
44% --------------------------------------------------------------------
45Y= [xc(:)';yc(:)'] ;
46U = tps(x,y,Y) ;
47Y0=Y ;
48
49figure(101);clf ;
50for i=1:10
51  % backward projection of dense grid
52  [wx,wy] = wtps(U,Y) ;
53  J = imwbackward(1:N,1:M,I,wx,wy);
54
55  % forward projection of control grid
56  [xg,yg]=witps(xc,yc,Y0,Y) ;
57
58  % change TPS randomly
59  Y=Y+3*randn(size(Y)) ;
60
61  % plot deformend image and grid
62  tightsubplot(10,i) ;imagesc(J) ;colormap gray; hold on ;
63  plotgrid(xg,yg,'color','g','linewidth',4) ; axis off ;
64end
Note: See TracBrowser for help on using the repository browser.