FACT++  1.0
int FilterLed::GetMeanPositionBox ( const int  x,
const int  y,
const int  boxx,
const int  boxy,
float &  mx,
float &  my,
unsigned int &  sum 
) const
private

Definition at line 277 of file FilterLed.cc.

References ClusterFinder::FindClusterAt(), ClusterFinder::GetSumX(), ClusterFinder::GetSumY(), mag, ClusterFinder::SetLimitingSize(), and ClusterFinder::SetRange().

280 {
281  //-------------------------------
282  // Improved algorithm:
283  // 1. Look for the largest five-pixel-cross signal inside the box
284  int x0 = max(x-boxx+1, 0);
285  int y0 = max(y-boxy+1, 0);
286 
287  int x1 = min(x+boxx+1-1, fW);
288  int y1 = min(y+boxy+1-1, fH);
289 
290  int maxx=0;
291  int maxy=0;
292 
293  unsigned int max =0;
294  for (int dx=x0; dx<x1; dx++)
295  {
296  for (int dy=y0; dy<y1; dy++)
297  {
298  const unsigned int sumloc =
299  fImg[(dy+0)*fW + (dx-1)] +
300  fImg[(dy+0)*fW + (dx+1)] +
301  fImg[(dy+1)*fW + dx] +
302  fImg[(dy+0)*fW + dx] +
303  fImg[(dy-1)*fW + dx];
304 
305  if(sumloc<=max)
306  continue;
307 
308  maxx=dx;
309  maxy=dy;
310  max =sumloc;
311  }
312  }
313 
314  // 2. Calculate mean position inside a circle around
315  // the highst cross-signal with radius of 6 pixels.
316  ClusterFinder find(fImg, fW, fH);
317  find.SetLimitingSize(9999);
318  find.SetRange(x0, y0, x1, y1);
319 
320  const float mag = find.FindClusterAt(maxx, maxy);
321 
322  mx = find.GetSumX()/mag;
323  my = find.GetSumY()/mag;
324 
325  sum = (int)(mag+0.5);
326 
327  return (int)my*fW + (int)mx;
328 }
int fH
Definition: FilterLed.h:14
float mag
Definition: HeadersSQM.h:89
int fW
Definition: FilterLed.h:13
uint8_t * fImg
Definition: FilterLed.h:12

+ Here is the call graph for this function: