UsTK : Ultrasound ToolKit  version 2.0.1 under development (2025-03-14)
testUsConfidenceMap.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ustk software.
4  * Copyright (C) 2016 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ustk with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * This software was developed at:
17  * Inria Rennes - Bretagne Atlantique
18  * Campus Universitaire de Beaulieu
19  * 35042 Rennes Cedex
20  * France
21  *
22  * If you have questions regarding the use of this file, please contact
23  * Inria at ustk@inria.fr
24  *
25  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27  *
28  * Author:
29  * Marc Pouliquen
30  *
31  *****************************************************************************/
32 #include <iostream>
33 
34 #include <visp3/ustk_confidence_map/usScanlineConfidence2D.h>
35 #include <visp3/ustk_core/usImageIo.h>
36 #include <visp3/ustk_core/usImagePreScan2D.h>
37 
38 #if defined(VISP_HAVE_XML2)
39 int main()
40 {
41  std::string filename, filenameConfidence;
42 
43  // Get the ustk-dataset package path or USTK_DATASET_PATH environment variable value
44  if (filename.empty()) {
45  std::string env_ipath = us::getDataSetPath();
46  if (!env_ipath.empty()) {
47  filename = env_ipath + "/pre-scan/2D_xml/prescan2d.xml";
48  filenameConfidence = env_ipath + "/pre-scan/2D_xml/confidenceResult/confidencePreScan.xml";
49  } else {
50  std::cout << "You should set USTK_DATASET_PATH environment var to access to ustk dataset" << std::endl;
51  return 0;
52  }
53  }
54 
55  usImagePreScan2D<unsigned char> image, confidenceTest, confidenceGroundTruth;
56  usImageIo::read(image, filename);
57  usImageIo::read(confidenceGroundTruth, filenameConfidence);
58 
59  // run confidence map
60  usScanlineConfidence2D confidenceProcess;
61  confidenceProcess.run(confidenceTest, image);
62 
63  std::cout << "Output image : \n";
64  std::cout << confidenceTest;
65  std::cout << "\nGround truth image : \n";
66  std::cout << confidenceGroundTruth;
67 
68  if (confidenceTest == confidenceGroundTruth) {
69  std::cout << "Test passed\n";
70  return 0;
71  }
72 
73  std::cout << "Test failed\n";
74  return 1;
75 }
76 #else
77 int main()
78 {
79  std::cout << "This test requires xml2 to run.\n";
80  return 0;
81 }
82 #endif
static void read(usImageRF2D< short int > &imageRf2D, const std::string &headerFileName)
Definition: usImageIo.cpp:153
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