function [my, mx] = getBallCenters(image, points, num)

ImageRGB = image;

% get original RGB image from edges 
% files where has been kept public
Im = rgb2gray(image);
Im = double(Im) / 255;  

% get image created by edges and invert colors
Edge = edge(Im, 'canny', [.04 .07], 1.4);

% Change image region of interest

BW = roipoly(ImageRGB, points(:, 1), points(:, 2));
Edge = double(Edge) .* double(BW);

[cnt, E] = hough_final(Edge, points);

temp = zeros(1, 2);
% Detect if image has rgb components for each pixel
temp = size(size(image));

% Draw an overlay of the original image
% end the detected circles and their center
s = size(E);
for i = 2 : s(1) - 1
    for j = 2 : s(2) - 1
        
        if (E(i, j) == 1)
            
            if temp(2) == 3
                ImageRGB(i, j, 1) = 255;
                ImageRGB(i, j, 2) = 0;
                ImageRGB(i, j, 3) = 0;
            else
                ImageRGB(i, j) = 0;
            end
            
        end
        
    end
end

imwrite(ImageRGB, ['out' int2str(num) '.jpg']);

figure('color', 'w');
imshow(ImageRGB);
hold on;
% draw table boundaries
tx = [points(:, 1)' points(1, 1)'];
ty = [points(:, 2)' points(1, 2)'];
plot(tx, ty, 'g-', 'linewidth', 3);
% draw ball centers
[my, mx] = find(cnt);
plot(mx, my, 'o', 'MarkerEdgeColor', 'r', 'MarkerFaceColor', 'g', 'MarkerSize', 5);

 

