UsTK : Ultrasound ToolKit  version 2.0.1 under development (2024-05-17)
usPreScanToPostScan3DConverter.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  * Jason Chevrie
30  * Marc Pouliquen
31  *
32  *****************************************************************************/
33 
39 #ifndef __usPreScanToPostScan3DConverter_h_
40 #define __usPreScanToPostScan3DConverter_h_
41 
42 #include <cmath>
43 #include <vector>
44 
45 #include <visp3/ustk_core/usConfig.h>
46 #include <visp3/ustk_core/usImagePostScan3D.h>
47 #include <visp3/ustk_core/usImagePreScan3D.h>
48 
110 {
111 public:
112  typedef enum {
121  GPU_REDUCED_LOOKUP_TABLE
122  } usConverterOptimizationMethod;
123 protected:
124 #ifndef DOXYGEN_SHOULD_SKIP_THIS
125  class usVoxelWeightAndIndex
126  {
127  friend class usPreScanToPostScan3DConverter;
128  unsigned int m_outputIndex;
129  unsigned int m_inputIndex[8];
130  double m_W[8];
131  };
132  class usVoxelWeightAndIndexReducedMemory
133  {
134  friend class usPreScanToPostScan3DConverter;
135  unsigned int m_outputIndex;
136  unsigned int m_inputIndex;
137  double m_W[3];
138  };
139 #endif
140 
143 
144 
145  std::vector<usVoxelWeightAndIndex> m_lookupTables[2];
146  std::vector<usVoxelWeightAndIndexReducedMemory> m_reducedLookupTables[2];
149 
151 
153  double m_resolution;
155 
156  unsigned int m_nbX;
157  unsigned int m_nbY;
158  unsigned int m_nbZ;
159 
161 
162 public:
164  usPreScanToPostScan3DConverter(const usImagePreScan3D<unsigned char> &preScanImage, double down);
166 
167  void convert(usImagePostScan3D<unsigned char> &postScanImage, const usImagePreScan3D<unsigned char> &preScanImage);
168 
169  void init(const usImagePreScan3D<unsigned char> &preScanImage, double down = 1);
170 
173 
174  double getResolution() const { return m_resolution; }
175 
176  void SweepInZdirection(bool flag) { m_SweepInZdirection = flag; }
177 
178 private:
179  void convertPreScanCoordToPostScanCoord(double i_preScan, double j_preScan, double k_preScan,
180  double *i_postScan = NULL, double *j_postScan = NULL,
181  double *k_postScan = NULL, bool sweepInZdirection = true);
182  void convertPostScanCoordToPreScanCoord(double x, double y, double z, double *i = NULL, double *j = NULL,
183  double *k = NULL, bool sweepInZdirection = true);
184 #ifdef USTK_HAVE_CUDA
185  void GPUDirectConversion(unsigned char *dataPost, const unsigned char *dataPre);
186 
187  void GPUFreeLookupTables();
188 
189  void GPUAllocateFullLookupTables();
190  void GPUFillFullLookupTables();
191  void GPUFullLookupTableConversion(unsigned char *dataPost, const unsigned char *dataPre);
192 
193  void GPUAllocateReducedLookupTables();
194  void GPUFillReducedLookupTables();
195  void GPUReducedLookupTableConversion(unsigned char *dataPost, const unsigned char *dataPre);
196 #endif
197 };
198 
199 #endif // __usPreScanToPostScan3DConverter_h_
std::vector< usVoxelWeightAndIndex > m_lookupTables[2]
usImagePreScan3D< unsigned char > m_VpreScan
void init(const usImagePreScan3D< unsigned char > &preScanImage, double down=1)
usConverterOptimizationMethod m_converterOptimizationMethod
void convert(usImagePostScan3D< unsigned char > &postScanImage, const usImagePreScan3D< unsigned char > &preScanImage)
std::vector< usVoxelWeightAndIndexReducedMemory > m_reducedLookupTables[2]
usConverterOptimizationMethod m_conversionOptimizationMethodUsedAtInit
usConverterOptimizationMethod setConverterOptimizationMethod() const