areaDetector  3-12-1
EPICS areaDetector framework
Go to the documentation of this file.
1 #ifndef NDPluginStats_H
2 #define NDPluginStats_H
4 #include "NDPluginDriver.h"
6 typedef enum {
14 typedef enum {
39 } NDStatTSType;
41 typedef enum {
48 typedef struct NDStats {
49  size_t nElements;
50  double total;
51  double net;
52  double mean;
53  double sigma;
54  double min;
55  size_t minX;
56  size_t minY;
57  double max;
58  size_t maxX;
59  size_t maxY;
61  double centroidTotal;
62  double centroidX;
63  double centroidY;
64  double sigmaX;
65  double sigmaY;
66  double sigmaXY;
67  double skewX;
68  double skewY;
69  double kurtosisX;
70  double kurtosisY;
71  double eccentricity;
72  double orientation;
75  size_t profileSizeX;
76  size_t profileSizeY;
77  size_t cursorX;
78  size_t cursorY;
79  double cursorValue;
80  epicsInt32 *totalArray;
81  epicsInt32 *netArray;
82  int histSize;
83  double *histogram;
84  double histMin;
85  double histMax;
86  epicsInt32 histBelow;
87  epicsInt32 histAbove;
88  double histEntropy;
89 } NDStats_t;
91 /* Statistics */
92 #define NDPluginStatsComputeStatisticsString "COMPUTE_STATISTICS" /* (asynInt32, r/w) Compute statistics? */
93 #define NDPluginStatsBgdWidthString "BGD_WIDTH" /* (asynInt32, r/w) Width of background region when computing net */
94 #define NDPluginStatsMinValueString "MIN_VALUE" /* (asynFloat64, r/o) Minimum counts in any element */
95 #define NDPluginStatsMinXString "MIN_X" /* (asynFloat64, r/o) X position of minimum counts */
96 #define NDPluginStatsMinYString "MIN_Y" /* (asynFloat64, r/o) Y position of minimum counts */
97 #define NDPluginStatsMaxValueString "MAX_VALUE" /* (asynFloat64, r/o) Maximum counts in any element */
98 #define NDPluginStatsMaxXString "MAX_X" /* (asynFloat64, r/o) X position of maximum counts */
99 #define NDPluginStatsMaxYString "MAX_Y" /* (asynFloat64, r/o) Y position of maximum counts */
100 #define NDPluginStatsMeanValueString "MEAN_VALUE" /* (asynFloat64, r/o) Mean counts of all elements */
101 #define NDPluginStatsSigmaValueString "SIGMA_VALUE" /* (asynFloat64, r/o) Sigma of all elements */
102 #define NDPluginStatsTotalString "TOTAL" /* (asynFloat64, r/o) Sum of all elements */
103 #define NDPluginStatsNetString "NET" /* (asynFloat64, r/o) Sum of all elements minus background */
105 /* Centroid */
106 #define NDPluginStatsComputeCentroidString "COMPUTE_CENTROID" /* (asynInt32, r/w) Compute centroid? */
107 #define NDPluginStatsCentroidThresholdString "CENTROID_THRESHOLD" /* (asynFloat64, r/w) Threshold when computing centroids */
108 #define NDPluginStatsCentroidTotalString "CENTROID_TOTAL" /* (asynFloat64, r/o) Total centroid */
109 #define NDPluginStatsCentroidXString "CENTROIDX_VALUE" /* (asynFloat64, r/o) X centroid */
110 #define NDPluginStatsCentroidYString "CENTROIDY_VALUE" /* (asynFloat64, r/o) Y centroid */
111 #define NDPluginStatsSigmaXString "SIGMAX_VALUE" /* (asynFloat64, r/o) Sigma X */
112 #define NDPluginStatsSigmaYString "SIGMAY_VALUE" /* (asynFloat64, r/o) Sigma Y */
113 #define NDPluginStatsSigmaXYString "SIGMAXY_VALUE" /* (asynFloat64, r/o) Sigma XY */
114 #define NDPluginStatsSkewXString "SKEWX_VALUE" /* (asynFloat64, r/o) Skew X */
115 #define NDPluginStatsSkewYString "SKEWY_VALUE" /* (asynFloat64, r/o) Skew Y */
116 #define NDPluginStatsKurtosisXString "KURTOSISX_VALUE" /* (asynFloat64, r/o) Kurtosis X */
117 #define NDPluginStatsKurtosisYString "KURTOSISY_VALUE" /* (asynFloat64, r/o) Kurtosis Y */
118 #define NDPluginStatsEccentricityString "ECCENTRICITY_VALUE" /* (asynFloat64, r/o) Eccentricity */
119 #define NDPluginStatsOrientationString "ORIENTATION_VALUE" /* (asynFloat64, r/o) Orientation */
121 /* Profiles*/
122 #define NDPluginStatsComputeProfilesString "COMPUTE_PROFILES" /* (asynInt32, r/w) Compute profiles? */
123 #define NDPluginStatsProfileSizeXString "PROFILE_SIZE_X" /* (asynInt32, r/o) X profile size */
124 #define NDPluginStatsProfileSizeYString "PROFILE_SIZE_Y" /* (asynInt32, r/o) Y profile size */
125 #define NDPluginStatsCursorXString "CURSOR_X" /* (asynInt32, r/w) X cursor position */
126 #define NDPluginStatsCursorYString "CURSOR_Y" /* (asynInt32, r/w) Y cursor position */
127 #define NDPluginStatsCursorValString "CURSOR_VAL" /* (asynFloat64, r/o) value at 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 */
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 */
149 /* Arrays of total and net counts for MCA or waveform record */
150 #define NDPluginStatsCallbackPeriodString "CALLBACK_PERIOD" /* (asynFloat64, r/w) Callback period */
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);
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);
177 protected:
179  #define FIRST_NDPLUGIN_STATS_PARAM NDPluginStatsComputeStatistics
180  /* Statistics */
193  /* Centroid */
209  /* Profiles */
225  /* Histogram */
236 private:
237  asynStatus computeHistX();
238 };
240 #endif
Class from which actual plugin drivers are derived; derived from asynNDArrayDriver.
Definition: NDPluginDriver.h:58
size_t cursorX
Definition: NDPluginStats.h:77
Definition: NDPluginStats.h:35
int NDPluginStatsCentroidThreshold
Definition: NDPluginStats.h:195
int NDPluginStatsHistArray
Definition: NDPluginStats.h:233
Definition: NDPluginStats.h:23
Definition: NDPluginStats.h:34
size_t minY
Definition: NDPluginStats.h:56
Definition: NDPluginStats.h:8
Definition: NDPluginStats.h:22
double kurtosisX
Definition: NDPluginStats.h:69
struct NDStats NDStats_t
int NDPluginStatsProfileThresholdX
Definition: NDPluginStats.h:218
Definition: NDPluginStats.h:33
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value)
Called when asyn clients call pasynInt32->write().
Definition: NDPluginDriver.cpp:678
int NDPluginStatsSigmaXY
Definition: NDPluginStats.h:201
Definition: NDPluginStats.h:37
int NDPluginStatsMaxY
Definition: NDPluginStats.h:187
int NDPluginStatsProfileCursorY
Definition: NDPluginStats.h:223
Definition: NDPluginStats.h:20
double mean
Definition: NDPluginStats.h:52
double centroidY
Definition: NDPluginStats.h:63
Definition: NDPluginStats.h:43
Definition: NDPluginStats.h:9
int NDPluginStatsHistAbove
Definition: NDPluginStats.h:231
Definition: NDPluginStats.h:11
Definition: NDPluginStats.h:26
double histMin
Definition: NDPluginStats.h:84
Definition: NDPluginStats.h:41
int NDPluginStatsKurtosisX
Definition: NDPluginStats.h:204
Definition: NDPluginStats.h:30
int NDPluginStatsCentroidY
Definition: NDPluginStats.h:198
int NDPluginStatsKurtosisY
Definition: NDPluginStats.h:205
int NDPluginStatsProfileAverageX
Definition: NDPluginStats.h:216
int NDPluginStatsComputeStatistics
Definition: NDPluginStats.h:178
double centroidX
Definition: NDPluginStats.h:62
list value
double cursorValue
Definition: NDPluginStats.h:79
int NDPluginStatsSkewY
Definition: NDPluginStats.h:203
epicsInt32 * netArray
Definition: NDPluginStats.h:81
Definition: NDPluginStats.h:31
int histSize
Definition: NDPluginStats.h:82
Definition: NDPluginStats.h:24
double * profileX[MAX_PROFILE_TYPES]
Definition: NDPluginStats.h:73
epicsInt32 * totalArray
Definition: NDPluginStats.h:80
virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value)
Called when asyn clients call pasynFloat64->write().
Definition: NDPluginDriver.cpp:769
double kurtosisY
Definition: NDPluginStats.h:70
double skewY
Definition: NDPluginStats.h:68
size_t profileSizeX
Definition: NDPluginStats.h:75
int NDPluginStatsSigmaX
Definition: NDPluginStats.h:199
epicsInt32 histAbove
Definition: NDPluginStats.h:87
int NDPluginStatsProfileAverageY
Definition: NDPluginStats.h:217
Definition: NDPluginStats.h:16
int NDPluginStatsProfileThresholdY
Definition: NDPluginStats.h:219
int NDPluginStatsProfileCentroidX
Definition: NDPluginStats.h:220
double orientation
Definition: NDPluginStats.h:72
int NDPluginStatsTotal
Definition: NDPluginStats.h:190
int NDPluginStatsOrientation
Definition: NDPluginStats.h:207
int NDPluginStatsMinY
Definition: NDPluginStats.h:184
Definition: NDPluginStats.h:19
epicsInt32 histBelow
Definition: NDPluginStats.h:86
Definition: NDPluginStats.h:14
Definition: NDPluginStats.h:44
Definition: NDPluginStats.h:17
double histEntropy
Definition: NDPluginStats.h:88
Does image statistics.
Definition: NDPluginStats.h:157
size_t profileSizeY
Definition: NDPluginStats.h:76
double sigma
Definition: NDPluginStats.h:53
Definition: NDPluginStats.h:32
int NDPluginStatsProfileSizeX
Definition: NDPluginStats.h:211
Definition: NDPluginStats.h:15
size_t nElements
Definition: NDPluginStats.h:49
int NDPluginStatsProfileCentroidY
Definition: NDPluginStats.h:221
double min
Definition: NDPluginStats.h:54
int NDPluginStatsComputeHistogram
Definition: NDPluginStats.h:226
int NDPluginStatsCentroidTotal
Definition: NDPluginStats.h:196
Definition: NDPluginStats.h:28
double skewX
Definition: NDPluginStats.h:67
int NDPluginStatsCursorVal
Definition: NDPluginStats.h:215
Definition: NDPluginStats.h:42
int NDPluginStatsMinValue
Definition: NDPluginStats.h:182
Definition: NDPluginStats.h:29
int NDPluginStatsComputeCentroid
Definition: NDPluginStats.h:194
Definition: NDPluginStats.h:36
virtual void processCallbacks(NDArray *pArray)=0
int NDPluginStatsHistMin
Definition: NDPluginStats.h:228
size_t cursorY
Definition: NDPluginStats.h:78
Definition: NDPluginStats.h:6
Definition: NDPluginAPI.h:41
Definition: NDPluginStats.h:45
Definition: NDPluginStats.h:7
int NDPluginStatsHistXArray
Definition: NDPluginStats.h:234
Definition: NDPluginStats.h:25
double net
Definition: NDPluginStats.h:51
Definition: NDPluginStats.h:38
Definition: NDPluginStats.h:48
int NDPluginStatsSigmaValue
Definition: NDPluginStats.h:189
double eccentricity
Definition: NDPluginStats.h:71
size_t minX
Definition: NDPluginStats.h:55
double max
Definition: NDPluginStats.h:57
int NDPluginStatsCursorY
Definition: NDPluginStats.h:214
int NDPluginStatsSigmaY
Definition: NDPluginStats.h:200
int NDPluginStatsHistMax
Definition: NDPluginStats.h:229
Definition: NDPluginStats.h:10
int NDPluginStatsHistEntropy
Definition: NDPluginStats.h:232
double sigmaY
Definition: NDPluginStats.h:65
int NDPluginStatsComputeProfiles
Definition: NDPluginStats.h:210
double total
Definition: NDPluginStats.h:50
double sigmaXY
Definition: NDPluginStats.h:66
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:94
int NDPluginStatsMeanValue
Definition: NDPluginStats.h:188
size_t maxX
Definition: NDPluginStats.h:58
double * histogram
Definition: NDPluginStats.h:83
int NDPluginStatsMaxX
Definition: NDPluginStats.h:186
int NDPluginStatsHistBelow
Definition: NDPluginStats.h:230
int NDPluginStatsMaxValue
Definition: NDPluginStats.h:185
int NDPluginStatsProfileSizeY
Definition: NDPluginStats.h:212
double * profileY[MAX_PROFILE_TYPES]
Definition: NDPluginStats.h:74
Definition: NDPluginStats.h:27
double histMax
Definition: NDPluginStats.h:85
size_t maxY
Definition: NDPluginStats.h:59
int NDPluginStatsMinX
Definition: NDPluginStats.h:183
int NDPluginStatsHistSize
Definition: NDPluginStats.h:227
int NDPluginStatsEccentricity
Definition: NDPluginStats.h:206
int NDPluginStatsNet
Definition: NDPluginStats.h:191
int NDPluginStatsSkewX
Definition: NDPluginStats.h:202
double centroidTotal
Definition: NDPluginStats.h:61
int NDPluginStatsProfileCursorX
Definition: NDPluginStats.h:222
double sigmaX
Definition: NDPluginStats.h:64
int NDPluginStatsCentroidX
Definition: NDPluginStats.h:197
double centroidThreshold
Definition: NDPluginStats.h:60
Definition: NDPluginStats.h:18
Definition: NDPluginStats.h:21