+function test_hough_ma(images_path, image_name)
+ i = imread([images_path image_name]);
+
+ green = i(:,:,2);
+ green_filtered = imgaussfilt(green, 1.0);
+ otsu = ~im2bw(green_filtered, graythresh(green_filtered));
+
+ se = strel('rectangle', [3 3]);
+ edges = imdilate(otsu, se) - imerode(otsu, se);
+
+ s = [-1 0 1; -2 0 2; -1 0 1];
+ x_edge = conv2(double(green_filtered), s, 'valid');
+ y_edge = conv2(double(green_filtered), s', 'valid');
+
+ magnitudes = sqrt(x_edge .^ 2 + y_edge .^ 2);
+
+ % Unit gradient.
+ x_dir = x_edge ./ magnitudes;
+ y_dir = y_edge ./ magnitudes;
+
+ disp('Applying Houg...');
+ tic
+ [acc_votes, acc_radius] = HTCircleMa(x_dir, y_dir, edges(2:end-1, 2:end-1), [25, 35]);
+ toc
+
+ disp('Finding ellipses...');
+ tic
+ ellipses = find_ellipses(acc_votes, acc_radius);
+ toc
+
+ name = ['Hough Ma - ' image_name];
+ show_figures(name,...
+ {{green_filtered, 'original filtered with a gaussian, sigma=1'},...
+ {edges, 'edges (otsu -> dilate - erode)'},...
+ {expand_matrix(x_edge), 'composante x du gradient'},...
+ {expand_matrix(acc_votes), 'votes'}}, green, ellipses);
+
+ f = figure;
+ img = green_filtered;
+ grayscale = linspace(0, 1, 255);
+ colormap([grayscale' grayscale' grayscale']);
+ img(~edges) = 0;
+ image(img);
+ axis image;
+ hold on;
+ [X, Y] = meshgrid(1:size(green, 2), 1:size(green, 1));
+ quiver(X, Y, expand_matrix(x_dir), expand_matrix(y_dir), 'Color', 'yellow');
+ savefig(['results/' name ' - gradient.fig']);
+end