Bonjour les gens,
Voila j'ai codé un débruitage d'image à partir de transformée en ondelettes, mais comme j'ai un peu codé comme un bourrin, je ne peux pas dépasser des images 2048*2048, autrement c'est out of memory. Je mets le code, si quelqu'un a une suggestion. Merki

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
 
function [w]= transfo_des_indiens (X);
X;
[m,n]=size(X);
%décomposition de la matrice image par une transformée discrète en
%ondelettes
%ici la décomposition s'effectue sur 5 niveaux
[A1,H1,V1,D1]=swt2(B,1,'bior3.3');
[A2,H2,V2,D2]=swt2(A1,1,'bior3.3');
[A3,H3,V3,D3]=swt2(A2,1,'bior3.3');
[A4,H4,V4,D4]=swt2(A3,1,'bior3.3');
[A5,H5,V5,D5]=swt2(A4,1,'bior3.3');
%fin de la décompostition
 
%moyennage des composantes détaillées des cinq niveaux(réduction du
%speckle)
%On commence par traiter les composantes du niveau 5
for i=1:m;
    Mh5= mean(H5(i,1:n));
    Mv5= mean(V5(i,1:n));
    Md5= mean(D5(i,1:n));
    for j=1:n;
    if abs(H5(i,j))<abs(Mh5);
        H5(i,j)=H5(i,j);
    else
        H5(i,j)=Mh5;
    end
    if abs(V5(i,j))<abs(Mv5);
        V5(i,j)=V5(i,j);
    else
        V5(i,j)=Mv5;
    end
    if abs(D5(i,j))<abs(Md5);
        D5(i,j)=D5(i,j);
    else
        D5(i,j)=Md5;
    end
    end
end
 
%transformation inverse, passage du niveau de décomposition 5 au niveau de
%décomposition 4
At4=iswt2(A5,H5,V5,D5,'bior3.3');
 
%réduction du speckle sur les coefficients de la décomposition au niveau 4
for i=1:m;
    Mh4= mean(H4(i,1:n));
    Mv4= mean(V4(i,1:n));
    Md4= mean(D4(i,1:n));
    for j=1:n;
    if abs(H4(i,j))<abs(Mh4);
        H4(i,j)=H4(i,j);
    else
        H4(i,j)=Mh4;
    end
    if abs(V4(i,j))<abs(Mv4);
        V4(i,j)=V4(i,j);
    else
        V4(i,j)=Mv4;
    end
    if abs(D4(i,j))<abs(Md4);
        D4(i,j)=D4(i,j);
    else
        D4(i,j)=Md4;
    end
    end
end
 
%transformation inverse, passage du niveau de décomposition 4 au niveau de
%décomposition 3
At3=iswt2(At4,H4,V4,D4,'bior3.3');
 
%réduction du speckle sur les coefficients de la décomposition au niveau 3
for i=1:m;
    Mh3= mean(H3(i,1:n));
    Mv3= mean(V3(i,1:n));
    Md3= mean(D3(i,1:n));
    for j=1:n;
    if abs(H3(i,j))<abs(Mh3);
        H3(i,j)=H3(i,j);
    else
        H3(i,j)=Mh3;
    end
    if abs(V3(i,j))<abs(Mv3);
        V3(i,j)=V3(i,j);
    else
        V3(i,j)=Mv3;
    end
    if abs(D3(i,j))<abs(Md3);
        D3(i,j)=D3(i,j);
    else
        D3(i,j)=Md3;
    end
    end
end
 
%transformation inverse, passage du niveau de décomposition 3 au niveau de
%décomposition 2
At2=iswt2(At3,H3,V3,D3,'bior3.3');
 
%réduction du speckle sur les coefficients de la décomposition au niveau 2
for i=1:m;
    Mh2= mean(H2(i,1:n));
    Mv2= mean(V2(i,1:n));
    Md2= mean(D2(i,1:n));
    for j=1:n;
    if abs(H2(i,j))<abs(Mh2);
        H2(i,j)=H2(i,j);
    else
        H2(i,j)=Mh2;
    end
    if abs(V2(i,j))<abs(Mv2);
        V2(i,j)=V2(i,j);
    else
        V2(i,j)=Mv2;
    end
    if abs(D2(i,j))<abs(Md2);
        D2(i,j)=D2(i,j);
    else
        D2(i,j)=Md2;
    end
    end
end
 
%transformation inverse, passage du niveau de décomposition 2 au niveau de
%décomposition 1
At1=iswt2(At2,H2,V2,D2,'bior3.3');
 
%réduction du speckle sur les coefficients de la décomposition au niveau 1
for i=1:m;
    Mh1= mean(H1(i,1:n));
    Mv1= mean(V1(i,1:n));
    Md1= mean(D1(i,1:n));
    for j=1:n;
    if abs(H1(i,j))<abs(Mh1);
        H1(i,j)=H1(i,j);
    else
        H1(i,j)=Mh1;
    end
    if abs(V1(i,j))<abs(Mv1);
        V1(i,j)=V1(i,j);
    else
        V1(i,j)=Mv1;
    end
    if abs(D1(i,j))<abs(Md1);
        D1(i,j)=D1(i,j);
    else
        D1(i,j)=Md1;
    end
    end
end
 
%Dernière transformation inverse pour avoir l'image débruitée, puis
%affichage du résultat
Xt=iswt2(At1,H1,V1,D1,'bior3.3');
n=256;
map2=gray(n);
subplot(211); image(B);colormap(map2);
subplot(212); image(Xt);colormap(map2);
w=Xt;