Commit 20cac304 authored by Laurent Claustre's avatar Laurent Claustre

Enhanced Accumulation and acc_mode with new mode for threshold and/or offset...

Enhanced Accumulation and acc_mode with new mode for threshold and/or offset correction. Updated Spec and Tango for that purpose too.
parent 54cd7059
Subproject commit 063407a1cac3fd1d5ac7f3420dbb850e6781e1fc
Subproject commit 0e77dda2e575db67b49544bc8f5cca5a61263854
Subproject commit 3258a04fa3167a764c381fc6af3aa06b91e9adbc
Subproject commit 1ca5549efe2375b5721ff59df3b79a2116b861a5
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// Copyright (C) : 2009-2015
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
......@@ -48,7 +48,7 @@ namespace lima
{
DEB_CLASS_NAMESPC(DebModControl,"Accumulation::Parameters","Control");
public:
enum Mode {STANDARD,THRESHOLD_BEFORE};
enum Mode {STANDARD,THRESHOLD_BEFORE, OFFSET_THEN_THRESHOLD_BEFORE};
Parameters();
void reset();
......@@ -59,6 +59,7 @@ namespace lima
std::string savePrefix; ///< prefix filename of saturatedImageCounter (default is saturated_image_counter)
Mode mode;
long long thresholdB4Acc; ///< value used in mode THRESHOLD_BEFORE
long long offsetB4Acc; ///< value used in OFFSET_THEN_THRESHOLD_BEFORE
};
class ThresholdCallback
......@@ -100,8 +101,11 @@ namespace lima
void getMode(Parameters::Mode& mode) const;
void setMode(Parameters::Mode mode);
void getThresholdBeforeAcc(long long&) const;
void setThresholdBeforeAcc(const long long&);
void getThresholdBefore(long long&) const;
void setThresholdBefore(const long long&);
void getOffsetBefore(long long&) const;
void setOffsetBefore(const long long&);
// --- variable and data result of Concatenation or Accumulation
......@@ -169,6 +173,7 @@ namespace lima
void _accFrame(Data &src,Data &dst);
void _accFrameWithThreshold(Data &src,Data &dst,long long threshold_value);
void _accFrameWithOffsetThenThreshold(Data &src,Data &dst,long long offset, long long threshold_value);
void _calcSaturatedImageNCounters(Data &src,Data &dst);
inline void _callIfNeedThresholdCallback(Data &aData,long long value);
......
......@@ -31,7 +31,7 @@ public:
struct Parameters
{
enum Mode {STANDARD,THRESHOLD_BEFORE};
enum Mode {STANDARD,THRESHOLD_BEFORE, OFFSET_THEN_THRESHOLD_BEFORE};
Parameters();
void reset();
......@@ -88,8 +88,12 @@ public:
void getMode(Parameters::Mode& mode) const;
void setMode(Parameters::Mode mode);
void getThresholdBeforeAcc(long long&) const;
void setThresholdBeforeAcc(const long long&);
void getThresholdBefore(long long&) const;
void setThresholdBefore(const long long&);
void getOffsetBefore(long long&) const;
void setOffsetBefore(const long long&);
// --- variable and data result of Concatenation or Accumulation
......
......@@ -190,7 +190,8 @@ CtAccumulation::Parameters::Parameters() :
savingFlag(false),
savePrefix("saturated_"),
mode(CtAccumulation::Parameters::STANDARD),
thresholdB4Acc(0)
thresholdB4Acc(0),
offsetB4Acc(0)
{
reset();
}
......@@ -364,18 +365,30 @@ void CtAccumulation::setMode(Parameters::Mode mode)
m_pars.mode = mode;
}
void CtAccumulation::getThresholdBeforeAcc(long long& threshold) const
void CtAccumulation::getThresholdBefore(long long& threshold) const
{
AutoMutex aLock(m_cond.mutex());
threshold = m_pars.thresholdB4Acc;
}
void CtAccumulation::setThresholdBeforeAcc(const long long& threshold)
void CtAccumulation::setThresholdBefore(const long long& threshold)
{
AutoMutex aLock(m_cond.mutex());
m_pars.thresholdB4Acc = threshold;
}
void CtAccumulation::getOffsetBefore(long long& offset) const
{
AutoMutex aLock(m_cond.mutex());
offset = m_pars.offsetB4Acc;
}
void CtAccumulation::setOffsetBefore(const long long& offset)
{
AutoMutex aLock(m_cond.mutex());
m_pars.offsetB4Acc = offset;
}
/** @brief read the saturated image of accumulated image which id is frameNumber
@param saturatedImage the saturated image conter (empty if not yet available)
@param frameNumber the frame acquisition id
......@@ -642,6 +655,8 @@ bool CtAccumulation::_newBaseFrameReady(Data &aData)
saturatedImg = m_saturated_images.back();
Parameters::Mode aMode = m_pars.mode;
long long threshold_value = m_pars.thresholdB4Acc;
long long offset_value = m_pars.offsetB4Acc;
aLock.unlock();
if(active)
......@@ -652,7 +667,9 @@ bool CtAccumulation::_newBaseFrameReady(Data &aData)
case Parameters::STANDARD:
_accFrame(aData,accFrame);break;
case Parameters::THRESHOLD_BEFORE:
_accFrameWithThreshold(aData,accFrame,threshold_value);break;
_accFrameWithThreshold(aData,accFrame, threshold_value);break;
case Parameters::OFFSET_THEN_THRESHOLD_BEFORE:
_accFrameWithOffsetThenThreshold(aData,accFrame,offset_value, threshold_value);break;
}
if(!((aData.frameNumber + 1) % nb_acc_frame))
......@@ -748,6 +765,41 @@ void CtAccumulation::_accFrameWithThreshold(Data &src,Data &dst,long long thresh
THROW_CTL_ERROR(Error) << "Data type for accumulation is not yet managed";
}
}
template <class SrcType, class DstType>
void accumulateFrameOffsetThenThreshold(void *src_ptr,void *dst_ptr,int nb_items,long long offset, long long threshold)
{
SrcType *sp = (SrcType *) src_ptr;
DstType *dp = (DstType *) dst_ptr;
DstType tmp_d;
for(int i = nb_items;i;--i,++sp,++dp)
{
tmp_d = DstType(*sp) - offset;
if(tmp_d > threshold)
*dp += tmp_d;
}
}
void CtAccumulation::_accFrameWithOffsetThenThreshold(Data &src,Data &dst,long long offset_value, long long threshold_value)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR2(src,dst);
int nb_items = src.dimensions[0] * src.dimensions[1];
switch(src.type)
{
case Data::UINT8: accumulateFrameOffsetThenThreshold<unsigned char,int> (src.data(),dst.data(),nb_items,offset_value, threshold_value);break;
case Data::INT8: accumulateFrameOffsetThenThreshold<char,int> (src.data(),dst.data(),nb_items,offset_value, threshold_value);break;
case Data::UINT16: accumulateFrameOffsetThenThreshold<unsigned short,int> (src.data(),dst.data(),nb_items,offset_value, threshold_value);break;
case Data::INT16: accumulateFrameOffsetThenThreshold<short,int> (src.data(),dst.data(),nb_items,offset_value, threshold_value);break;
case Data::UINT32: accumulateFrameOffsetThenThreshold<unsigned int,int> (src.data(),dst.data(),nb_items,offset_value, threshold_value);break;
case Data::INT32: accumulateFrameOffsetThenThreshold<int,int> (src.data(),dst.data(),nb_items,offset_value, threshold_value);break;
default:
THROW_CTL_ERROR(Error) << "Data type for accumulation is not yet managed";
}
}
#ifdef WITH_CONFIG
CtConfig::ModuleTypeCallback* CtAccumulation::_getConfigHandler()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment