forked from minoue-xx/digital-art-with-matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdfltimg_parallax.m
62 lines (44 loc) · 1.23 KB
/
dfltimg_parallax.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function dfltimg_parallax()
% Get the default image cdata and display 4 images in a rotating cube.
I = get(groot,'defaultimageCData');
defimage = pow2(I,47);
% Compute the images from the default CData
I1 = bitslice(defimage,42,46);
I2 = bitslice(defimage,37,41);
I3 = bitslice(defimage,47,51);
I4 = bitslice(defimage,5,8);
set(gca,'PositionConstraint','innerposition')
% Display a transition for each image in sequence.
parallaxPlot(I1,I2);
pause(1)
paratwist
parallaxPlot(I2,I3);
pause(1)
paratwist
parallaxPlot(I3,I4);
pause(1)
paratwist
parallaxPlot(I4,I1);
pause(1)
paratwist
end
function paratwist()
% Rotate the axes to show off the paralax thing...
for idx=linspace(0,90,50)
view([ idx (cosd(idx*4)-1)*5 ]);
drawnow
end
end
function b = bitslice(a,lowbit,highbit)
% BITSLICE(A,LOWBIT,HIGHBIT)
%
% Scales return values so that the maximum is 1.0.
b = a / 2^(lowbit);
b = fix(b);
b = b / 2^(highbit - lowbit + 1);
b = b - fix(b);
b = b / max(b(:));
% To work with parallaxPlot, pull up only the brightest pixels.
b = floor(b*1.8);
b([end 1]) = 1;
end