MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Image.hpp
1 #ifndef IMAGE_HPP
2 #define IMAGE_HPP
3 
4 #include <Config.hpp>
5 
6 #include <cuda/CudaExport.hpp>
7 #include <Vector.hpp>
8 
9 #include <QString>
10 #include <QStringList>
11 
12 namespace mgx {
13 
14 class Progress;
15 
16 typedef util::Vector<3, unsigned int> Point3u;
17 
18 mgx_EXPORT QStringList supportedImageReadFormats();
19 mgx_EXPORT QStringList supportedImageWriteFormats();
20 
21 struct Image3D {
22  Image3D();
23  Image3D(const Image3D& copy);
24  Image3D(HVecUS& data, const Point3u& size, const Point3f& step = Point3f(1, 1, 1), bool labels = false);
25 
26  ~Image3D();
27 
28  void allocate(const Point3u& size);
29  void allocate();
30 
31  void setPlane(int i)
32  {
33  if(i >= 0 and size_t(i) < size.z())
34  plane = i;
35  else
36  plane = -1;
37  }
38 
39  const ushort& operator[](int i) const {
40  return (*data)[i];
41  }
42 
43  ushort& operator[](int i) {
44  return (*data)[i];
45  }
46 
47  HVecUS* data;
48  Point3u size;
49  Point3f step;
50  Point3f origin;
51  uint minc, maxc;
52  float brightness;
53  int plane;
54  bool labels;
55 
56 protected:
57  bool allocated;
58 };
59 
60 // In case of an error, this function will throw a QString with the description of the error
61 mgx_EXPORT bool saveImage(QString filename, const Image3D& data, QString type = "CImg Auto",
62  unsigned int nb_digits = 0);
63 
64 // Save a TIFF image as a single file
65 mgx_EXPORT bool saveTIFFImage(QString filename, const Image3D& data);
66 
67 mgx_EXPORT bool loadTIFFImage(QString filename, Image3D& data, bool allocate_data = false, Progress* progress = 0);
68 mgx_EXPORT bool loadImage(QString filename, Image3D& data, bool allocate_data = false);
69 
70 mgx_EXPORT HVecUS resize(const HVecUS& data, const Point3u& before, const Point3u& after, bool center);
71 } // namespace mgx
72 
73 #endif // IMAGE_HPP
Definition: Image.hpp:21
bool labels
If the image contains labels.
Definition: Image.hpp:54
int plane
To load a 2D image in a 3D stack.
Definition: Image.hpp:53
Definition: Progress.hpp:89
CU_HOST_DEVICE void z(const T &v)
Short access to the third element.
Definition: Vector.hpp:669
Defines the Vector class template This file is shared by cuda, do not include headers that nvcc can't...