CFEL - ASG Software Suite  2.5.0
CASS
pixel_finder_simple.cpp
Go to the documentation of this file.
1 // Copyright (C) 2011 Lutz Foucar
2 
3 /**
4  * @file pixel_finder_simple.cpp contains pixel finder that works like Per Johnsons
5  *
6  * @author Lutz Foucar
7  */
8 
9 #include "pixel_finder_simple.h"
10 
11 #include "cass_settings.h"
12 #include "advanced_pixeldetector.h"
13 
14 using namespace cass;
15 using namespace pixeldetector;
16 using namespace std;
17 
19 {
20 
21 }
22 
24 {
25  size_t idx(0);
26  Detector::frame_t::const_iterator pixel(frame.data.begin());
27  for (;pixel != frame.data.end(); ++pixel)
28  {
29  const uint16_t x(idx % frame.columns);
30  const uint16_t y(idx / frame.columns);
31  if (*pixel > _threshold &&
32  //check wether point is not at an edge
33  y > 0 &&
34  y < frame.rows-1 &&
35  x > 0 &&
36  x < frame.columns+1 &&
37  // Check all surrounding pixels
38  frame.data[idx-frame.columns-1] < *pixel && //upper left
39  frame.data[idx-frame.columns] < *pixel && //upper middle
40  frame.data[idx-frame.columns+1] < *pixel && //upper right
41  frame.data[idx-1] < *pixel && //left
42  frame.data[idx+1] < *pixel && //right
43  frame.data[idx+frame.columns-1] < *pixel && //lower left
44  frame.data[idx+frame.columns] < *pixel && //lower middle
45  frame.data[idx+frame.columns+1] < *pixel) //lower right
46  {
47  pixels.push_back(Pixel(x,y,*pixel));
48  }
49  ++idx;
50  }
51  return pixels;
52 }
53 
55 {
56  s.beginGroup("SimpleFinder");
57  _threshold = s.value("Threshold",0).toUInt();
58  s.endGroup();
59 }
60 
61 
63 {
64 
65 }
66 
68 {
69  size_t idx(0);
70  Detector::frame_t::const_iterator pixel(frame.data.begin());
71  for (;pixel != frame.data.end(); ++pixel)
72  {
73  const uint16_t x(idx % frame.columns);
74  const uint16_t y(idx / frame.columns);
75  //not at edges
76  if (*pixel > _threshold &&
77  y > _squaresize-1 &&
78  y < frame.rows-_squaresize &&
79  x > _squaresize-1 &&
80  y < frame.columns-_squaresize)
81  {
82  //check surrounding pixels
83  bool pixelIsLocalMaximum(true);
84  for (int squareRow=-_squaresize; squareRow <= _squaresize; ++squareRow)
85  {
86  for (int squareCol=-_squaresize; squareCol <= _squaresize; ++squareCol)
87  {
88  if (!(squareRow == 0 && squareCol == 0))
89  pixelIsLocalMaximum = pixelIsLocalMaximum && (frame.data[idx + squareRow*frame.columns + squareCol] < *pixel);
90  }
91  }
92  if (pixelIsLocalMaximum)
93  {
94  pixels.push_back(Pixel(x,y,*pixel));
95  }
96  }
97  ++idx;
98  }
99  return pixels;
100 }
101 
103 {
104  s.beginGroup("SimpleFinder");
105  _threshold = s.value("Threshold",0).toUInt();
106  _squaresize = s.value("SquareSize",1).toUInt();
107  s.endGroup();
108 }
109 
110 
111 
113 {}
114 
116 {
117  Detector::frame_t::const_iterator pixel(frame.data.begin());
118  Detector::frame_t::const_iterator end(frame.data.end());
119  size_t idx(0);
120  for (; pixel != end; ++pixel, ++idx)
121  {
122 // cout << *pixel<<" " << _range.first<<" "<< _range.second<<" "<< (_range.first < *pixel && *pixel < _range.second) << endl;
123  if(_range.first < *pixel && *pixel < _range.second)
124  {
125  const uint16_t x(idx % frame.columns);
126  const uint16_t y(idx / frame.columns);
127  pixels.push_back(Pixel(x,y,*pixel));
128  }
129  }
130  return pixels;
131 }
132 
134 {
135  s.beginGroup("InRangeFinder");
136  _range = make_pair(s.value("LowerThreshold",0).toFloat(),
137  s.value("UpperThreshold",1e6).toFloat());
138  s.endGroup();
139 }
Settings for CASS.
Definition: cass_settings.h:30
void loadSettings(CASSSettings &s)
load the settings of this
STL namespace.
void loadSettings(CASSSettings &s)
load the settings of this
pixels_t & operator()(const Frame &frame, pixels_t &pixels)
find the pixels
std::vector< Pixel > pixels_t
the list of pixels
uint16_t columns
how many columns
value(const QString &key, const QVariant &defaultValue=QVariant()
pixels_t & operator()(const Frame &frame, pixels_t &pixels)
find the pixels
A Frame of an advance Pixel Detector.
Detector::frame_t data
the frame data
file contains specialized class that do the settings for cass
contains pixel finder that works like Per Johnsons
advanced pixeldetectors
int16_t pixel
define a pixel
Definition: hlltypes.hpp:27
pixels_t & operator()(const Frame &frame, pixels_t &pixels)
find the pixels
beginGroup(const QString &prefix)
void loadSettings(CASSSettings &s)
load the settings of this