UsTK : Ultrasound ToolKit  version 2.0.1 under development (2023-12-07)
usImagePreScan2D.h
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  * Pierre Chatelain
30  *
31  *****************************************************************************/
32 
38 #ifndef __usImagePreScan2D_h_
39 #define __usImagePreScan2D_h_
40 
41 #include <visp3/core/vpImage.h>
42 
43 #include <visp3/ustk_core/usImagePreScanSettings.h>
44 
105 template <class Type> class usImagePreScan2D : public vpImage<Type>, public usImagePreScanSettings
106 {
107 public:
108  // default constructors
110  // sized constructor
111  usImagePreScan2D(unsigned int height, unsigned int width);
112  // All parameters initialisation constructors
113  usImagePreScan2D(const vpImage<Type> &image, const usImagePreScanSettings &preScanSettings);
114  // usImagePreScan2D copy constructor
116 
117  // destructor
118  virtual ~usImagePreScan2D();
119 
120  // Those parameters have to be passed in the constructor.
121  unsigned int getBModeSampleNumber() const;
122 
123  // assignement
125 
126  // comparison
127  bool operator==(const usImagePreScan2D<Type> &other);
128  bool operator!=(const usImagePreScan2D<Type> &other);
129 
130  void setData(const vpImage<Type> image);
131  void setScanLineNumber(unsigned int scanLineNumber);
132 
133  // Filtering before calling vpImage::resize() to update scanLineNumber
134  void resize(const unsigned int h, const unsigned int w);
135  void resize(const unsigned int h, const unsigned int w, const Type val);
136 };
137 
141 template <class Type> usImagePreScan2D<Type>::usImagePreScan2D() : vpImage<Type>(), usImagePreScanSettings() {}
142 
147 template <class Type>
149  : vpImage<Type>(other), usImagePreScanSettings(other)
150 {
151 }
152 
158 template <class Type>
159 usImagePreScan2D<Type>::usImagePreScan2D(unsigned int height, unsigned int width)
160  : vpImage<Type>(height, width), usImagePreScanSettings()
161 {
163 }
164 
170 template <class Type>
171 usImagePreScan2D<Type>::usImagePreScan2D(const vpImage<Type> &image, const usImagePreScanSettings &preScanSettings)
172  : vpImage<Type>(image), usImagePreScanSettings(preScanSettings)
173 {
174  if (image.getWidth() != preScanSettings.getScanLineNumber())
175  throw(vpException(vpException::badValue, "Pre-scan image width differ from transducer scanline number"));
176 }
177 
182 
187 {
188  // from vpImage
189  vpImage<Type>::operator=(other);
190 
191  // from usImagePreScanSettings
193 
194  return *this;
195 }
196 
200 template <class Type> bool usImagePreScan2D<Type>::operator==(const usImagePreScan2D<Type> &other)
201 {
202  return (vpImage<Type>::operator==(other) && usImagePreScanSettings::operator==(other));
203 }
204 
208 template <class Type> bool usImagePreScan2D<Type>::operator!=(const usImagePreScan2D<Type> &other)
209 {
210  return (!operator==(other));
211 }
212 
216 template <class Type> std::ostream &operator<<(std::ostream &out, const usImagePreScan2D<Type> &other)
217 {
218  return out << static_cast<const usImagePreScanSettings &>(other)
219  << "number of B-mode samples in a scan line : " << other.getBModeSampleNumber() << std::endl
220  << "number of scan lines : " << other.getScanLineNumber() << std::endl;
221 }
222 
227 template <class Type> unsigned int usImagePreScan2D<Type>::getBModeSampleNumber() const
228 {
229  return vpImage<Type>::getHeight();
230 }
231 
236 template <class Type> void usImagePreScan2D<Type>::setData(const vpImage<Type> image)
237 {
238  vpImage<Type>::operator=(image);
239  setScanLineNumber(image.getWidth());
240 }
241 
248 template <class Type> void usImagePreScan2D<Type>::setScanLineNumber(unsigned int scanLineNumber)
249 {
250  vpImage<Type>::resize(vpImage<Type>::getHeight(), scanLineNumber);
252 }
253 
261 template <class Type> void usImagePreScan2D<Type>::resize(const unsigned int h, const unsigned int w)
262 {
264  vpImage<Type>::resize(h, w);
265 }
266 
275 template <class Type> void usImagePreScan2D<Type>::resize(const unsigned int h, const unsigned int w, const Type val)
276 {
278  vpImage<Type>::resize(h, w, val);
279 }
280 
281 #endif // __usImagePreScan2D_h_
2D pre-scan ultrasound image.
void resize(const unsigned int h, const unsigned int w)
bool operator!=(const usImagePreScan2D< Type > &other)
usImagePreScan2D(const vpImage< Type > &image, const usImagePreScanSettings &preScanSettings)
virtual ~usImagePreScan2D()
bool operator==(const usImagePreScan2D< Type > &other)
void resize(const unsigned int h, const unsigned int w, const Type val)
void setData(const vpImage< Type > image)
unsigned int getBModeSampleNumber() const
usImagePreScan2D(const usImagePreScan2D &other)
usImagePreScan2D< Type > & operator=(const usImagePreScan2D< Type > &other)
usImagePreScan2D(unsigned int height, unsigned int width)
void setScanLineNumber(unsigned int scanLineNumber)
Settings associated to ultrasound pre-scan images implemented in usImageRF2D, usImageRF3D,...
usImagePreScanSettings & operator=(const usImagePreScanSettings &other)
Class containing a set of static methods to compute various processes on RF images (gradients,...
unsigned int getScanLineNumber() const
void setScanLineNumber(unsigned int scanLineNumber)