40m QIL Cryo_Lab CTN SUS_Lab TCS_Lab OMC_Lab CRIME_Lab FEA ENG_Labs OptContFac Mariner WBEEShop
  TCS elog  Not logged in ELOG logo
Entry  Thu May 6 21:32:26 2010, Won Kim, Computing, Hartmann sensor, Peak detection and centroiding code detect_peaks_uml.m
    Reply  Tue May 11 10:32:00 2010, Aidan, Computing, Hartmann sensor, Peak detection and centroiding code - review test_centroid_code.m
Message ID: 35     Entry time: Tue May 11 10:32:00 2010     In reply to: 34
Author: Aidan 
Type: Computing 
Category: Hartmann sensor 
Subject: Peak detection and centroiding code - review 

This looks really efficient! However, I think there's a systematic error in the calculation. I tested it on some simulated data and it had trouble getting the centroids exactly right. I need to better understand the functions that are called to get an idea of what might be the problem.





Attached is .m file of the custom function that I wrote and used to automatically detect peaks in a Hartmann image,
and calculate the centroid corrdinates of each of those peaks.

A simple example of its usage,  provided that myimage is a two-dimensional image array obtained from the camera, is


radius = 10;

peak_positions = detect_peaks_uml(myimage,radius);

no_of_peaks = length(peak_positions);

centroids_array = zeros(no_of_peaks);

for k = 1:no_of_peaks

  centroids_array(k,1) = peak_positions(k).WeightedCentroid(1);

  centroids_array(k,2) = peak_positions(k).WeightedCentroid(2);



I chose my value of radius by looking at spots in a sample image and counting the number of pixels across a peak. It may be 
more useful to automatically obtain a value for the
radius. I may run some tests to see how different choices of radius
affect the centroid calculations. 

I may also need to add some error checking and/or image validating codes, but so far I have not encountered any problems. 

Please let me know if anyone needs more explanation!





Attachment 1: test_centroid_code.m  1 kB  Uploaded Tue May 11 11:40:47 2010  | Hide | Hide all
% generate an blank image
imarr = zeros(1024, 1024);

% get the background and intensity levels
bckgrd = 700.0;
I1 = 56000.0;

% get the 2D coordinate arrays
x = 1:1024;
... 61 more lines ...
ELOG V3.1.3-