areaDetector  3-13
EPICS areaDetector framework
NDPluginStats.h
Go to the documentation of this file.
1 #ifndef NDPluginStats_H
2 #define NDPluginStats_H
3 
4 #include "NDPluginDriver.h"
5 
6 typedef enum {
13 
14 typedef enum {
40 
41 typedef enum {
45  TSRead
47 
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;
90 
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 */
104 
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 */
120 
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 */
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 
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 */
224 
225  /* Histogram */
235 
236 private:
237  asynStatus computeHistX();
238 };
239 
240 #endif
#define NDPLUGIN_API
Definition: NDPluginAPI.h:41
NDStatsTSControl_t
Definition: NDPluginStats.h:41
@ TSRead
Definition: NDPluginStats.h:45
@ TSStart
Definition: NDPluginStats.h:43
@ TSStop
Definition: NDPluginStats.h:44
@ TSEraseStart
Definition: NDPluginStats.h:42
struct NDStats NDStats_t
NDStatTSType
Definition: NDPluginStats.h:14
@ TSMinX
Definition: NDPluginStats.h:16
@ TSMinValue
Definition: NDPluginStats.h:15
@ TSSkewX
Definition: NDPluginStats.h:31
@ TSCentroidY
Definition: NDPluginStats.h:27
@ TSKurtosisX
Definition: NDPluginStats.h:33
@ TSNet
Definition: NDPluginStats.h:24
@ TSSigmaX
Definition: NDPluginStats.h:28
@ TSCentroidX
Definition: NDPluginStats.h:26
@ TSMaxValue
Definition: NDPluginStats.h:18
@ TSSkewY
Definition: NDPluginStats.h:32
@ TSMinY
Definition: NDPluginStats.h:17
@ TSTotal
Definition: NDPluginStats.h:23
@ TSTimestamp
Definition: NDPluginStats.h:37
@ TSSigmaXY
Definition: NDPluginStats.h:30
@ TSMaxY
Definition: NDPluginStats.h:20
@ TSMeanValue
Definition: NDPluginStats.h:21
@ TSSigmaValue
Definition: NDPluginStats.h:22
@ MAX_TIME_SERIES_TYPES
Definition: NDPluginStats.h:38
@ TSOrientation
Definition: NDPluginStats.h:36
@ TSKurtosisY
Definition: NDPluginStats.h:34
@ TSSigmaY
Definition: NDPluginStats.h:29
@ TSCentroidTotal
Definition: NDPluginStats.h:25
@ TSEccentricity
Definition: NDPluginStats.h:35
@ TSMaxX
Definition: NDPluginStats.h:19
NDStatProfileType
Definition: NDPluginStats.h:6
@ MAX_PROFILE_TYPES
Definition: NDPluginStats.h:11
@ profCentroid
Definition: NDPluginStats.h:9
@ profCursor
Definition: NDPluginStats.h:10
@ profAverage
Definition: NDPluginStats.h:7
@ profThreshold
Definition: NDPluginStats.h:8
N-dimensional array class; each array has a set of dimensions, a data type, pointer to data,...
Definition: NDArray.h:99
Class from which actual plugin drivers are derived; derived from asynNDArrayDriver.
Definition: NDPluginDriver.h:57
virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value)
Called when asyn clients call pasynFloat64->write().
Definition: NDPluginDriver.cpp:769
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value)
Called when asyn clients call pasynInt32->write().
Definition: NDPluginDriver.cpp:678
virtual void processCallbacks(NDArray *pArray)=0
Does image statistics.
Definition: NDPluginStats.h:157
int NDPluginStatsHistMin
Definition: NDPluginStats.h:228
int NDPluginStatsSkewX
Definition: NDPluginStats.h:202
int NDPluginStatsCentroidThreshold
Definition: NDPluginStats.h:195
int NDPluginStatsCentroidX
Definition: NDPluginStats.h:197
int NDPluginStatsCentroidY
Definition: NDPluginStats.h:198
int NDPluginStatsHistMax
Definition: NDPluginStats.h:229
int NDPluginStatsKurtosisY
Definition: NDPluginStats.h:205
int NDPluginStatsComputeCentroid
Definition: NDPluginStats.h:194
int NDPluginStatsHistBelow
Definition: NDPluginStats.h:230
int NDPluginStatsHistXArray
Definition: NDPluginStats.h:234
int NDPluginStatsHistAbove
Definition: NDPluginStats.h:231
int NDPluginStatsProfileThresholdY
Definition: NDPluginStats.h:219
int NDPluginStatsSkewY
Definition: NDPluginStats.h:203
int NDPluginStatsMinX
Definition: NDPluginStats.h:183
int NDPluginStatsKurtosisX
Definition: NDPluginStats.h:204
int NDPluginStatsHistSize
Definition: NDPluginStats.h:227
int NDPluginStatsOrientation
Definition: NDPluginStats.h:207
int NDPluginStatsProfileThresholdX
Definition: NDPluginStats.h:218
int NDPluginStatsSigmaX
Definition: NDPluginStats.h:199
int NDPluginStatsEccentricity
Definition: NDPluginStats.h:206
int NDPluginStatsCursorVal
Definition: NDPluginStats.h:215
int NDPluginStatsCentroidTotal
Definition: NDPluginStats.h:196
int NDPluginStatsMinValue
Definition: NDPluginStats.h:182
int NDPluginStatsProfileSizeX
Definition: NDPluginStats.h:211
int NDPluginStatsComputeHistogram
Definition: NDPluginStats.h:226
int NDPluginStatsSigmaValue
Definition: NDPluginStats.h:189
int NDPluginStatsMaxValue
Definition: NDPluginStats.h:185
int NDPluginStatsComputeProfiles
Definition: NDPluginStats.h:210
int NDPluginStatsProfileCursorY
Definition: NDPluginStats.h:223
int NDPluginStatsMeanValue
Definition: NDPluginStats.h:188
int NDPluginStatsCursorX
Definition: NDPluginStats.h:213
int NDPluginStatsNet
Definition: NDPluginStats.h:191
int NDPluginStatsHistEntropy
Definition: NDPluginStats.h:232
int NDPluginStatsMinY
Definition: NDPluginStats.h:184
int NDPluginStatsProfileCursorX
Definition: NDPluginStats.h:222
int NDPluginStatsTotal
Definition: NDPluginStats.h:190
int NDPluginStatsProfileAverageX
Definition: NDPluginStats.h:216
int NDPluginStatsMaxY
Definition: NDPluginStats.h:187
int NDPluginStatsProfileCentroidY
Definition: NDPluginStats.h:221
int NDPluginStatsCursorY
Definition: NDPluginStats.h:214
int NDPluginStatsComputeStatistics
Definition: NDPluginStats.h:178
int NDPluginStatsSigmaY
Definition: NDPluginStats.h:200
int NDPluginStatsProfileSizeY
Definition: NDPluginStats.h:212
int NDPluginStatsSigmaXY
Definition: NDPluginStats.h:201
int NDPluginStatsProfileCentroidX
Definition: NDPluginStats.h:220
int NDPluginStatsProfileAverageY
Definition: NDPluginStats.h:217
int NDPluginStatsHistArray
Definition: NDPluginStats.h:233
int NDPluginStatsBgdWidth
Definition: NDPluginStats.h:181
int NDPluginStatsMaxX
Definition: NDPluginStats.h:186
list value
Definition: makeDbAndEdl.py:234
Definition: NDPluginStats.h:48
double mean
Definition: NDPluginStats.h:52
double histMax
Definition: NDPluginStats.h:85
double centroidX
Definition: NDPluginStats.h:62
size_t minX
Definition: NDPluginStats.h:55
size_t minY
Definition: NDPluginStats.h:56
double sigmaXY
Definition: NDPluginStats.h:66
double eccentricity
Definition: NDPluginStats.h:71
size_t cursorX
Definition: NDPluginStats.h:77
double net
Definition: NDPluginStats.h:51
double orientation
Definition: NDPluginStats.h:72
double centroidY
Definition: NDPluginStats.h:63
double skewY
Definition: NDPluginStats.h:68
size_t profileSizeY
Definition: NDPluginStats.h:76
double sigmaY
Definition: NDPluginStats.h:65
epicsInt32 * totalArray
Definition: NDPluginStats.h:80
double min
Definition: NDPluginStats.h:54
epicsInt32 histAbove
Definition: NDPluginStats.h:87
size_t cursorY
Definition: NDPluginStats.h:78
double kurtosisY
Definition: NDPluginStats.h:70
int histSize
Definition: NDPluginStats.h:82
double centroidThreshold
Definition: NDPluginStats.h:60
double max
Definition: NDPluginStats.h:57
double kurtosisX
Definition: NDPluginStats.h:69
double sigma
Definition: NDPluginStats.h:53
epicsInt32 * netArray
Definition: NDPluginStats.h:81
size_t maxX
Definition: NDPluginStats.h:58
double centroidTotal
Definition: NDPluginStats.h:61
double histEntropy
Definition: NDPluginStats.h:88
double histMin
Definition: NDPluginStats.h:84
double * histogram
Definition: NDPluginStats.h:83
size_t maxY
Definition: NDPluginStats.h:59
double * profileX[MAX_PROFILE_TYPES]
Definition: NDPluginStats.h:73
double sigmaX
Definition: NDPluginStats.h:64
size_t profileSizeX
Definition: NDPluginStats.h:75
epicsInt32 histBelow
Definition: NDPluginStats.h:86
double total
Definition: NDPluginStats.h:50
double cursorValue
Definition: NDPluginStats.h:79
double * profileY[MAX_PROFILE_TYPES]
Definition: NDPluginStats.h:74
size_t nElements
Definition: NDPluginStats.h:49
double skewX
Definition: NDPluginStats.h:67