FACT++  1.0
void FilterLed::Execute ( std::vector< Led > &  leds,
int  xc,
int  yc,
double &  bright 
) const

Definition at line 344 of file FilterLed.cc.

References ClusterFinder::FindCluster().

Referenced by MStarguider::ProcessFrame(), MCaos::Run(), and SetCut().

345 {
346  const int x0 = max(xc-fBoxX, 0);
347  const int y0 = max(yc-fBoxY, 0);
348  const int x1 = min(xc+fBoxX, fW);
349  const int y1 = min(yc+fBoxY, fH);
350 
351  const int wx = x1-x0;
352  const int hy = y1-y0;
353 
354  double sum = 0;
355  double sq = 0;
356 
357  for (int x=x0; x<x1; x++)
358  for (int y=y0; y<y1; y++)
359  {
360  uint8_t &b = fImg[y*fW+x];
361 
362  // Skip saturating pixels
363  if (b>0xf0)
364  continue;
365 
366  sum += b;
367  sq += b*b;
368  }
369 
370  sum /= wx*hy;
371  sq /= wx*hy;
372 
373  bright=sum;
374 
375 
376  // 254 because b<=max and not b<max
377  const double sdev = sqrt(sq-sum*sum);
378  const uint8_t max = sum+fCut*sdev>254 ? 254 : (uint8_t)(sum+fCut*sdev);
379 
380  //
381  // clean image from noise
382  // (FIXME: A lookup table could accelerate things...
383  //
384  for (int x=x0; x<x1; x++)
385  for (int y=y0; y<y1; y++)
386  {
387  uint8_t &b = fImg[y*fW+x];
388  if (b<=max)
389  b = 0;
390  }
391 
392  ClusterFinder find(fImg, fW, fH);
393  find.FindCluster(leds, x0, y0, x1, y1);
394 }
int fH
Definition: FilterLed.h:14
int fBoxY
Definition: FilterLed.h:16
int fBoxX
Definition: FilterLed.h:15
float fCut
Definition: FilterLed.h:17
int fW
Definition: FilterLed.h:13
uint8_t * fImg
Definition: FilterLed.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function: