Repository navigation
Expand file tree
/
Copy pathLocalisationFormesParCorrelation.m
More file actions
130 lines (104 loc) · 2.88 KB
/
Copy pathLocalisationFormesParCorrelation.m
File metadata and controls
130 lines (104 loc) · 2.88 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
function[]=LocalisationFormesParCorrelation()
%Creation de la matrice 1024 contenant la forme 'n'
n=zeros(1024);
nTemp=255*[1 1 1 1 1 1 1 0;
0 1 1 1 1 1 1 1;
0 0 1 1 0 0 1 1;
0 0 1 1 0 0 1 1;
0 0 1 1 0 0 1 1;
0 0 1 1 0 0 1 1;
0 1 1 0 0 0 1 1];
for i=1:7
for j=1:8
n(i,j)=nTemp(i,j);
end
end
%Creation de la matrice 1024 contenant la forme '?'
interro=zeros(1024);
interroTemp=255*[0 0 1 1 1 1 0 0;
0 1 1 1 1 1 1 0;
1 1 0 0 0 0 1 1;
0 0 0 0 0 0 1 1;
0 0 0 0 0 1 1 0;
0 0 0 0 1 1 0 0;
0 0 0 1 1 0 0 0;
0 0 0 1 1 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 1 1 0 0 0;
0 0 0 1 1 0 0 0];
for i=1:11
for j=1:8
interro(i,j)=interroTemp(i,j);
end
end
%Creation de la matrice 1024 contenant la forme '?inversé'
interroInv=zeros(1024);
interroInvTemp=255*[0 0 0 1 1 0 0 0;
0 0 0 1 1 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 1 1 0 0 0;
0 0 0 1 1 0 0 0;
0 0 1 1 0 0 0 0;
0 1 1 0 0 0 0 0;
1 1 0 0 0 0 0 0;
1 1 0 0 0 0 1 1;
0 1 1 1 1 1 1 0;
0 0 1 1 1 1 0 0];
for i=1:11
for j=1:8
interroInv(i,j)=interroInvTemp(i,j);
end
end
%Creation de la matrice 1024 contenant l image avec les formes a compter
[im, map]=imread('imageFormes.png');
%Representation de l'ensembles des matrices crees
subplot(2,4,1),image(n);
colormap(map);
subplot(2,4,2),image(interro);
colormap(map);
subplot(2,4,3),image(interroInv);
colormap(map);
subplot(2,4,4),image(im);
colormap(map);
%On inverse l'image
im=rot90(im,2);
%On calcule les transformees de fourier des matrices
N=fftshift(fft2(n));
INTERRO=fftshift(fft2(interro));
INTERROINV=fftshift(fft2(interroInv));
IM=fftshift(fft2(im));
%Produit de convolution
CONVN=N.*IM;
CONVINTERRO=INTERRO.*IM;
CONVINTERROINV=INTERROINV.*IM;
%Transformee inverse de fourier
convN=fftshift(ifft2(CONVN));
convInterro=fftshift(ifft2(CONVINTERRO));
convInterroInv=fftshift(ifft2(CONVINTERROINV));
subplot(2,4,5),plot(convN);
subplot(2,4,6),plot(convInterro);
subplot(2,4,7),plot(convInterroInv);
%Pour chaque max trouve, on implemente le nombre de forme
nbN=0;
nbInterro=0;
nbInterroInv=0;
maxN=max(max(convN));
maxInterro=max(max(convInterro));
maxInterroInv=max(max(convInterroInv));
for i=1:1024
for j=1:1024
if convN(i,j)>=0.98*maxN
nbN=nbN+1;
end
if convInterro(i,j)>=0.98*maxInterro
nbInterro=nbInterro+1;
end
if convInterroInv(i,j)>=0.98*maxInterroInv
nbInterroInv=nbInterroInv+1;
end
end
end
nbN
nbInterro
nbInterroInv
end