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
5 Current_val = round(Initial+2);
\r
6 Next_val = round(Initial);
\r
9 % global plot_number plot_xmin plot_xmax plot_ymin plot_ymax
\r
10 % if plot_number == 1
\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
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
27 while abs(Next_val-Current_val) > 1
\r
29 % Draw_rect(1.8*Window_radius, Window_radius, [Next_val, Values(Next_val)], 'magenta');
\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
43 % text(Next_val+Window_radius, Values(Next_val)+Window_radius/4, 'Final');
\r
44 % plot_number = plot_number + 1;
\r