UsTK : Ultrasound ToolKit  version 2.0.1 under development (2025-01-22)
tutorial-RFSequenceConversion2D.cpp
1 #include <visp3/ustk_core/usConfig.h>
2 
3 #ifdef USTK_HAVE_FFTW
4 
5 #include <visp3/ustk_core/usMHDSequenceReader.h>
6 #include <visp3/ustk_core/usMHDSequenceWriter.h>
7 #include <visp3/ustk_core/usRFToPreScan2DConverter.h>
8 
9 int main(int argc, char **argv)
10 {
11  std::string sequenceDirectory;
12  if (argc == 1) {
13  std::cout << "\nUsage: " << argv[0] << " [--input /path/to/mhd/sequence ] \n" << std::endl;
14  return 0;
15  }
16 
17  for (unsigned int i = 1; i < (unsigned int)argc; i++) {
18  if (std::string(argv[i]) == "--input") {
19  sequenceDirectory = std::string(argv[i + 1]);
20  i = argc;
21  } else {
22  std::cout << "\nUsage: " << argv[0] << " [--input /path/to/mhd/sequence ] \n" << std::endl;
23  return 0;
24  }
25  }
26 
27  usImageRF2D<short int> imageRF;
29  usMHDSequenceReader reader;
30  reader.setSequenceDirectory(sequenceDirectory);
31 
32  usMHDSequenceWriter writer;
33 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
34  writer.setSequenceDirectory("/tmp"); // set here your outpur directory
35 #elif defined(_WIN32)
36  writer.setSequenceDirectory("C:\\temp"); // set here your outpur directory
37 #endif
38 
39  usRFToPreScan2DConverter converter;
40 
41  uint64_t timestamp = 0;
42  int inc = 0;
43  // reading/converting loop
44  while (!reader.end()) {
45  reader.acquire(imageRF, timestamp);
46  converter.convert(imageRF, imagePreScan);
47  writer.write(imagePreScan, timestamp);
48  std::cout << "image " << inc << " successfully converted\n";
49  }
50 
51  return 0;
52 }
53 #else
54 #include <iostream>
55 int main()
56 {
57  std::cout << "this tutorial requirest RF to pre-scan conversion, so you have to install FFTW thirdparty\n";
58  return 0;
59 }
60 #endif
Reader for a sequence of images stored as mhd/raw files in a directory Image sequence files order hav...
void acquire(usImageRF2D< short int > &image, uint64_t &timestamp)
void setSequenceDirectory(const std::string sequenceDirectory)
Writer for a sequence of images stored as mhd/raw files in a directory Image filenames are set based ...
void setSequenceDirectory(const std::string sequenceDirectory)
void write(const usImageRF2D< short int > &image, const uint64_t timestamp)
2D conversion from RF signal to pre-scan image
void convert(const usImageRF2D< short int > &rfImage, usImagePreScan2D< unsigned char > &preScanImage)