CFEL - ASG Software Suite  2.5.0
CASS
imaging.h
Go to the documentation of this file.
1 // Copyright (C) 2010-2013 Lutz Foucar
2 
3 /**
4  * @file imaging.h processors to generate a test image
5  *
6  * @author Stephan Kassemeyer
7  * @author Lutz Foucar
8  */
9 
10 #ifndef _IMAGING_H_
11 #define _IMAGING_H_
12 
13 #include "processor.h"
14 
15 namespace cass
16 {
17 //forward declaration
18 class CASSEvent;
19 class CASSSettings;
20 
21 /** Test image
22  *
23  * @PPList "240": Test image
24  *
25  * @see Processor for a list of all commonly available cass.ini
26  * settings.
27  *
28  * @cassttng Processor/\%name\%/{sizeX} \n
29  * Width of testimage (default = 1024)
30  * @cassttng Processor/\%name\%/{sizeY} \n
31  * Height of testimage (default = 1024)
32  * @cassttng Processor/\%name\%/{FixedValue} \n
33  * Use a fixed value instead of the product of the column and row index.
34  * Default is false
35  * @cassttng Processor/\%name\%/{Value} \n
36  * In case FixedValue is true, this is the value that the image will
37  * be filled with. Default is 0
38  * @cassttng Processor/\%name\%/Mask/{size}\n
39  * The number of mask elements that are part of the complete mask.
40  * Default is 0.
41  * @cassttng Processor/\%name\%/Mask/\%index\%/{Type}\n
42  * Name of the mask element. Default is "Unknown", which let the code
43  * ignore that element. Possible values are:
44  * - "square": a square region of the mask. See cass::pp240::square
45  * for details.
46  * - "circle" or "circ": a circular region of the mask. See
47  * cass::pp240::circle for details
48  * - "ellipse": a ellipsodial region of the mask. See
49  * cass::pp240::ellipse for details
50  * - "triangle": a triangular region of the mask. See
51  * cass::pp240::triangle for details
52  * - "ring": a ring with inner and outer part composed by ellipsoids.
53  * See cass::pp240::ring for details
54  *
55  * @author Stephan Kassemeyer
56  * @author Lutz Foucar
57  */
58 class pp240 : public Processor
59 {
60 public:
61  /** constructor. */
62  pp240(const name_t&);
63 
64  /** overwrite default behaviour and just return the constant */
65  virtual const result_t& result(const CASSEvent::id_t)
66  {
67  return *_result;
68  }
69 
70  /** overwrite default behaviour don't do anything */
71  virtual void releaseEvent(const CASSEvent &){}
72 
73  /** overwrite default behaviour don't do anything */
74  virtual void processEvent(const CASSEvent&){}
75 
76  /** load the settings of this pp */
77  virtual void loadSettings(size_t);
78 
79  /** define the index type */
80  typedef std::pair<int,int> index_t;
81 
82  /** define a floating point version of the index */
83  typedef std::pair<float,float> indexf_t;
84 
85 private:
86  /** add a circle to the mask
87  *
88  * goes through the sqare that conatins the cirlce and checks whether the index
89  * is covered by the circle. If so the mask at that index will be set to false.
90  *
91  * @cassttng Processor/\%name\%/Mask/\%index\%/{CenterX|CenterY}\n
92  * The center of the circle. Default is 500|500.
93  * @cassttng Processor/\%name\%/Mask/\%index\%/{Radius}\n
94  * The radius of the circle. Default is 2.
95  * @cassttng Processor/\%name\%/Mask/\%index\%/{Value}\n
96  * The value that will be set to all the pixels within the mask.
97  * Default is 1
98  *
99  * @param data the container containing the mask where the element should be added
100  * @param s the settings element to read the mask element parameters from
101  *
102  * @author Nicola Coppola
103  * @author Lutz Foucar
104  */
105  void circle(result_t &data, CASSSettings &s);
106 
107  /** add a square element to the mask
108  *
109  * sets all pixels covered by the square to 0.
110  *
111  * @cassttng Processor/\%name\%/Mask/\%index\%/{LowerLeftX|LowerLeftY}\n
112  * The lower left pixel of the square element. The indizes given are
113  * included in the square. Default is 0|0.
114  * @cassttng Processor/\%name\%/Mask/\%index\%/{UpperRightX|UpperRightY}\n
115  * The upper right pixel of the square element. The indizes given are
116  * included in the square. Default is 1023|1023.
117  * @cassttng Processor/\%name\%/Mask/\%index\%/{Value}\n
118  * The value that will be set to all the pixels within the mask.
119  * Default is 1
120  *
121  * @param data the container containing the mask where the element should be added
122  * @param s the settings element to read the mask element parameters from
123  *
124  * @author Nicola Coppola
125  * @author Lutz Foucar
126  */
127  void square(result_t &data, CASSSettings &s);
128 
129  /** add a ellipsodial element to the mask
130  *
131  * adds an ellipsodial to the mask. Will iterate trhough the sqare that contains
132  * the ellipse and checks which pixels should be masked.
133  *
134  * @cassttng Processor/\%name\%/Mask/\%index\%/{CenterX|CenterY}\n
135  * The central point of the ellipse. Default is 500|500.
136  * @cassttng Processor/\%name\%/Mask/\%index\%/{SemiAxisX|SemiAxisY}\n
137  * The semi axis along x and y of the ellipse. By definition the
138  * longer one defines the major axis and the smaller on the minor axis.
139  * Default is 5|4.
140  * @cassttng Processor/\%name\%/Mask/\%index\%/{Value}\n
141  * The value that will be set to all the pixels within the mask.
142  * Default is 1
143  *
144  * @param data the container containing the mask where the element should be added
145  * @param s the settings element to read the mask element parameters from
146  *
147  * @author Nicola Coppola
148  * @author Lutz Foucar
149  */
150  void ellipse(result_t &data, CASSSettings &s);
151 
152  /** add a ring
153  *
154  * define the ring by two ellipses; an inner and outer ellipse. The area covered
155  * by the out but not by the inner will be masked. The two ellipsoids can have
156  * different centers and axis. Therefore the ring can take any shape.
157  *
158  * @cassttng Processor/\%name\%/Mask/\%index\%/{InnerCenterX|InnerCenterY}\n
159  * The central point of the inner ellipse. Default is 500|500.
160  * @cassttng Processor/\%name\%/Mask/\%index\%/{InnerSemiAxisX|InnerSemiAxisY}\n
161  * The semi axis along x and y of the inner ellipse. By definition the
162  * longer one defines the major axis and the smaller on the minor axis.
163  * Default is 5|4.
164  * @cassttng Processor/\%name\%/Mask/\%index\%/{OuterCenterX|OuterCenterY}\n
165  * The central point of the outer ellipse. Default is 500|500.
166  * @cassttng Processor/\%name\%/Mask/\%index\%/{OuterSemiAxisX|OuterSemiAxisY}\n
167  * The semi axis along x and y of the outer ellipse. By definition the
168  * longer one defines the major axis and the smaller on the minor axis.
169  * Default is 20|20.
170  * @cassttng Processor/\%name\%/Mask/\%index\%/{Value}\n
171  * The value that will be set to all the pixels within the mask.
172  * Default is 1
173  *
174  * @author Lutz Foucar
175  */
176  void ring(result_t &data, CASSSettings &s);
177 
178  /** add a triangluar element to the mask
179  *
180  * To see whether a point is within a triangle one can use barycentric coordinates.
181  * See http://en.wikipedia.org/wiki/Barycentric_coordinates_(mathematics) for
182  * details. A point within barycentric can be defined by converting to these
183  * coordinates. The bayrocentric coordinates are represented by three points
184  * A, B, C. Each point can be represented by
185  * \f$ \vec{P} = \lambda_1\vec{A} + \lambda_2\vec{B} + \lambda_3\vec{C}\f$
186  * where \f$ \lambda_1, \lambda_2, \lambda_3\f$ can be determined from
187  * \f$ \vec{P} \f$ using the components of the triangle points and the wanted point
188  * \f$ \vec{P} = (x,y) ; \vec{A} = (x_1,y_1); \vec{B} = (x_2,y_2); \vec{C} = (x_3,y_3)\f$
189  * with these definition the following equalities are given:
190  * \f{eqnarray*}{
191  * \lambda_1&=&\frac{(y_2-y_3)(x-x_3)+(x_3-x_2)(y-y_3)}{(y_2-y_3)(x_1-x_3)+(x_3-x_2)(y_1-y_3)}\\
192  * \lambda_2&=&\frac{(y_3-y_1)(x-x_3)+(x_1-x_3)(y-y_3)}{(y_2-y_3)(x_1-x_3)+(x_3-x_2)(y_1-y_3)}\\
193  * \lambda_3&=&1-\lambda_1-\lambda_2
194  * \f}
195  * With this we know that \f$ \vec{P} \f$ lies within the triangluar when
196  * \f[ 0 \leq \lambda_i \leq 1 \f]
197  *
198  * @cassttng Processor/\%name\%/Mask/\%index\%/{PointA_X|PointA_Y}\n
199  * The triangles first point. Default is 500|500.
200  * @cassttng Processor/\%name\%/Mask/\%index\%/{PointB_X|PointB_Y}\n
201  * The triangles first point. Default is 500|500.
202  * @cassttng Processor/\%name\%/Mask/\%index\%/{PointC_X|PointC_Y}\n
203  * The triangles first point. Default is 500|500.
204  * @cassttng Processor/\%name\%/Mask/\%index\%/{Value}\n
205  * The value that will be set to all the pixels within the mask.
206  * Default is 1
207  *
208  * @param data the container containing the mask where the element should be added
209  * @param s the settings element to read the mask element parameters from
210  *
211  * @author Lutz Foucar
212  */
213  void triangle(result_t &data, CASSSettings &s);
214 
215  /** the constant image */
217 
218 };
219 
220 
221 
222 }
223 #endif
Event to store all LCLS Data.
Definition: cass_event.h:32
void triangle(result_t &data, CASSSettings &s)
add a triangluar element to the mask
Definition: imaging.cpp:344
void ring(result_t &data, CASSSettings &s)
add a ring
Definition: imaging.cpp:267
result_t::shared_pointer _result
the constant image
Definition: imaging.h:216
Settings for CASS.
Definition: cass_settings.h:30
std::tr1::shared_ptr< self_type > shared_pointer
a shared pointer of this class
Definition: result.hpp:323
uint64_t id_t
define the id type
Definition: cass_event.h:52
virtual void processEvent(const CASSEvent &)
overwrite default behaviour don't do anything
Definition: imaging.h:74
Test image.
Definition: imaging.h:58
base class for processors.
Definition: processor.h:39
std::pair< int, int > index_t
define the index type
Definition: imaging.h:80
void ellipse(result_t &data, CASSSettings &s)
add a ellipsodial element to the mask
Definition: imaging.cpp:226
auxiliary data[Processor]
file contains processors baseclass declaration
void circle(result_t &data, CASSSettings &s)
add a circle to the mask
Definition: imaging.cpp:159
virtual const result_t & result(const CASSEvent::id_t)
overwrite default behaviour and just return the constant
Definition: imaging.h:65
void square(result_t &data, CASSSettings &s)
add a square element to the mask
Definition: imaging.cpp:192
pp240(const name_t &)
constructor.
Definition: imaging.cpp:111
std::pair< float, float > indexf_t
define a floating point version of the index
Definition: imaging.h:83
std::string name_t
define the name type
Definition: processor.h:46
virtual void loadSettings(size_t)
load the settings of this pp
Definition: imaging.cpp:117
virtual void releaseEvent(const CASSEvent &)
overwrite default behaviour don't do anything
Definition: imaging.h:71