38 #ifndef __usImageRF3D_h_
39 #define __usImageRF3D_h_
43 #include <visp3/ustk_core/usImageRF2D.h>
45 #include <visp3/ustk_core/usImagePreScanSettings.h>
46 #include <visp3/ustk_core/usMotorSettings.h>
141 usImageRF3D(
unsigned int height,
unsigned int width,
unsigned int numberOfFrames);
142 usImageRF3D(
unsigned int height,
unsigned int width,
unsigned int numberOfFrames,
164 Type
operator()(
unsigned int i,
unsigned int indexJ,
unsigned int k)
const;
165 void operator()(
unsigned int i,
unsigned int indexJ,
unsigned int k,
const Type &value);
170 void resize(
unsigned int height,
unsigned int width,
unsigned int numberOfFrames);
173 void init(
unsigned int height,
unsigned int width,
unsigned int numberOfFrames);
175 unsigned int m_width;
176 unsigned int m_height;
177 unsigned int m_numberOfFrames;
187 template <
class Type>
197 template <
class Type>
202 resize(height, width, numberOfFrames);
213 template <
class Type>
217 m_numberOfFrames(0), m_size(0), bitmap(NULL), framPointer(NULL)
220 throw(vpException(vpException::badValue,
"3D RF image U-size differ from transducer scanline number"));
222 throw(vpException(vpException::badValue,
"3D RF image W-size differ from motor frame number"));
224 init(height, width, numberOfFrames);
231 template <
class Type>
237 memcpy(bitmap, other.
getConstData(), (
size_t)(m_width * m_height * m_numberOfFrames *
sizeof(Type)));
250 delete[] framPointer;
265 memcpy(bitmap, other.
getConstData(), (
size_t)(m_width * m_height * m_numberOfFrames *
sizeof(Type)));
283 if (!usImagePreScanSettings::operator==(other))
285 if (!usMotorSettings::operator==(other))
289 if (this->m_width != other.
getWidth())
297 for (
unsigned int i = 0; i < m_size; i++) {
298 if (bitmap[i] != other.bitmap[i]) {
309 template <
class Type> std::ostream &operator<<(std::ostream &out,
const usImageRF3D<Type> &image)
311 return out <<
"width : " << image.
getWidth() <<
"\nheight : " << image.
getHeight()
329 if (scanLineNumber != m_width)
330 resize(getHeight(), scanLineNumber, getNumberOfFrames());
342 if (frameNumber != m_numberOfFrames)
343 resize(getHeight(), getWidth(), frameNumber);
356 template <
class Type>
359 init(height, width, numberOfFrames);
372 if (index > this->getNumberOfFrames())
373 throw(vpException(vpException::badValue,
"usImageRF3D::insertFrame : frame index out of volume"));
375 if (frame.
getHeight() != this->getHeight() || frame.
getWidth() != this->getWidth())
376 throw(vpException(vpException::badValue,
"usImageRF3D::insertFrame : frame size don't match volume size"));
379 int offset = index * this->getHeight() * this->getWidth();
380 Type *frameBeginning = bitmap + offset;
383 for (
unsigned int i = 0; i < this->getHeight(); i++) {
384 for (
unsigned int j = 0; j < this->getWidth(); j++) {
385 frameBeginning[i + this->getHeight() * j] = frame(i, j);
398 if (index > this->getNumberOfFrames())
399 throw(vpException(vpException::badValue,
"usImageRF3D::getFrame : frame index out of volume"));
401 image.
resize(this->getHeight(), this->getWidth());
406 int offset = index * this->getHeight() * this->getWidth();
407 const Type *frameBeginning = this->getConstData() + offset;
410 for (
unsigned int i = 0; i < this->getHeight(); i++) {
411 for (
unsigned int j = 0; j < this->getWidth(); j++) {
412 image(i, j, frameBeginning[i + this->getHeight() * j]);
434 template <
class Type>
void usImageRF3D<Type>::init(
unsigned int height,
unsigned int width,
unsigned int numberOfFrames)
436 if ((width != this->m_width) || (height != this->m_height) || (numberOfFrames != this->m_numberOfFrames)) {
437 if (bitmap != NULL) {
441 if (framPointer != NULL) {
442 delete[] framPointer;
447 this->m_width = width;
448 this->m_height = height;
449 this->m_numberOfFrames = numberOfFrames;
451 m_size = m_width * m_height * m_numberOfFrames;
454 bitmap =
new Type[m_size];
456 if (framPointer == NULL)
457 framPointer =
new Type *[numberOfFrames];
459 for (
unsigned int k = 0; k < numberOfFrames; k++)
460 framPointer[k] = bitmap + m_width * m_height * k;
462 if (bitmap == NULL) {
463 throw(vpException(vpException::memoryAllocationError,
"cannot allocate bitmap "));
505 bool indexOK = j < m_width && i < m_height && k < m_numberOfFrames;
507 throw(vpException(vpException::dimensionError,
"usImageRF3D : accessing a voxel out of range !"));
509 return framPointer[k][m_height * j + i];
519 template <
class Type>
522 bool indexOK = j < m_width && i < m_height && k < m_numberOfFrames;
524 throw(vpException(vpException::dimensionError,
"usImageRF3D : trying to write in a voxel out of range !"));
525 framPointer[k][m_height * j + i] = value;
Settings associated to ultrasound pre-scan images implemented in usImageRF2D, usImageRF3D,...
void setImagePreScanSettings(const usImagePreScanSettings &preScanSettings)
usImagePreScanSettings & operator=(const usImagePreScanSettings &other)
2D Radio Frequence (RF) ultrasound image.
unsigned int getHeight() const
void resize(const unsigned int height, const unsigned int width)
unsigned int getWidth() const
3D Radio Frequence (RF) ultrasound image.
bool operator==(const usImageRF3D< Type > &other)
usImageRF3D< Type > & operator=(const usImageRF3D< Type > &other)
void setScanLineNumber(unsigned int scanLineNumber)
usImageRF3D(unsigned int height, unsigned int width, unsigned int numberOfFrames, const usImagePreScanSettings &imageSettings, const usMotorSettings &motorSettings)
Type operator()(unsigned int i, unsigned int indexJ, unsigned int k) const
Access operator for value in voxel (i, j, k)
void getFrame(usImageRF2D< Type > &image, unsigned int index) const
void setFrameNumber(unsigned int frameNumber)
usImageRF3D(const usImageRF3D< Type > &other)
void operator()(unsigned int i, unsigned int indexJ, unsigned int k, const Type &value)
Set value in voxel (i, j, k)
void insertFrame(const usImageRF2D< short > &frame, unsigned int index)
usImageRF3D(unsigned int height, unsigned int width, unsigned int numberOfFrames)
unsigned int getWidth() const
unsigned int getSize() const
friend class usRawFileParser
const Type * getConstData() const
void resize(unsigned int height, unsigned int width, unsigned int numberOfFrames)
unsigned int getHeight() const
unsigned int getRFSampleNumber() const
unsigned int getNumberOfFrames() const
Generic class for 3D ultrasound motor settings associated to the 3D probe used during acquisition.
usMotorSettings & operator=(const usMotorSettings &other)
unsigned int getFrameNumber() const
void setFrameNumber(unsigned int frameNumber)
unsigned int getScanLineNumber() const
void setScanLineNumber(unsigned int scanLineNumber)