9 #include <boost/signals2.hpp>
10 #include <boost/bind.hpp>
25 bool GetUseBackgroundSubtract ()
const {
return _useBackgroundSubtract; }
26 bool GetUseAverageBG ()
const {
return _useAverageBG; }
27 bool GetUseAutoDC ()
const {
return _useAutoDC; }
28 bool GetAutoSaveBG ()
const {
return _autoSaveBG; }
32 void SetUseBackgroundSubtract (
bool value) { _useBackgroundSubtract = value; }
33 void SetUseAverageBG (
bool value) { _useAverageBG = value; }
34 void SetUseAutoDC (
bool value) { _useAutoDC = value; }
35 void SetAutoSaveBG (
bool value) { _autoSaveBG = value; }
38 bool UpdateImage (
float* buffer =
nullptr,
int size = 0);
40 void AdjustForBackground (
const U16* raw, SGL *&inputData);
55 template <
typename T,
typename F>
59 int width = _scanProcessor->GetWidth();
60 int height = _scanProcessor->GetHeight();
62 for (
int i = 0; i < width; i++)
67 for (j = 0; j < height; j++)
69 aSum +=
static_cast<F
>(*(raw + j + i * height)) / height;
72 dcComp = aSum - _averageSum;
73 if (_scanProcessor->GetUseApodization())
76 for (j = 0; j < height; j++)
78 *(inputData + i * height + j) = _maxIntensity *
79 (
static_cast<F
>(*(raw + i * height + j)) - dcComp - _avgBgLine[j]) /
80 (dcComp - _avgBgLine[j]);
85 for (j = 0; j < height; j++)
87 *(inputData + i * height + j) =
static_cast<F
>(*(raw + i * height + j)) -
88 dcComp - _avgBgLine[j];
109 template <
typename T,
typename F>
112 long imageSize = _scanProcessor->GetWidth() *_scanProcessor->GetHeight();
113 if (_avgBgImage.size() != imageSize)
119 if (_scanProcessor->GetUseApodization())
122 for (
int i = 0; i < imageSize; i++)
124 *(inputData + i) = _maxIntensity * (
static_cast<F
>(*(raw + i)) -
125 _avgBgImage[i]) / _avgBgImage[i];
131 for (
int i = 0; i < imageSize; i++)
133 *(inputData + i) =
static_cast<F
>(*(raw + i)) - _avgBgImage[i];
145 template <
typename T,
typename F>
148 long imageSize = _scanProcessor->GetWidth() *_scanProcessor->GetHeight();
149 for (
int i = 0; i < imageSize; i++)
151 *(inputData + i) =
static_cast<F
>(*(raw + i)) - _bgImage[i];
162 template <
typename T,
typename F>
165 long imageSize = _scanProcessor->GetWidth() *_scanProcessor->GetHeight();
167 for (
int i = 0; i < imageSize; i++)
169 *(inputData + i) =
static_cast<F
>(*(raw + i));
173 virtual void InitGPUMethods (
int programIndex) { }
174 virtual void OnWidthHeightChanged (
int width,
int height) { }
176 virtual int Subtract (
const unsigned short *raw);
182 bool _useAveragedImage;
184 static std::vector<SGL> _bgImage;
185 static std::vector<SGL> _avgBgImage;
186 static std::vector<SGL> _avgBgLine;
193 static float _maxIntensity;
194 static float _averageSum;
197 static bool _useBackgroundSubtract;
198 static bool _useAverageBG;
199 static bool _useAutoDC;
200 static bool _autoSaveBG;
202 static std::mutex _mutexSubtract;
205 void SetBackgroundImagePtr (
const U16 *sourceptr);
207 virtual void InitStorage ();
208 virtual void ReleaseStorage () { }
209 virtual void UpdateBackgroundArray (
float *
Background,
float maxgb) { }
212 boost::signals2::connection _widthHeightConnection;
typedefs used across UtensilConverter
Interface of the ScanProcessor class.
Definition: Background.h:18
void BackgroundImageMethod(const T *raw, F *&inputData)
Use the entire background image frame and do a line by line subtraction with raw to get inputData.
Definition: Background.h:146
bool UpdateImage(float *buffer=nullptr, int size=0)
Update the background image.
Definition: Background.cpp:145
void BackgroundAverageMethod(const T *raw, F *&inputData)
For the averaged background, create a single a-scan by averaging the background image.
Definition: Background.h:110
void NoImageMethod(const T *raw, F *&inputData)
Just copy raw to indata.
Definition: Background.h:163
void BackgroundAverageAutoDCMethod(const T *raw, F *&inputData)
Pre-processing methods to move raw data to input data.
Definition: Background.h:56
bool GetBackgroundImage(float *buffer, int size)
Gets the one A-scan wide background image and places it in the buffer.
Definition: Background.cpp:122
void ComputeAveragedBackground()
this takes into account the apodization regardless - 4/24/2015 for apodization only need maxbg
Definition: Background.cpp:176
static int _numObjects
Reference counter to keep track of number of background objects.
Definition: Background.h:189
Class that processes scans.
Definition: ScanProcessor.h:32