33 #include <visp3/ustk_core/usPostScanToPreScan2DConverter.h>
48 const int BModeSampleNumber,
const int scanLineNumber)
50 init(inputSettings, BModeSampleNumber, scanLineNumber);
57 const int BModeSampleNumber,
const int scanLineNumber,
58 const double xResolution,
const double yResolution)
60 init(transducerSettings, BModeSampleNumber, scanLineNumber, xResolution, yResolution);
75 const int BModeSampleNumber,
const int scanLineNumber)
79 m_yResolution == inputSettings.
getHeightResolution() && m_scanLineNumber == scanLineNumber &&
80 m_BModeSampleNumber == BModeSampleNumber) {
86 throw(vpException(vpException::notInitialized,
"Please fill the post-scan resplution before init the conversion."));
90 double APitch = inputSettings.
getDepth() / (double)(BModeSampleNumber);
97 double x_min = r_min * cos(t_min);
99 double y_min = r_max * sin(t_min);
102 m_iMap.resize(BModeSampleNumber, scanLineNumber);
103 m_jMap.resize(BModeSampleNumber, scanLineNumber);
106 for (
int u = 0; u < BModeSampleNumber; ++u) {
107 for (
int v = 0; v < scanLineNumber; ++v) {
118 throw(vpException(vpException::notImplementedError,
119 "Back-scan conversion is not implemented for linear transducer."));
122 m_initSettings = inputSettings;
125 m_scanLineNumber = scanLineNumber;
126 m_BModeSampleNumber = BModeSampleNumber;
138 const int scanLineNumber,
const double xResolution,
const double yResolution)
141 if (m_initSettings == transducerSettings && m_xResolution == xResolution && m_yResolution == yResolution &&
142 m_scanLineNumber == scanLineNumber && m_BModeSampleNumber == BModeSampleNumber) {
148 double APitch = transducerSettings.
getDepth() / BModeSampleNumber;
156 double x_min = r_min * cos(t_min);
158 double y_min = r_max * sin(t_min);
160 m_iMap.resize(BModeSampleNumber, scanLineNumber);
161 m_jMap.resize(BModeSampleNumber, scanLineNumber);
164 for (
int u = 0; u < BModeSampleNumber; ++u) {
165 for (
int v = 0; v < scanLineNumber; ++v) {
168 m_iMap[u][v] = (r * cos(t) - x_min) / yResolution;
169 m_jMap[u][v] = (r * sin(t) - y_min) / xResolution;
179 m_initSettings = transducerSettings;
180 m_xResolution = xResolution;
181 m_yResolution = yResolution;
182 m_scanLineNumber = scanLineNumber;
183 m_BModeSampleNumber = BModeSampleNumber;
207 imageConverted.
resize(m_BModeSampleNumber, m_scanLineNumber);
213 imageConverted[u][v] =
static_cast<unsigned char>(interpolateLinear(imageToConvert, i, j));
217 double usPostScanToPreScan2DConverter::interpolateLinear(
const vpImage<unsigned char> &I,
double x,
double y)
219 int x1 = (int)floor(x);
220 int x2 = (int)ceil(x);
221 int y1 = (int)floor(y);
222 int y2 = (int)ceil(y);
224 if ((0 <= x) && (x < I.getHeight()) && (0 <= y) && (y < I.getWidth())) {
231 if (x2 >=
static_cast<int>(I.getHeight()))
233 if (y2 >=
static_cast<int>(I.getWidth()))
241 val1 = (x2 - x) * I(x1, y1) + (x - x1) * I(x2, y1);
242 val2 = (x2 - x) * I(x1, y2) + (x - x1) * I(x2, y2);
247 return (y2 - y) * val1 + (y - y1) * val2;
double getHeightResolution() const
double getWidthResolution() const
void resize(const unsigned int h, const unsigned int w)
unsigned int getBModeSampleNumber() const
void setScanLineNumber(unsigned int scanLineNumber)
Settings associated to ultrasound pre-scan images implemented in usImageRF2D, usImageRF3D,...
void setImagePreScanSettings(const usImagePreScanSettings &preScanSettings)
void setAxialResolution(const double axialResolution)
void init(const usImagePostScan2D< unsigned char > &inputSettings, const int BModeSampleNumber, const int scanLineNumber)
~usPostScanToPreScan2DConverter()
usPostScanToPreScan2DConverter()
void convert(const usImagePostScan2D< unsigned char > &imageToConvert, usImagePreScan2D< unsigned char > &imageConverted, int preScanSamples)
Generic class for 2D ultrasound data common settings associated to the type of probe transducer used ...
void setFieldOfView(double fieldOfView)
void setTransducerConvexity(const bool isTransducerConvex)
double getFieldOfView() const
double getScanLinePitch() const
void setTransducerRadius(const double transducerRadius)
bool isTransducerConvex() const
double getTransducerRadius() const
unsigned int getScanLineNumber() const