UsTK : Ultrasound ToolKit  version 2.0.1 under development (2023-12-07)
usElastography3D.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ustk software.
4  * Copyright (C) 2016 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ustk with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * This software was developed at:
17  * Inria Rennes - Bretagne Atlantique
18  * Campus Universitaire de Beaulieu
19  * 35042 Rennes Cedex
20  * France
21  *
22  * If you have questions regarding the use of this file, please contact
23  * Inria at ustk@inria.fr
24  *
25  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27  *
28  * Authors:
29  * Marc Pouliquen
30  *
31  *****************************************************************************/
32 
33 #include <visp3/ustk_elastography/usElastography3D.h>
34 
35 #if defined(USTK_HAVE_FFTW)
36 
41 {
42  m_isloadPre = false;
43  m_isloadPost = false;
44  m_setROI = false;
45  m_framesInROI = 0;
46 }
47 
55 {
56  setPreCompression(Pre);
57  setPostCompression(Post);
58 
59  m_setROI = false;
60 }
61 
66 
72 {
73  m_Precomp = Pre;
74  m_isloadPre = true;
75 }
76 
82 {
83  m_Postcomp = Post;
84  m_isloadPost = true;
85 }
86 
91 void usElastography3D::setLSQpercentage(double per) { m_elastography2DProcessor.setLSQpercentage(per); }
92 
97 void usElastography3D::setFPS(double fps) { m_elastography2DProcessor.setFPS(fps); }
98 
103 void usElastography3D::setSamplingFrequency(double samplingFrequency)
104 {
105  m_elastography2DProcessor.setSamplingFrequency(samplingFrequency);
106 }
107 
109 {
110  m_elastography2DProcessor.setMotionEstimator(t_mest);
111 }
112 
113 double usElastography3D::getFPS(void) { return m_elastography2DProcessor.getFPS(); }
114 
115 double usElastography3D::getSamplingFrequency(void) { return m_elastography2DProcessor.getSamplingFrequency(); }
116 
117 void usElastography3D::setDecimationFactor(unsigned int decimationFactor)
118 {
119  m_elastography2DProcessor.setDecimationFactor(decimationFactor);
120 }
121 
128 {
129  if (!m_isloadPre) {
130  setPreCompression(volume);
131  } else {
132  if (m_isloadPost)
133  setPreCompression(m_Postcomp);
134  setPostCompression(volume);
135  }
136 }
137 
147 void usElastography3D::setROI(int tx, int ty, int tz, int tw, int th, int tf)
148 {
149  m_elastography2DProcessor.setROI(tx, ty, tw, th);
150  m_setROI = true;
151  m_framesInROI = tf;
152  m_frameBeginROI = tz;
153 }
154 
161 void usElastography3D::updateROIPos(int tx, int ty, int tz)
162 {
163  m_elastography2DProcessor.updateROIPos(tx, ty);
164  m_frameBeginROI = tz;
165 }
166 
172 {
173  usImageRF2D<short int> preCompressedFrame, postCompressedFrame;
174  usImage3D<unsigned char> outputVolume;
175  vpImage<unsigned char> outputFrame;
176 
177  if (m_isloadPre == true && m_isloadPost == true && m_setROI == true) {
178  for (int i = m_frameBeginROI; i < m_frameBeginROI + m_framesInROI; i++) {
179  m_Precomp.getFrame(preCompressedFrame, i);
180  m_Postcomp.getFrame(postCompressedFrame, i);
181  m_elastography2DProcessor.setPreCompression(preCompressedFrame);
182  m_elastography2DProcessor.setPostCompression(postCompressedFrame);
183 
184  outputFrame = m_elastography2DProcessor.run();
185  outputVolume.resize(outputFrame.getHeight(), outputFrame.getWidth(), m_framesInROI);
186  for (unsigned int row = 0; row < outputFrame.getHeight(); row++) {
187  for (unsigned int col = 0; col < outputFrame.getWidth(); col++) {
188  outputVolume(row, col, i - m_frameBeginROI, outputFrame[row][col]);
189  }
190  }
191  }
192  }
193 
194  return outputVolume;
195 }
196 #endif // QT
void updateROIPos(int tx, int ty, int tz)
void setSamplingFrequency(double samplingFrequency)
void setPreCompression(const usImageRF3D< short > &Pre)
usImage3D< unsigned char > run()
void setPostCompression(const usImageRF3D< short > &Post)
void setLSQpercentage(double per)
virtual ~usElastography3D()
double getSamplingFrequency(void)
void setDecimationFactor(unsigned int decimationFactor)
void updateRF(const usImageRF3D< short int > &volume)
void setFPS(double fps)
void setMotionEstimator(usElastography::MotionEstimator t_mest)
void setROI(int tx, int ty, int tz, int tw, int th, int tf)
vpImage< unsigned char > run()
void updateROIPos(int tx, int ty)
double getSamplingFrequency(void)
void setLSQpercentage(double per)
void setFPS(double fps)
void setROI(int tx, int ty, int tw, int th)
void setPreCompression(const usImageRF2D< short > &Pre)
void setSamplingFrequency(double samplingFrequency)
double getFPS(void)
void setDecimationFactor(unsigned int decimationFactor)
void setPostCompression(const usImageRF2D< short > &Post)
void setMotionEstimator(MotionEstimator t_mest)
void resize(unsigned int height, unsigned int width, unsigned int numberOfFrames)
Definition: usImage3D.h:376
void getFrame(usImageRF2D< Type > &image, unsigned int index) const
Definition: usImageRF3D.h:395