-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplate49_obj.m
More file actions
105 lines (100 loc) · 2.4 KB
/
Copy pathplate49_obj.m
File metadata and controls
105 lines (100 loc) · 2.4 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
function obj = plate49_obj(row, col, N, sg)
obj = zeros([N N]);
x = -N/2:N/2-1;
[xx, yy] = meshgrid(x, x);
spacing = 58;
x1 = -N/2:spacing:N/2;
[px, py] = meshgrid(x1, x1);
r_circle = 5;
r_circle2 = 10;
obj_funct1 = @() draw_circle(xx, yy, r_circle, sg);
obj_funct3 = @() draw_circle(xx, yy, r_circle2, sg);
if(row == 1 && col == 1)
magx = 1;
magy = 0.25;
probx = 0;
proby = .25;
elseif(row == 1 && col == 2)
magx = 0;
magy = 0.25;
probx = 0;
proby = 0.75;
elseif(row == 1 && col == 3)
magx = 0;
magy = 0.5;
probx = 0;
proby = 0.25;
elseif(row == 2 && col == 1)
magx = 0.25;
magy = 0;
probx = 0.25;
proby = 0;
elseif(row == 2 && col == 2)
magx = 0.25;
magy = 0;
probx = 0.5;
proby = 0;
elseif(row == 2 && col == 3)
magx = 0.5;
magy = 0;
probx = 0.25;
proby = 0;
elseif(row == 3 && col == 1)
magx = 0.25;
magy = 0.25;
probx = 0.25;
proby = 0.25;
elseif(row == 3 && col == 2)
magx = 0.25;
magy = 0.25;
probx = 0.75;
proby = 0.75;
elseif(row == 3 && col == 3)
magx = 0.5;
magy = 0.25;
probx = 0.25;
proby = 0.25;
elseif(row == 4 && col == 1)
magx = 0.25;
magy = 0.5;
probx = 0.25;
proby = 0.25;
elseif(row == 4 && col == 2)
magx = 0.5;
magy = 0.5;
probx = 0.25;
proby = 0.25;
elseif(row == 4 && col == 3)
magx = 0.5;
magy = 0.5;
probx = 0.75;
proby = 0.75;
end
count = 1;
for i = 1:size(px, 1)
for j = 1:size(px, 2)
if(count <= 4)
obj = obj + imtranslate(obj_funct1(), [px(i, j), py(i, j)], 'bilinear');
count = count + 1;
else
rand_offsetx = rand(1,1)*spacing*magx;
rand_offsety = rand(1,1)*spacing*magy;
if(rand(1,1) <= probx)
if(rand(1,1) <= proby)
obj = obj + imtranslate(obj_funct3(), [px(i, j)+rand_offsetx, py(i, j)+rand_offsety], 'bilinear');
count = count - 1;
else
obj = obj + imtranslate(obj_funct3(), [px(i, j)+rand_offsetx, py(i, j)], 'bilinear');
count = count - 1;
end
elseif(rand(1,1) <= proby)
obj = obj + imtranslate(obj_funct3(), [px(i, j), py(i, j)+rand_offsety], 'bilinear');
count = count - 1;
else
obj = obj + imtranslate(obj_funct3(), [px(i, j), py(i, j)], 'bilinear');
count = count - 1;
end
end
end
end
end