]> AND Private Git Repository - these_gilles.git/blob - THESE/codes/meanshift/Ms_segmenter/M_shift1.m
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
7 avril pour jury
[these_gilles.git] / THESE / codes / meanshift / Ms_segmenter / M_shift1.m
1 function [Mode, Number_values] = M_shift1 (Values, Window_radius, Initial)\r
2 % assumes that Values contains cumulative information, i.e.\r
3 % the number of elements of the particular value in each Values cell\r
4 \r
5 Current_val = round(Initial+2);\r
6 Next_val = round(Initial);\r
7 L = size(Values, 2);\r
8 \r
9 % global plot_number plot_xmin plot_xmax plot_ymin plot_ymax\r
10 % if plot_number == 1\r
11 %       figure;\r
12 % end\r
13 % II = find(Values > 0);\r
14 % if plot_number == 1\r
15 %       plot_xmin = min(II)-Window_radius/2;\r
16 %       plot_xmax = max(II)+Window_radius/2;\r
17 %       plot_ymin = min(Values)-Window_radius/2;\r
18 %       plot_ymax = max(Values)+Window_radius/2;\r
19 % end\r
20 % subplot(2, 2, plot_number);\r
21 % plot(Values, '.');\r
22 % xlabel('feature space (intensity)');\r
23 % ylabel('density');\r
24 % axis([plot_xmin plot_xmax plot_ymin plot_ymax])\r
25 % text(Next_val+Window_radius, Values(Next_val)-Window_radius/4, 'Initial');\r
26 \r
27 while abs(Next_val-Current_val) > 1\r
28 \r
29 %       Draw_rect(1.8*Window_radius, Window_radius, [Next_val, Values(Next_val)], 'magenta');\r
30 \r
31         Current_val = Next_val;\r
32    Range = [max(1, Current_val-Window_radius): ...\r
33       min(L, Current_val+Window_radius)];\r
34    Window = Values(Range);\r
35    Sum_values = full(Window * Range');\r
36    Number_values = full(sum(Window));\r
37    if Number_values > 0\r
38       Next_val = round(Sum_values/Number_values);\r
39    end\r
40 end\r
41 Mode = Next_val;\r
42 \r
43 % text(Next_val+Window_radius, Values(Next_val)+Window_radius/4, 'Final');\r
44 % plot_number = plot_number + 1;\r