
% tally votes
svt = sparse(zeros(250*raster_res,250*raster_res));
im_dim = size(svt);
ll_r = min(real(thevotes));
ll_i = min(imag(thevotes));
rr_r = max([real(thevotes),ll_r+1]);
rr_i = max([imag(thevotes),ll_i+1]);
offset = -ll_r-ll_i*i;
scale_x = (im_dim(2)-1)/(rr_r-ll_r);
scale_y = (im_dim(1)-1)/(rr_i-ll_i);
for j=1:length(thevotes),
	spot = thevotes(j)+offset;
	s_x = floor(real(spot)*scale_x)+1;
	s_y = floor(imag(spot)*scale_y)+1;
	svt(s_y, s_x) = svt(s_y, s_x) + 1;
end

% blur svt
w_w = linspace(-4,4,20*raster_res);
[w_x,w_y] = meshgrid(w_w,w_w);
w_z = exp( -(w_x.^2 + w_y.^2)/(2*blur_var) );
%svt = conv2(full(svt), w_z, 'same');
	% 'same'=>don't change dimensions from svt, else we can't compute
	% correct axes

% find max index
[max_y, max_ind] = max(svt);		% brightest in each column
[maxx_y, maxx_ind] = max(max_y);	% column with brightest max
max_x = maxx_ind;
max_y = max_ind(max_x);
% put it back into original units

max_spot = ((max_x-0.5)/scale_x - real(offset)) +((max_y-0.5)/scale_y - imag(offset))*i;
