UsTK : Ultrasound ToolKit  version 2.0.1 under development (2025-02-01)
tutorial-Rf-reader.cpp
1 #include <visp3/ustk_core/usConfig.h>
2 
3 #if defined(USTK_HAVE_FFTW)
4 
5 #include <visp3/ustk_core/usImageIo.h>
6 #include <visp3/ustk_core/usImagePreScan2D.h>
7 #include <visp3/ustk_core/usImageRF2D.h>
8 #include <visp3/ustk_core/usRFToPreScan2DConverter.h>
9 #include <visp3/ustk_core/usRfReader.h>
10 
11 int main(int argc, char **argv)
12 {
13  std::string rf_filename;
14 
15  for (int i = 0; i < argc; i++) {
16  if (std::string(argv[i]) == "--input")
17  rf_filename = std::string(argv[i + 1]);
18  else if (std::string(argv[i]) == "--help") {
19  std::cout << "\nUsage: " << argv[0] << " [--input <rfData.rf>] [--help]\n" << std::endl;
20  return 0;
21  }
22  }
23 
24  // Get the ustk-dataset package path or USTK_DATASET_PATH environment variable value
25  if (rf_filename.empty()) {
26  std::string env_ipath = us::getDataSetPath();
27  if (!env_ipath.empty())
28  rf_filename = env_ipath + "/rf/signal.rf";
29  else {
30  std::cout << "You should set USTK_DATASET_PATH environment var to access to ustk dataset" << std::endl;
31  return 0;
32  }
33  }
34  // read us image
35  usImageRF2D<short int> rfImage;
36  usImageIo::read(rfImage, rf_filename);
37 
38  std::cout << rfImage;
39 
41  usRFToPreScan2DConverter converter;
42  converter.convert(rfImage, preScanImage);
43 
44  usImageIo::write(preScanImage, "test.xml");
45 
46  // wait until user closes the window
47  return 0;
48 }
49 #else
50 #include <iostream>
51 int main() { std::cout << "You should install libfftw to run the Rf to pre-scan conversion" << std::endl; }
52 #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