UsTK : Ultrasound ToolKit  version 2.0.1 under development (2025-02-01)
tutorial-confidence-map.cpp
1 #include <iostream>
4 
5 #include <visp3/ustk_confidence_map/usScanlineConfidence2D.h>
6 #include <visp3/ustk_core/usImageIo.h>
7 #include <visp3/ustk_core/usImagePreScan2D.h>
8 
9 int main(int argc, const char *argv[])
10 {
11  std::string filename;
12 
13  // Command line options
14  for (int i = 0; i < argc; i++) {
15  if (std::string(argv[i]) == "--input")
16  filename = std::string(argv[i + 1]);
17  else if (std::string(argv[i]) == "--help") {
18  std::cout << "Usage: " << argv[0] << " [--input <filename>] [--help]" << std::endl;
19  return 0;
20  }
21  }
22 
23  // Get the ustk-dataset package path or USTK_DATASET_PATH environment variable value
24  if (filename.empty()) {
25  std::string env_ipath = us::getDataSetPath();
26  if (!env_ipath.empty())
27  filename = env_ipath + "/pre-scan/2D_xml/prescan2d.xml";
28  else {
29  std::cout << "You should set USTK_DATASET_PATH environment var to access to ustk dataset" << std::endl;
30  return 0;
31  }
32  }
33 
34  usImagePreScan2D<unsigned char> image, confidence;
35  usImageIo::read(image, filename);
36 
37  usScanlineConfidence2D confidenceProcess;
38  confidenceProcess.run(confidence, image);
39 
40  std::string outFileName = std::string("confidence.xml");
41  std::cout << " Outuput " << outFileName << " written" << std::endl;
42 
43  usImageIo::write(confidence, outFileName);
44 
45  return 0;
46 }
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
Process a pre-scan image to determine the confidence map.
void run(usImagePreScan2D< unsigned char > &preScanConfidence, const usImagePreScan2D< unsigned char > &preScanImage)
VISP_EXPORT std::string getDataSetPath()
Definition: us.cpp:54