UsTK : Ultrasound ToolKit  version 2.0.1 under development (2025-01-22)
tutorial-RFConversion3D.cpp
1 #include <visp3/ustk_core/usConfig.h>
2 
3 #ifdef USTK_HAVE_FFTW
4 
5 #include <visp3/core/vpTime.h>
6 #include <visp3/ustk_core/usImageIo.h>
7 #include <visp3/ustk_core/usRFToPostScan3DConverter.h>
8 
9 int main(int argc, char **argv)
10 {
11  std::string filename;
12 
13  for (int i = 0; i < argc; i++) {
14  if (std::string(argv[i]) == "--input")
15  filename = std::string(argv[i + 1]);
16  else if (std::string(argv[i]) == "--help") {
17  std::cout << "\nUsage: " << argv[0] << " [--input <RF3D.mhd>] [--help]\n" << std::endl;
18  return 0;
19  }
20  }
21 
22  // Get the ustk-dataset package path or USTK_DATASET_PATH environment variable value
23  if (filename.empty()) {
24  std::string env_ipath = us::getDataSetPath();
25  if (!env_ipath.empty())
26  filename = env_ipath + "/RFElasto3D/preCompressed/image00000.mhd";
27  else {
28  std::cout << "You should set USTK_DATASET_PATH environment var to access to ustk dataset" << std::endl;
29  return 0;
30  }
31  }
32 
33  usImageRF3D<short int> rfImage;
34 
36 
37  usImageIo::read(rfImage, filename);
38 
39  std::cout << "end reading" << std::endl;
40 
41  // scan-conversion
42  usRFToPreScan3DConverter converter;
43 
44  double startTime = vpTime::measureTimeMs();
45  std::cout << "init converter..." << std::endl;
46 
47  double endInitTime = vpTime::measureTimeMs();
48  std::cout << "init time (sec) = " << (endInitTime - startTime) / 1000.0 << std::endl;
49 
50  std::cout << "converting..." << std::endl;
51  converter.convert(rfImage, prescanImage);
52 
53  std::cout << prescanImage;
54 
55  double endConvertTime = vpTime::measureTimeMs();
56  std::cout << "convert time (sec) = " << (endConvertTime - endInitTime) / 1000.0 << std::endl;
57 
58  std::cout << "writing pre-scan : pre-scan.mhd in current folder" << std::endl;
59  std::string outFileName = "prescan.mhd";
60  usImageIo::write(prescanImage, outFileName);
61 
62  return 0;
63 }
64 
65 #else
66 #include <iostream>
67 int main()
68 {
69  std::cout << "You should install FFTW library to run this tutorial" << std::endl;
70  return 0;
71 }
72 
73 #endif
static void read(usImageRF2D< short int > &imageRf2D, const std::string &headerFileName)
Definition: usImageIo.cpp:153
static void write(const usImageRF2D< short > &rfImage, const std::string &headerFileName, const std::string &imageExtension2D)
Definition: usImageIo.cpp:104
3D conversion from RF signal to pre-scan image
void convert(const usImageRF3D< short int > &rfImage, usImagePreScan3D< unsigned char > &preScanImage)
VISP_EXPORT std::string getDataSetPath()
Definition: us.cpp:54