areaDetector  3-5-0
EPICS areaDetector framework
NDPluginStats.h
Go to the documentation of this file.
1 #ifndef NDPluginStats_H
2 #define NDPluginStats_H
3 
4 #include <epicsTypes.h>
5 
6 #include "NDPluginDriver.h"
7 
8 typedef enum {
15 
16 typedef enum {
41 } NDStatTSType;
42 
43 typedef enum {
49 
50 typedef struct NDStats {
51  size_t nElements;
52  double total;
53  double net;
54  double mean;
55  double sigma;
56  double min;
57  size_t minX;
58  size_t minY;
59  double max;
60  size_t maxX;
61  size_t maxY;
63  double centroidTotal;
64  double centroidX;
65  double centroidY;
66  double sigmaX;
67  double sigmaY;
68  double sigmaXY;
69  double skewX;
70  double skewY;
71  double kurtosisX;
72  double kurtosisY;
73  double eccentricity;
74  double orientation;
77  size_t profileSizeX;
78  size_t profileSizeY;
79  size_t cursorX;
80  size_t cursorY;
81  epicsInt32 *totalArray;
82  epicsInt32 *netArray;
83  int histSize;
84  double *histogram;
85  double histMin;
86  double histMax;
87  epicsInt32 histBelow;
88  epicsInt32 histAbove;
89  double histEntropy;
90 } NDStats_t;
91 
92 /* Statistics */
93 #define NDPluginStatsComputeStatisticsString "COMPUTE_STATISTICS" /* (asynInt32, r/w) Compute statistics? */
94 #define NDPluginStatsBgdWidthString "BGD_WIDTH" /* (asynInt32, r/w) Width of background region when computing net */
95 #define NDPluginStatsMinValueString "MIN_VALUE" /* (asynFloat64, r/o) Minimum counts in any element */
96 #define NDPluginStatsMinXString "MIN_X" /* (asynFloat64, r/o) X position of minimum counts */
97 #define NDPluginStatsMinYString "MIN_Y" /* (asynFloat64, r/o) Y position of minimum counts */
98 #define NDPluginStatsMaxValueString "MAX_VALUE" /* (asynFloat64, r/o) Maximum counts in any element */
99 #define NDPluginStatsMaxXString "MAX_X" /* (asynFloat64, r/o) X position of maximum counts */
100 #define NDPluginStatsMaxYString "MAX_Y" /* (asynFloat64, r/o) Y position of maximum counts */
101 #define NDPluginStatsMeanValueString "MEAN_VALUE" /* (asynFloat64, r/o) Mean counts of all elements */
102 #define NDPluginStatsSigmaValueString "SIGMA_VALUE" /* (asynFloat64, r/o) Sigma of all elements */
103 #define NDPluginStatsTotalString "TOTAL" /* (asynFloat64, r/o) Sum of all elements */
104 #define NDPluginStatsNetString "NET" /* (asynFloat64, r/o) Sum of all elements minus background */
105 
106 /* Centroid */
107 #define NDPluginStatsComputeCentroidString "COMPUTE_CENTROID" /* (asynInt32, r/w) Compute centroid? */
108 #define NDPluginStatsCentroidThresholdString "CENTROID_THRESHOLD" /* (asynFloat64, r/w) Threshold when computing centroids */
109 #define NDPluginStatsCentroidTotalString "CENTROID_TOTAL" /* (asynFloat64, r/o) Total centroid */
110 #define NDPluginStatsCentroidXString "CENTROIDX_VALUE" /* (asynFloat64, r/o) X centroid */
111 #define NDPluginStatsCentroidYString "CENTROIDY_VALUE" /* (asynFloat64, r/o) Y centroid */
112 #define NDPluginStatsSigmaXString "SIGMAX_VALUE" /* (asynFloat64, r/o) Sigma X */
113 #define NDPluginStatsSigmaYString "SIGMAY_VALUE" /* (asynFloat64, r/o) Sigma Y */
114 #define NDPluginStatsSigmaXYString "SIGMAXY_VALUE" /* (asynFloat64, r/o) Sigma XY */
115 #define NDPluginStatsSkewXString "SKEWX_VALUE" /* (asynFloat64, r/o) Skew X */
116 #define NDPluginStatsSkewYString "SKEWY_VALUE" /* (asynFloat64, r/o) Skew Y */
117 #define NDPluginStatsKurtosisXString "KURTOSISX_VALUE" /* (asynFloat64, r/o) Kurtosis X */
118 #define NDPluginStatsKurtosisYString "KURTOSISY_VALUE" /* (asynFloat64, r/o) Kurtosis Y */
119 #define NDPluginStatsEccentricityString "ECCENTRICITY_VALUE" /* (asynFloat64, r/o) Eccentricity */
120 #define NDPluginStatsOrientationString "ORIENTATION_VALUE" /* (asynFloat64, r/o) Orientation */
121 
122 /* Profiles*/
123 #define NDPluginStatsComputeProfilesString "COMPUTE_PROFILES" /* (asynInt32, r/w) Compute profiles? */
124 #define NDPluginStatsProfileSizeXString "PROFILE_SIZE_X" /* (asynInt32, r/o) X profile size */
125 #define NDPluginStatsProfileSizeYString "PROFILE_SIZE_Y" /* (asynInt32, r/o) Y profile size */
126 #define NDPluginStatsCursorXString "CURSOR_X" /* (asynInt32, r/w) X cursor position */
127 #define NDPluginStatsCursorYString "CURSOR_Y" /* (asynInt32, r/w) Y cursor position */
128 #define NDPluginStatsProfileAverageXString "PROFILE_AVERAGE_X" /* (asynFloat64Array, r/o) X average profile array */
129 #define NDPluginStatsProfileAverageYString "PROFILE_AVERAGE_Y" /* (asynFloat64Array, r/o) Y average profile array */
130 #define NDPluginStatsProfileThresholdXString "PROFILE_THRESHOLD_X" /* (asynFloat64Array, r/o) X average profile array after threshold */
131 #define NDPluginStatsProfileThresholdYString "PROFILE_THRESHOLD_Y" /* (asynFloat64Array, r/o) Y average profile array after threshold */
132 #define NDPluginStatsProfileCentroidXString "PROFILE_CENTROID_X" /* (asynFloat64Array, r/o) X centroid profile array */
133 #define NDPluginStatsProfileCentroidYString "PROFILE_CENTROID_Y" /* (asynFloat64Array, r/o) Y centroid profile array */
134 #define NDPluginStatsProfileCursorXString "PROFILE_CURSOR_X" /* (asynFloat64Array, r/o) X cursor profile array */
135 #define NDPluginStatsProfileCursorYString "PROFILE_CURSOR_Y" /* (asynFloat64Array, r/o) Y cursor profile array */
136 
137 /* Histogram */
138 #define NDPluginStatsComputeHistogramString "COMPUTE_HISTOGRAM" /* (asynInt32, r/w) Compute histogram? */
139 #define NDPluginStatsHistSizeString "HIST_SIZE" /* (asynInt32, r/w) Number of elements in histogram */
140 #define NDPluginStatsHistMinString "HIST_MIN" /* (asynFloat64, r/w) Minimum value for histogram */
141 #define NDPluginStatsHistMaxString "HIST_MAX" /* (asynFloat64, r/w) Maximum value for histogram */
142 #define NDPluginStatsHistBelowString "HIST_BELOW" /* (asynInt32, r/o) Number of pixels below minimum */
143 #define NDPluginStatsHistAboveString "HIST_ABOVE" /* (asynInt32, r/o) Number of pixels above maximum */
144 #define NDPluginStatsHistEntropyString "HIST_ENTROPY" /* (asynFloat64, r/o) Image entropy calculcated from histogram */
145 #define NDPluginStatsHistArrayString "HIST_ARRAY" /* (asynFloat64Array, r/o) Histogram array */
146 #define NDPluginStatsHistXArrayString "HIST_X_ARRAY" /* (asynFloat64Array, r/o) Histogram X axis array */
147 
148 
149 /* Arrays of total and net counts for MCA or waveform record */
150 #define NDPluginStatsCallbackPeriodString "CALLBACK_PERIOD" /* (asynFloat64, r/w) Callback period */
151 
157 class epicsShareClass NDPluginStats : public NDPluginDriver {
158 public:
159  NDPluginStats(const char *portName, int queueSize, int blockingCallbacks,
160  const char *NDArrayPort, int NDArrayAddr,
161  int maxBuffers, size_t maxMemory,
162  int priority, int stackSize, int maxThreads=1);
163  /* These methods override the virtual methods in the base class */
164  void processCallbacks(NDArray *pArray);
165  asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
166  asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
167 
168  template <typename epicsType> void doComputeStatisticsT(NDArray *pArray, NDStats_t *pStats);
169  int doComputeStatistics(NDArray *pArray, NDStats_t *pStats);
170  template <typename epicsType> asynStatus doComputeCentroidT(NDArray *pArray, NDStats_t *pStats);
171  asynStatus doComputeCentroid(NDArray *pArray, NDStats_t *pStats);
172  template <typename epicsType> asynStatus doComputeProfilesT(NDArray *pArray, NDStats_t *pStats);
173  asynStatus doComputeProfiles(NDArray *pArray, NDStats_t *pStats);
174  template <typename epicsType> asynStatus doComputeHistogramT(NDArray *pArray, NDStats_t *pStats);
175  asynStatus doComputeHistogram(NDArray *pArray, NDStats_t *pStats);
176 
177 protected:
179  #define FIRST_NDPLUGIN_STATS_PARAM NDPluginStatsComputeStatistics
180  /* Statistics */
192 
193  /* Centroid */
208 
209  /* Profiles */
223 
224  /* Histogram */
234 
235 private:
236  asynStatus computeHistX();
237 };
238 
239 #endif
Class from which actual plugin drivers are derived; derived from asynNDArrayDriver.
Definition: NDPluginDriver.h:56
size_t cursorX
Definition: NDPluginStats.h:79
Definition: NDPluginStats.h:37
int NDPluginStatsCentroidThreshold
Definition: NDPluginStats.h:195
int NDPluginStatsHistArray
Definition: NDPluginStats.h:232
Definition: NDPluginStats.h:25
Definition: NDPluginStats.h:36
size_t minY
Definition: NDPluginStats.h:58
Definition: NDPluginStats.h:10
Definition: NDPluginStats.h:24
double kurtosisX
Definition: NDPluginStats.h:71
struct NDStats NDStats_t
int NDPluginStatsProfileThresholdX
Definition: NDPluginStats.h:217
Definition: NDPluginStats.h:35
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value)
Called when asyn clients call pasynInt32->write().
Definition: NDPluginDriver.cpp:684
int NDPluginStatsSigmaXY
Definition: NDPluginStats.h:201
Definition: NDPluginStats.h:39
int NDPluginStatsMaxY
Definition: NDPluginStats.h:187
int NDPluginStatsProfileCursorY
Definition: NDPluginStats.h:222
Definition: NDPluginStats.h:22
double mean
Definition: NDPluginStats.h:54
double centroidY
Definition: NDPluginStats.h:65
Definition: NDPluginStats.h:45
Definition: NDPluginStats.h:11
int NDPluginStatsHistAbove
Definition: NDPluginStats.h:230
Definition: NDPluginStats.h:13
Definition: NDPluginStats.h:28
double histMin
Definition: NDPluginStats.h:85
NDStatsTSControl_t
Definition: NDPluginStats.h:43
int NDPluginStatsKurtosisX
Definition: NDPluginStats.h:204
Definition: NDPluginStats.h:32
int NDPluginStatsCentroidY
Definition: NDPluginStats.h:198
int NDPluginStatsKurtosisY
Definition: NDPluginStats.h:205
int NDPluginStatsProfileAverageX
Definition: NDPluginStats.h:215
int NDPluginStatsComputeStatistics
Definition: NDPluginStats.h:178
double centroidX
Definition: NDPluginStats.h:64
list value
Definition: makeDbAndEdl.py:234
int NDPluginStatsSkewY
Definition: NDPluginStats.h:203
epicsInt32 * netArray
Definition: NDPluginStats.h:82
Definition: NDPluginStats.h:33
int histSize
Definition: NDPluginStats.h:83
Definition: NDPluginStats.h:26
double * profileX[MAX_PROFILE_TYPES]
Definition: NDPluginStats.h:75
epicsInt32 * totalArray
Definition: NDPluginStats.h:81
virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value)
Called when asyn clients call pasynFloat64->write().
Definition: NDPluginDriver.cpp:776
double kurtosisY
Definition: NDPluginStats.h:72
double skewY
Definition: NDPluginStats.h:70
size_t profileSizeX
Definition: NDPluginStats.h:77
int NDPluginStatsSigmaX
Definition: NDPluginStats.h:199
epicsInt32 histAbove
Definition: NDPluginStats.h:88
int NDPluginStatsProfileAverageY
Definition: NDPluginStats.h:216
Definition: NDPluginStats.h:18
int NDPluginStatsProfileThresholdY
Definition: NDPluginStats.h:218
int NDPluginStatsProfileCentroidX
Definition: NDPluginStats.h:219
double orientation
Definition: NDPluginStats.h:74
int NDPluginStatsTotal
Definition: NDPluginStats.h:190
int NDPluginStatsOrientation
Definition: NDPluginStats.h:207
int NDPluginStatsMinY
Definition: NDPluginStats.h:184
Definition: NDPluginStats.h:21
epicsInt32 histBelow
Definition: NDPluginStats.h:87
NDStatTSType
Definition: NDPluginStats.h:16
Definition: NDPluginStats.h:46
Definition: NDPluginStats.h:19
double histEntropy
Definition: NDPluginStats.h:89
Does image statistics.
Definition: NDPluginStats.h:157
size_t profileSizeY
Definition: NDPluginStats.h:78
double sigma
Definition: NDPluginStats.h:55
Definition: NDPluginStats.h:34
int NDPluginStatsProfileSizeX
Definition: NDPluginStats.h:211
Definition: NDPluginStats.h:17
size_t nElements
Definition: NDPluginStats.h:51
int NDPluginStatsProfileCentroidY
Definition: NDPluginStats.h:220
double min
Definition: NDPluginStats.h:56
int NDPluginStatsComputeHistogram
Definition: NDPluginStats.h:225
int NDPluginStatsCentroidTotal
Definition: NDPluginStats.h:196
Definition: NDPluginStats.h:30
double skewX
Definition: NDPluginStats.h:69
Definition: NDPluginStats.h:44
int NDPluginStatsMinValue
Definition: NDPluginStats.h:182
Definition: NDPluginStats.h:31
int NDPluginStatsComputeCentroid
Definition: NDPluginStats.h:194
Definition: NDPluginStats.h:38
virtual void processCallbacks(NDArray *pArray)=0
int NDPluginStatsHistMin
Definition: NDPluginStats.h:227
size_t cursorY
Definition: NDPluginStats.h:80
NDStatProfileType
Definition: NDPluginStats.h:8
Definition: NDPluginStats.h:47
Definition: NDPluginStats.h:9
int NDPluginStatsHistXArray
Definition: NDPluginStats.h:233
Definition: NDPluginStats.h:27
double net
Definition: NDPluginStats.h:53
Definition: NDPluginStats.h:40
Definition: NDPluginStats.h:50
int NDPluginStatsSigmaValue
Definition: NDPluginStats.h:189
double eccentricity
Definition: NDPluginStats.h:73
size_t minX
Definition: NDPluginStats.h:57
double max
Definition: NDPluginStats.h:59
int NDPluginStatsCursorY
Definition: NDPluginStats.h:214
int NDPluginStatsSigmaY
Definition: NDPluginStats.h:200
int NDPluginStatsHistMax
Definition: NDPluginStats.h:228
Definition: NDPluginStats.h:12
int NDPluginStatsHistEntropy
Definition: NDPluginStats.h:231
double sigmaY
Definition: NDPluginStats.h:67
int NDPluginStatsComputeProfiles
Definition: NDPluginStats.h:210
double total
Definition: NDPluginStats.h:52
double sigmaXY
Definition: NDPluginStats.h:68
int NDPluginStatsCursorX
Definition: NDPluginStats.h:213
int NDPluginStatsBgdWidth
Definition: NDPluginStats.h:181
N-dimensional array class; each array has a set of dimensions, a data type, pointer to data,...
Definition: NDArray.h:92
int NDPluginStatsMeanValue
Definition: NDPluginStats.h:188
size_t maxX
Definition: NDPluginStats.h:60
double * histogram
Definition: NDPluginStats.h:84
int NDPluginStatsMaxX
Definition: NDPluginStats.h:186
int NDPluginStatsHistBelow
Definition: NDPluginStats.h:229
int NDPluginStatsMaxValue
Definition: NDPluginStats.h:185
int NDPluginStatsProfileSizeY
Definition: NDPluginStats.h:212
double * profileY[MAX_PROFILE_TYPES]
Definition: NDPluginStats.h:76
Definition: NDPluginStats.h:29
double histMax
Definition: NDPluginStats.h:86
size_t maxY
Definition: NDPluginStats.h:61
int NDPluginStatsMinX
Definition: NDPluginStats.h:183
int NDPluginStatsHistSize
Definition: NDPluginStats.h:226
int NDPluginStatsEccentricity
Definition: NDPluginStats.h:206
int NDPluginStatsNet
Definition: NDPluginStats.h:191
int NDPluginStatsSkewX
Definition: NDPluginStats.h:202
double centroidTotal
Definition: NDPluginStats.h:63
int NDPluginStatsProfileCursorX
Definition: NDPluginStats.h:221
double sigmaX
Definition: NDPluginStats.h:66
int NDPluginStatsCentroidX
Definition: NDPluginStats.h:197
double centroidThreshold
Definition: NDPluginStats.h:62
Definition: NDPluginStats.h:20
Definition: NDPluginStats.h:23