-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawOnCanvas.m
116 lines (108 loc) · 3.92 KB
/
drawOnCanvas.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
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
106
107
108
109
110
111
112
113
114
115
116
function [canvas] = drawOnCanvas(canvas,centers,mask)
% * output : Canvas
% * input :
% - canvas : support des dessins de cercles
% - centers : centres de corr�lation
% - mask : masque pour le dessin du cercle
[L,H,~] = size(canvas);
border = (size(mask,1)-1)/2;
taille = size(mask,1); % +1
centers2 = floor(taille + centers)
HTop = floor(centers2(2) - border)
HBottom = floor(centers2(2) + border)
LTop = floor(centers2(1) - border)
LBottom = floor(centers2(1) + border)
% size1 = size(canvas(LTop:LBottom,HTop:HBottom,1));
% size2 = size(mask(1:size(mask,1),1:size(mask,2),1));
% canvas(LTop:LBottom,HTop:HBottom,:) = mask(1:size(mask,1),1:size(mask,2),:);
% for i = 1:1:size(mask,1)
% for j = 1:1:size(mask,2)
% if ( (canvas(LBottom+i,HTop+j,1) == 255) && (canvas(LBottom+i,HTop+j,2) == 255) && (canvas(LBottom+i,HTop+j,3) == 255) )
% if (mask(i,j,1) ~= 0)
% canvas(LBottom+i,HTop+j,:) = mask(i,j,:);
% end
% else
% if (mask(i,j,1) ~= 0)
% % canvas(LBottom+i,HBottom+j,:) = max( (canvas(LBottom+i,HBottom+j,:) + mask(i,j,:))/2, 255);
% canvas(LBottom+i,HTop+j,:) = (canvas(LBottom+i,HTop+j,:) + mask(i,j,:))/2;
% end
% end
% end
% end
% for i = 1:1:size(mask,1)
% for j = 1:1:size(mask,2)
% if ( (canvas(LTop+i,HTop+j,1) == 255) && (canvas(LTop+i,HTop+j,2) == 255) && (canvas(LTop+i,HTop+j,3) == 255) )
% if (mask(i,j,1) ~= 0)
% canvas(LTop+i,HTop+j,:) = mask(i,j,:);
% end
% else
% if (mask(i,j,1) ~= 0)
% % canvas(LTop+i,HTop+j,:) = max( (canvas(LTop+i,HTop+j,:) + mask(i,j,:))/2, 255);
% canvas(LTop+i,HTop+j,:) = (canvas(LTop+i,HTop+j,:) + mask(i,j,:))/2;
% end
% end
% end
% end
switch nComportement
case 0
for i = 1:1:size(mask,1)
for j = 1:1:size(mask,2)
canvas(LTop+i,HTop+j,:) = normal(mask(i,j,:)); % Doit-il y avoir un ',:' dans l'appel de `mask` ?
end
end
case 1
for i = 1:1:size(mask,1)
for j = 1:1:size(mask,2)
canvas(LTop+i,HTop+j,:) = fondu(mask(i,j,:));
end
end
case 2
for i = 1:1:size(mask,1)
for j = 1:1:size(mask,2)
canvas(LTop+i,HTop+j,:) = obscurcir(canvas(LTop+i,HTop+j,:),mask(i,j,:));
end
end
case 3
for i = 1:1:size(mask,1)
for j = 1:1:size(mask,2)
canvas(LTop+i,HTop+j,:) = produit(canvas(LTop+i,HTop+j,:),mask(i,j,:));
end
end
case 4
for i = 1:1:size(mask,1)
for j = 1:1:size(mask,2)
canvas(LTop+i,HTop+j,:) = eclaircir(canvas(LTop+i,HTop+j,:),mask(i,j,:));
end
end
case 5
for i = 1:1:size(mask,1)
for j = 1:1:size(mask,2)
canvas(LTop+i,HTop+j,:) = melange_max(canvas(LTop+i,HTop+j,:),mask(i,j,:));
end
end
case 6
for i = 1:1:size(mask,1)
for j = 1:1:size(mask,2)
canvas(LTop+i,HTop+j,:) = difference(canvas(LTop+i,HTop+j,:),mask(i,j,:));
end
end
case 7
for i = 1:1:size(mask,1)
for j = 1:1:size(mask,2)
canvas(LTop+i,HTop+j,:) = division(canvas(LTop+i,HTop+j,:),mask(i,j,:));
end
end
case 8
for i = 1:1:size(mask,1)
for j = 1:1:size(mask,2)
canvas(LTop+i,HTop+j,:) = couleur_plus_claire(canvas(LTop+i,HTop+j,:),mask(i,j,:));
end
end
case 9
for i = 1:1:size(mask,1)
for j = 1:1:size(mask,2)
canvas(LTop+i,HTop+j,:) = couleur_plus_sombre(canvas(LTop+i,HTop+j,:),mask(i,j,:));
end
end
end
end