CFEL - ASG Software Suite  2.5.0
CASS
rankfilter.h
Go to the documentation of this file.
1 // Copyright (C) 2010 Stephan Kassemeyer
2 
3 /** @file rankfilter.h file contains processors that will operate
4  * on histograms of other processors, calculating
5  * statistical rank filters like median filter.
6  * @author Stephan Kassemeyer
7  */
8 
9 #ifndef _RANKFILTER_H_
10 #define _RANKFILTER_H_
11 
12 #include <deque>
13 
14 #include "processor.h"
15 #include "cass_event.h"
16 #include "result.hpp"
17 
18 
19 namespace cass
20 {
21 /** calculate median of last values.
22  *
23  * @PPList "301": calculate median of last values
24  *
25  * If input histogram is > 0d, its values get
26  * summed up prior to median calculation.
27  *
28  * @see Processor for a list of all commonly available cass.ini
29  * settings.
30  *
31  * @cassttng Processor/\%name\%/{InputName} \n
32  * the processor name that contain the first histogram. Default
33  * is 0.
34  * @cassttng Processor/\%name\%/{MedianSize} \n
35  * how many last values should be included in median calculation.
36  * default is 100.
37  *
38  * @todo make more general: operate on bins. now operates on sum.
39  * @author Stephan Kassemeyer.
40  * @author Lutz Foucar
41  */
43 {
44 public:
45  /** constructor */
46  pp301(const name_t&);
47 
48  /** process event */
49  virtual void process(const CASSEvent&, result_t&);
50 
51  /** load the settings of this pp */
52  virtual void loadSettings(size_t);
53 
54 protected:
55  /** pp containing first histogram */
57 
58  /** last N items to be used for median calculation */
59  unsigned int _medianSize;
60 
61  /** storage of last values for median calculation */
62  std::deque<float> _medianStorage;
63 
64  /** mutex to lock the median storage */
66 };
67 
68 
69 
70 
71 
72 
73 /** load data from binary dump into 2DHistogram
74  *
75  * @PPList "302": load data from binary dump into 2DHistogram
76  *
77  * example python code to generate binary file:
78  *
79  * import numpy
80  * arr = numpy.zeros( (1024,1024), dtype=numpy.float32 )
81  * cord = numpy.mgrid[0:1024,0:1024]
82  * arr[ cord[0]**2+cord[1]**2 < 5000 ] = 1
83  * arr.tofile('waterJetMask.bin')
84  *
85  * import vigra
86  * import numpy
87  * arr = vigra.readImage('waterJetMask.png')
88  * arr = numpy.array( arr[:,:,0], dtype=numpy.float32 ) # only save one color channel
89  * arr /= 255 # rgb -> 0..1
90  * arr = arr.T # transpose image to match cass coordinate system
91  * arr.tofile('waterJetMask_png.bin')
92  *
93  *
94  * @see Processor for a list of all commonly available cass.ini
95  * settings.
96  *
97  * @cassttng Processor/\%name\%/{BinaryFile} \n
98  * Filename of binary float[sizeX*sizeY] file which contains data.
99  * Default is "".
100  *
101  * @cassttng Processor/\%name\%/{SizeX} \n
102  * nr of Pixels for x axis.
103  * Default is 0.
104  *
105  * @cassttng Processor/\%name\%/{SizeY} \n
106  * nr of Pixels for y axis.
107  * Default is 0.
108  *
109  * @author Stephan Kassemeyer
110  */
111 class pp302 : public Processor
112 {
113 public:
114  /** constructor */
115  pp302(const name_t&);
116 
117  /** overwrite default behaviour and just return the constant */
118  virtual const result_t& result(const CASSEvent::id_t)
119  {
120  return *_result;
121  }
122 
123  /** overwrite and do nothing */
124  virtual void processEvent(const CASSEvent&){}
125 
126  /** overwrite default behaviour don't do anything */
127  virtual void releaseEvent(const CASSEvent &){}
128 
129  /** load the settings of this pp */
130  virtual void loadSettings(size_t);
131 
132 private:
133  /** the constant result */
135 };
136 
137 }//end namespace cass
138 
139 #endif
virtual void loadSettings(size_t)
load the settings of this pp
Definition: rankfilter.cpp:94
Event to store all LCLS Data.
Definition: cass_event.h:32
unsigned int _medianSize
last N items to be used for median calculation
Definition: rankfilter.h:59
file contains declaration of the CASSEvent
std::tr1::shared_ptr< self_type > shared_pointer
a shared pointer of this class
Definition: result.hpp:323
QMutex _mutex
mutex to lock the median storage
Definition: rankfilter.h:65
shared_pointer _one
pp containing first histogram
Definition: rankfilter.h:56
virtual void processEvent(const CASSEvent &)
overwrite and do nothing
Definition: rankfilter.h:124
uint64_t id_t
define the id type
Definition: cass_event.h:52
std::deque< float > _medianStorage
storage of last values for median calculation
Definition: rankfilter.h:62
result classes
pp302(const name_t &)
constructor
Definition: rankfilter.cpp:88
result_t::shared_pointer _result
the constant result
Definition: rankfilter.h:134
virtual const result_t & result(const CASSEvent::id_t)
overwrite default behaviour and just return the constant
Definition: rankfilter.h:118
base class for processors.
Definition: processor.h:39
calculate median of last values.
Definition: rankfilter.h:42
file contains processors baseclass declaration
load data from binary dump into 2DHistogram
Definition: rankfilter.h:111
pp301(const name_t &)
constructor
Definition: rankfilter.cpp:28
an accumulating processor
Definition: processor.h:289
virtual void releaseEvent(const CASSEvent &)
overwrite default behaviour don't do anything
Definition: rankfilter.h:127
virtual void loadSettings(size_t)
load the settings of this pp
Definition: rankfilter.cpp:34
std::string name_t
define the name type
Definition: processor.h:46
std::tr1::shared_ptr< Processor > shared_pointer
a shared pointer of this
Definition: processor.h:43
virtual void process(const CASSEvent &, result_t &)
process event
Definition: rankfilter.cpp:59