UsTK : Ultrasound ToolKit  version 2.0.1 under development (2025-02-01)
tutorial-RFConversion2D.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/usRFToPostScan2DConverter.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 <RF2D.rf> | <RF2D.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 + "/RFElasto/image00010.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  usImageRF2D<short int> rfImage;
34 
36 
37  // Warning : if you read .rf files, you have to fill the image settings by yourself after reading it.
38  usImageIo::read(rfImage, filename);
39 
40  std::cout << "end reading" << std::endl;
41 
42  // scan-conversion
43  usRFToPreScan2DConverter converter;
44 
45  double startTime = vpTime::measureTimeMs();
46  std::cout << "init converter..." << std::endl;
47 
48  double endInitTime = vpTime::measureTimeMs();
49  std::cout << "init time (sec) = " << (endInitTime - startTime) / 1000.0 << std::endl;
50 
51  std::cout << "converting..." << std::endl;
52  converter.convert(rfImage, prescanImage);
53 
54  std::cout << prescanImage;
55 
56  double endConvertTime = vpTime::measureTimeMs();
57  std::cout << "convert time (sec) = " << (endConvertTime - endInitTime) / 1000.0 << std::endl;
58 
59  std::cout << "writing pre-scan..." << std::endl;
60  std::string outFileName = "prescan.xml";
61  usImageIo::write(prescanImage, outFileName);
62 
63  return 0;
64 }
65 
66 #else
67 #include <iostream>
68 int main()
69 {
70  std::cout << "You should install FFTW library to run this tutorial" << std::endl;
71  return 0;
72 }
73 
74 #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
2D conversion from RF signal to pre-scan image
void convert(const usImageRF2D< short int > &rfImage, usImagePreScan2D< unsigned char > &preScanImage)
VISP_EXPORT std::string getDataSetPath()
Definition: us.cpp:54