-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.m
51 lines (41 loc) · 1.09 KB
/
demo.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
%b?y?tt?kten sonra cube ? crop ediyoruz quantize
%quzntize etmemiz gerekiyor
kernelx = [-1 0 1];
kernely = [-1 0 1]'; %kernelx';
kernelz = zeros(3,3,3);
kernelz(2,2,:) = [-1 0 1];
%Demo Sphere
sesize = 25;
sw=(sesize-1)/2;
ses2=ceil(sesize/2); % ceil sesize to handle odd diameters
[y,x,z]=meshgrid(-sw:sw,-sw:sw,-sw:sw);
m=sqrt(x.^2 + y.^2 + z.^2);
b=(m <= m(ses2,ses2,sesize));
se=strel('arbitrary',b);
sph = [se.getnhood];
dx = convn(sph, kernelx, 'same');
dy = convn(sph, kernely, 'same');
dz = convn(sph, kernelz, 'same');
%Cut-off noises
dx = dx(2:end-1, 2:end-1, 2:end-1);
dy = dy(2:end-1, 2:end-1, 2:end-1);
dz = dz(2:end-1, 2:end-1, 2:end-1);
mag = abs(dx) + abs(dy) + abs(dz);
ref = [1 0 0];
ori = zeros(size(dx));
for i = 1: size(dx, 1) * size(dy, 2) * size(dz, 3),
v = [dx(i) dy(i) dz(i)];
ori(i) = atan2(norm(cross(v,ref)),dot(v,ref));
end;
orsum = sum(ori ,3);
%Visualize
data = ori;
surfaceparam = 0;
p = patch(isosurface(data, surfaceparam));
isonormals(data,p)
p.FaceColor = 'red';
p.EdgeColor = 'none';
daspect([1,1,1])
view(3); axis tight
camlight
lighting gouraud