VMTK
importDicom.h
1 /*
2  * importDicom.h
3  *
4  * Copyright (C) 2013 Wu Shin-Ting, FEEC, Unicamp
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 /*============================================================
22  Incluir definicoes da bilbioteca gdcm
23 
24  http://www.creatis.insa-lyon.fr/software/public/Gdcm/
25  ===========================================================*/
26 #include "gdcmReader.h"
27 #include "gdcmImageReader.h"
28 #include "gdcmMediaStorage.h"
29 #include "gdcmFile.h"
30 #include "gdcmDataSet.h"
31 #include "gdcmUIDs.h"
32 #include "gdcmGlobal.h"
33 #include "gdcmModules.h"
34 #include "gdcmDefs.h"
35 #include "gdcmOrientation.h"
36 #include "gdcmVersion.h"
37 #include "gdcmMD5.h"
38 #include "gdcmSystem.h"
39 #include "gdcmDirectory.h"
40 #include "gdcmSorter.h"
41 #include "gdcmScanner.h"
42 #include "gdcmDataSet.h"
43 #include "gdcmAttribute.h"
44 
45 class Import {
46  public:
47  typedef struct ImgFormat
48  {
49  unsigned short dims[3]; // dims[0]: nrows; dims[1]: ncols; dims[2]: nplanes
50  double space[3]; // space[0]: width; space[1]: height; space[2]: depth
51  double origin[3]; // Origin
52  double dircos[3][3]; // basis vectors with respect to LPS
53  unsigned short samples; // Samples per pixel
54  unsigned short nbitsalloc; // Bits allocated
55  unsigned short nbitsstored; // Bits stored
56  unsigned short nhighbit; // High bit
57  float slope; //Rescale slope
58  float intercept; //Rescale intercept
59  unsigned int length;
60  char *buffer;
61  int umin, umax;
62  } ImgFormat;
63 
64  /*==========================================================
65  Public Methods
66  ===========================================================*/
67  Import() {};
68  ~Import() {};
69 
70  int DICOMImage (std::string &filename, ImgFormat *imgformat);
71 
72  /*==========================================================
73  Private Methods
74  ===========================================================*/
75  private:
76  bool LPS_ReorientImageVolume (ImgFormat *volData);
77  bool ReadPixelData(const gdcm::Image &image, const gdcm::DataSet &ds,
78  const gdcm::PixelFormat::ScalarType & stype,
79  unsigned short nbitsalloc, unsigned short nbitsstored,
80  float slope, float intercept,
81  unsigned int *len, char **buf,
82  int *umin, int *umax);
83  int ProcessOneFile( std::string const & filename,
84  gdcm::Defs const & defs ,
85  std::string *series_desc_str,
86  std::string *patient_name_str,
87  std::string *patient_code_str,
88  std::string *scalar,
89  gdcm::PixelFormat::ScalarType *stype,
90  ImgFormat *volData);
91  bool ValidateMediaStorageIsImage (std::string const & filename,
92  gdcm::Defs const & defs );
93  int ImportFile(std::string &filename, const gdcm::Defs &defs,
94  ImgFormat *volData);
95 };
96 
97 
~Import()
Constructor.
Definition: importDicom.h:68
int DICOMImage(std::string &filename, ImgFormat *imgformat)
Destructor.