areaDetector / ADCore

The home of the core components of the EPICS areaDetector software. It includes base classes for drivers and code for all of the standard plugins.
https://areadetector.github.io/areaDetector
Other
20 stars 69 forks source link

Add thresholding option to NDPluginProcess #492

Closed xiaoqiangwang closed 1 year ago

xiaoqiangwang commented 1 year ago

NDPluginProcess currently has the clipping algorithms https://github.com/areaDetector/ADCore/blob/49f9cce7ffa6331d947986bfa54fa6906d540d79/ADApp/pluginSrc/NDPluginProcess.cpp#L169-L170

In practice, it is often desired to set the outliers to 0 instead of the clipping values. This improves the contrast and reduces the background when x/y profile is summed.

This could be either implemented as a separate processing step, or as two options (one for low and one for high).

enum ClipMode {ClipModeClamp, ClipModeThreshold};
...

int lowClipMode, highClipMode;
double lowClipValue, highClipValue;
getIntegerParam(NDPluginProcessLowClipMode, lowClipMode);
getIntegerParam(NDPluginProcessHighClipMode, highClipMode);
lowClipValue  = (lowClipMode == ClipModeThreshold) ? 0 : lowClip;
highClipValue  = (highClipMode == ClipModeThreshold) ? 0 : highClip;

...
        if (enableHighClip && (value > highClip)) value = highClipValue;
        if (enableLowClip  && (value < lowClip))  value = lowClipValue;
MarkRivers commented 1 year ago

I think it would be better to make this more general than replacing with 0 or the clip value. Users might want to replace the clip values with non-zero user-specified values, for example -1, -2, etc.

I will work on this soon.

xiaoqiangwang commented 1 year ago

Implemented eb74e5f