j'ai une image IRM, je veux modéliser son histogramme par une mélange gaussienne. sachant que l'histogramme présente trois pics, c a d il faut trois gaussiennes pouar la modélisation. svp vous pouvez m'aider comment débuter le code. merci
j'ai une image IRM, je veux modéliser son histogramme par une mélange gaussienne. sachant que l'histogramme présente trois pics, c a d il faut trois gaussiennes pouar la modélisation. svp vous pouvez m'aider comment débuter le code. merci
Bonjour,
Le sujet n'est pas des plus clair. Peux tu expliquer plus en détail ? Eventuellement avec des schémas?
Qu'est-ce que l'histogramme d'un IRM?
Qu'est-ce que tu appelles mélange gaussienne?
Comment peux tu savoir que l'histogramme présente 3 pics alors que c'est ce que tu désires modéliser?
Si vous cherchez des réponses sur ce forum il faudra avant tout expliquer clairement votre problème et exposer la démarche que vous avez entreprise pour le résoudre. Fournissez une base de travail et de réflexion à vos interlocuteurs!
bonjour
j'ai deux images cérébrales IRM , je veux les fusionner par la méthode probabiliste, pour cela je commence par prétraiter ces images(filtrage et recalage) ensuite, aprés segmenation par kmeans, je veux modéliser ses histogrammes par la mélange des gaussiennes.
par exemple: l'histogramme de IRM1 présente deux bosses, je veux les modéliser par la somme de deux gaussiennes.j'utilise ce code:
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295 function [em_thr,em_thr_behavior,P,Mean,Std,pdf_x,xx,pdf_xx,cdf_xx,P_0] = em_1dim(x,nr_groups,fig_nr,P_0,max_nr_it); % [COLOR="#FF0000"][COLOR="#FF0000"][COLOR="#FF0000"][COLOR="#FF0000"] Syntax: % % [mixture_parameters,mixture_density] = em_1dim(x,nr_groups,fig_nr,P_0,max_nr_it); % % EM algo for 1-dimensional Gaussian Mixture Model % % INPUT: % ------- % % x = data with [nr_pts,nr_dim] = size(x) % % nr_groups = number of Gaussians % % P_0 = (OPTIONAL) initial soft assignment of data points to different clusters % (matrix of size = (nr_pts,k) % If omitted, we use either % * k-means to divide group in approx equal parts % * or home-made function (see end-of-file) to divide RANGE in % equal parts (this should be beneficial for distributions % that have long tails). % % OUTPUT: % ------- % % mixture_parameters = structure that contains the Gaussian Mixture parameters: % mixture_parameters.props = priors for each gaussian (size = [nr_gauss,1]); % mixture_parameters.means = means for each gaussian (size = [nr_gauss,1]); % mixture_parameters.stds = std for each gaussian (size = [nr_gauss,1]); % % mixture_density = structure that contains various density components for plotting: % % mixture_density.xplot : x-values for plotting % mixture_density.pdf : pdf values for plotting; % mixture_density.cdf : cdf values for plotting; % % % % History: % THIS IS SPECIALIZATION OF THE GENERAL "em_ndim.m" algorithm FOR 1-DIM % DATA (CREATED: 26 Nov 2003, EP) % % 8 feb 04: eliminated potential "divide by zero" problem when % renormalizing P (EP) % 11 may 04: streamlined output (more extensive original version: em_1dim_extra.m) % em_thr = 0; em_thr_behavior = 0; plot_ind = 0; % Define default values wherever needed. if size(x,1) < size(x,2), x = x'; end % turn into column if need be nr_pts = length(x); if nargin < 3, fig_nr = 0; end % default: no plotting if nargin < 4 % construct initial assignment -----(-5) if 0 %nr_groups > 1 % use K-means to divide dataset in equal GROUPS P_0 = zeros(nr_pts,nr_groups); disp('Creating initial assignment based on k-means clustering') [cluster_thr,cluster_label] = k_means_cluster_1dim(x,nr_groups); for j = 1:nr_groups zz = find(cluster_label==j); P_0(zz,j) = 1; end elseif nr_groups >1 % divide RANGE in equal parts P_0 = initialize_em_range_based(x,nr_groups); % See end of this file else % only one group: trivial assignment P_0 = ones(nr_pts,1); end end %----------------------------------------(-5) if nargin < 5 max_nr_it = 1000; end P = P_0; Mean = zeros(nr_groups,1); Std = ones(nr_groups,1); green_light = 1; nr_it = 0; while (green_light == 1) & (nr_it < max_nr_it) % begin---------------(100) nr_it = nr_it + 1; P_new = zeros(size(P)); for k = 1 : nr_groups %--------------------------(50) PP = P(:,k); D = x.* PP; % Data weighted with P-matrix if sum(P(:,k)) ~=0 % there are datapoints assigned to this group mean_grp = sum(D)/sum(PP); var_grp = sum(((x - mean_grp).^2).*PP)/sum(PP); % should this be sum(PP)-1 ?? std_grp = sqrt(var_grp); else mean_grp = 0; std_grp = 1; end F = normpdf(x,mean_grp,std_grp); Mean(k,:) = mean_grp; Std(k,:) = std_grp(:)'; P_new(:,k) = F; end %--------------------------(50) P_old = P; P = P_new; % Renormalize P_sum = sum(P,2); PP_sum = P_sum *ones(1,nr_groups); % Precautions to avoid "divide by zero" u_zero = find(P_sum < 10^(-200)); % if ~isempty(u_zero) % create uniform distribution Q = zeros(nr_pts,nr_groups); Q(u_zero,:) = 1/nr_groups; N = ones(nr_pts,nr_groups); N(u_zero,:)=0; PP_sum(u_zero,:) = 1; P = (P./PP_sum).*N + Q; else P = P./(sum(P,2)*ones(1,nr_groups)); % end if sum(sum(abs(P-P_old))) < 0.001*nr_pts % disp(['Convergence occurred after ' int2str(nr_it) ' iterations']) green_light = 0; end end % end -------------------------------------------(100) % Compute stuff to SHOW DENSITY if requested %=========================================== r = range(x); dx = r/250; xx = (min(x)-0.05*r:dx:max(x)+0.05*r); gx = zeros(nr_groups,length(x)); g = zeros(nr_groups,length(xx)); G = zeros(nr_groups,length(xx)); s = sum(P,1); s = s/sum(s); for i = 1:nr_groups g(i,:) = s(i)*(normpdf(xx,Mean(i),Std(i))); G(i,:) = s(i)*(normcdf(xx,Mean(i),Std(i))); gx(i,:) = s(i)*(normpdf(x',Mean(i),Std(i))); end g_tot = sum(g,1); gx_tot = sum(gx,1); G_tot = sum(G,1)/nr_pts; pdf_x = gx_tot; pdf_xx = g_tot; cdf_xx = G_tot; if fig_nr > 0 figure(fig_nr), clf hold on for k = 1:nr_groups plot(xx,g(k,:),'b') end plot(xx,pdf_xx,'r'),title('EM-based Gaussian Mixture density') hold off drawnow end % % PACKAGE RESULTS FOR EXPORT %=========================== % P is matrix of size [nr_pts,nr_gauss] such that each row contains the % soft assignment of the corresponding point to the different Gaussian components. % By summing over the rows, we get the proportional contribution of each % Gaussian. props = sum(P,1); props = props'/nr_pts; mixture_parameters.props = props; mixture_parameters.means = Mean; mixture_parameters.stds = Std; % % thresholds.vals = em_thr; % thresholds.behavior = em_thr_behavior; % % local_mins.xvals = xmin; % local_mins.fvals = fmin; % local_mins.quality = qmin; mixture_density.xplot = xx; mixture_density.pdf = pdf_xx; mixture_density.cdf = cdf_xx; % PLOT RESULTING DENSITY ON REQUEST if plot_ind == 1 [nbin,xbin]=hist(x,30); dxbin = xbin(2)-xbin(1); total_mass = sum(nbin).*dxbin; figure(fignr), hist(x,30); hold on plot(xx,total_mass*pdf_xx,'r') title('Proposed GMM density') hold off drawnow end return %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function P_0 = initialize_em_range_based(x,nr_groups) % divide the range up in equal parts (rather than the dataset itself, as is % done by k-means). % This should favour the creation of groups in long and slender tails nr_pts = length(x); P_raw = zeros(nr_pts,nr_groups); xrange = range(x); dx = xrange/(nr_groups-1); ss = 0.5*xrange/(2*(nr_groups-1)); xc = min(x) + dx*(0:nr_groups-1); for j = 1:nr_groups P_raw(:,j) = normpdf(x,xc(j),ss); end % make sure each row sums to 1: P_0 = P_raw./(sum(P_raw,2)*ones(1,nr_groups)); return %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % TEST SUITE % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% n = 300; % sample size x1 = randn(n,1); x2 = 0.5*randn(n,1)+3; x = [x1; x2]; % mixture of two gaussians figure(1), hist(x,30); title('Input data') drawnow nr_gauss = 4 [mixture_parameters,mixture_density] = em_1dim(x,nr_gauss,77); disp(['Extracted number of Gaussians: ' int2str(nr_gauss)])
mais je peux pas l'appliquer sur un histogramme d'une image, pouvez vous m'aider svp.
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager