% assumes upper left corner is at 1,1
function [x y] = find_centroid(img)

[ii jj] = find(img(:,:,1) == 255);
x = sum(jj) / size(jj, 1);
y = sum(ii) / size(ii, 1);

%figure; image(img); rectangle('Position', [x-2 y-2 4 4]);