Here's a copy of an email I distributed today that describes the centroid and simulation code I wrote.
I've written some code that generates an image of Gaussian spots and provides you with the coordinates of the centers used to generate those spots. There is the facility to turn on i) photo-electron shot noise, ii) random displacement of the nominal positions of the centers from a regular array and iii) 12-bit digitization to more accurately model the output from a CCD.
I've included an example routine that calls this function and then centroids those spots using a variant of your centroiding algorithm.
You should be able to use this to generate reliable simulated data to test versions of your centroiding algorithm.
1. test_spot_generation_and_centroiding.m - the example routine. Run this first
2. generate_simulated_spots.m - the function to generate the simulated spots in an image and as a set of positions
3. centroid_image.m - the function to centroid an image
function output = generate_simulated_spots(npixels, digitizeFLAG, ...
% a function to generate an image of spots to centroid and to provide the original
% locations of the spots.
% npixels - pixels in output image
% digitizeFLAG: 0 - floating point array is output
function centroids = centroid_image(image, centroids)
% This function centroids a supplied image. It returns a centroids structure
% 'centroids' structure
% centroids.image_background_level - the background intensity of an image
% with no illumination on it
% .spot_radius - the radius of a hartmann spot
% .spot_threshold_level - the minimum intensity of pixels used to