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: 34     Entry time: Thu May 6 21:32:26 2010     Reply to this: 35
Author: Won Kim 
Type: Computing 
Category: Hartmann sensor 
Subject: Peak detection and centroiding code 



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: detect_peaks_uml.m  787 Bytes  Uploaded Thu May 6 22:57:59 2010  | Show | Show all
ELOG V3.1.3-