UsTK : Ultrasound ToolKit  version 2.0.1 under development (2023-12-07)
usImageIo.h
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  * Authors:
29  * Marc Pouliquen
30  *
31  *****************************************************************************/
32 
39 #ifndef __usImageIo_h_
40 #define __usImageIo_h_
41 
42 #include <string>
43 
44 #include <visp3/ustk_core/usImagePostScan2D.h>
45 #include <visp3/ustk_core/usImagePostScan3D.h>
46 #include <visp3/ustk_core/usImagePreScan2D.h>
47 #include <visp3/ustk_core/usImagePreScan3D.h>
48 #include <visp3/ustk_core/usImageRF2D.h>
49 #include <visp3/ustk_core/usImageRF3D.h>
50 #include <visp3/ustk_core/usImageSettingsXmlParser.h>
51 #include <visp3/ustk_core/usMetaHeaderParser.h>
52 
59 class VISP_EXPORT usImageIo
60 {
61 private:
62  static std::string getExtension(const std::string &filename);
63 
64 public:
67  static void read(usImageRF2D<short int> &imageRf2D, const std::string &headerFileName);
68  static void read(usImageRF3D<short> &rfImage3D, const std::string &headerFileName);
69 
70  static void write(const usImageRF2D<short> &rfImage, const std::string &headerFileName,
71  const std::string &imageExtension2D);
72  static void write(const usImageRF2D<short> &rfImage, const std::string &headerFileName);
73  static void write(const usImageRF3D<short> &rfImage3D, const std::string &headerFileName,
74  const std::string &imageExtension2D);
75  static void write(const usImageRF3D<short> &rfImage3D, const std::string &headerFileName);
76 
78 
81  static void read(usImagePreScan2D<unsigned char> &preScanImage, const std::string &headerFileName);
82  static void read(usImagePreScan3D<unsigned char> &preScanImage3D, const std::string &headerFileName);
83 
84  // Doubles types writing not implemented
85  static void read(usImagePreScan2D<double> &preScanImage, const std::string &headerFileName);
86  static void read(usImagePreScan3D<double> &preScanImage3D, const std::string &headerFileName);
87 
88  static void write(const usImagePreScan2D<unsigned char> &preScanImage, const std::string &headerFileName,
89  const std::string &imageExtension2D);
90  static void write(const usImagePreScan2D<unsigned char> &preScanImage, const std::string &headerFileName);
91 
92  static void write(const usImagePreScan3D<unsigned char> &preScanImage3D, const std::string &headerFileName,
93  const std::string &imageExtension2D);
94  static void write(const usImagePreScan3D<unsigned char> &preScanImage3D, const std::string &headerFileName);
95 
96  // Doubles types writing not implemented
97  static void write(const usImagePreScan2D<double> &preScanImage, const std::string &headerFileName,
98  const std::string &imageExtension2D);
99  static void write(const usImagePreScan2D<double> &preScanImage, const std::string &headerFileName);
100  static void write(const usImagePreScan3D<double> &preScanImage3D, const std::string &headerFileName,
101  const std::string &imageExtension2D);
102  static void write(const usImagePreScan3D<double> &preScanImage3D, const std::string &headerFileName);
104 
107  static void read(usImagePostScan2D<unsigned char> &postScanImage, const std::string &headerFileName);
108  static void read(usImagePostScan3D<unsigned char> &postScanImage3D, const std::string &headerFileName);
109 
110  static void write(const usImagePostScan2D<unsigned char> &postScanImage, const std::string &headerFileName,
111  const std::string &imageExtension2D);
112  static void write(const usImagePostScan2D<unsigned char> &postScanImage, const std::string &headerFileName);
113  static void write(const usImagePostScan3D<unsigned char> &postScanImage3D, const std::string &headerFileName,
114  const std::string &imageExtension2D);
115  static void write(const usImagePostScan3D<unsigned char> &postScanImage3D, const std::string &headerFileName);
117 
118 #ifndef DOXYGEN_SHOULD_SKIP_THIS
119  struct VolHeader {
120  int type; // Data type(0: prescan B, 1 : postscan B, 2 : rf, 3 : vel / var, 5 = B + flow RGB)
121  int volumes; // Number of volumes in the file
122  int fpv; // Number of frames per volumes
123  int w; // frame width
124  int h; // frame height
125  int ss; // sample size in bits
126  int degPerFr; // degree step between frames
127  };
128 
129  struct FrameHeader {
130  int type; // data type
131  int frames; // number of frames in file
132  int w; // width (number of scanlines or pixels)
133  int h; // height (number of samples or pixels)
134  int ss; // sample size in bits
135  int ulx; // roi - upper left (x) (unused in Propello)
136  int uly; // roi - upper left (y) (unused in Propello)
137  int urx; // roi - upper right (x) (unused in Propello)
138  int ury; // roi - upper right (y) (unused in Propello)
139  int brx; // roi - bottom right (x) (unused in Propello)
140  int bry; // roi - bottom right (y) (unused in Propello)
141  int blx; // roi - bottom left (x) (unused in Propello)
142  int bly; // roi - bottom left (y) (unused in Propello)
143  int probe; // probe identifier
144  int txf; // transmit frequency in Hz
145  int sf; // sampling frequency in Hz
146  int dr; // data rate (always fps)
147  int ld; // line density (number of scanlines at 100% sector)
148  int extra; // extra information (always 0 in Propello)
149  };
150 #endif // DOXYGEN_SHOULD_SKIP_THIS
151 
152  typedef enum { FORMAT_XML, FORMAT_MHD, FORMAT_VOL, FORMAT_RF, HEADER_FORMAT_UNKNOWN } usHeaderFormatType;
153 
154  static usHeaderFormatType getHeaderFormat(const std::string &headerfilename);
155 };
156 
157 #endif // __usImageIo_h_
Input/output operations between ultrasound data and files (header + image file).
Definition: usImageIo.h:60
static void write(const usImagePreScan2D< double > &preScanImage, const std::string &headerFileName)
static void write(const usImagePreScan3D< double > &preScanImage3D, const std::string &headerFileName)
@ FORMAT_MHD
Definition: usImageIo.h:152
3D Radio Frequence (RF) ultrasound image.
Definition: usImageRF3D.h:136
Class containing a set of static methods to compute various processes on RF images (gradients,...