MorphoGraphX
Image.hpp
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2015 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef IMAGE_HPP
12 #define IMAGE_HPP
13 
14 #include <Config.hpp>
15 
16 #include <cuda/CudaExport.hpp>
17 #include <Vector.hpp>
18 
19 #include <QString>
20 #include <QStringList>
21 
22 namespace mgx {
23 
24 class Progress;
25 
26 typedef util::Vector<3, unsigned int> Point3u;
27 
28 mgx_EXPORT QStringList supportedImageReadFormats();
29 mgx_EXPORT QStringList supportedImageWriteFormats();
30 
31 struct Image3D {
32  Image3D();
33  Image3D(const Image3D& copy);
34  Image3D(HVecUS& data, const Point3u& size, const Point3f& step = Point3f(1, 1, 1), bool labels = false);
35 
36  ~Image3D();
37 
38  void allocate(const Point3u& size);
39  void allocate();
40 
41  void setPlane(int i)
42  {
43  if(i >= 0 and size_t(i) < size.z())
44  plane = i;
45  else
46  plane = -1;
47  }
48 
49  const ushort& operator[](int i) const {
50  return (*data)[i];
51  }
52 
53  ushort& operator[](int i) {
54  return (*data)[i];
55  }
56 
57  HVecUS* data;
58  Point3u size;
59  Point3f step;
60  Point3f origin;
61  uint minc, maxc;
62  float brightness;
63  int plane;
64  bool labels;
65 
66 protected:
67  bool allocated;
68 };
69 
70 // In case of an error, this function will throw a QString with the description of the error
71 mgx_EXPORT bool saveImage(QString filename, const Image3D& data, QString type = "CImg Auto",
72  unsigned int nb_digits = 0);
73 
74 // Save a TIFF image as a single file
75 mgx_EXPORT bool saveTIFFImage(QString filename, const Image3D& data);
76 
77 mgx_EXPORT bool loadTIFFImage(QString filename, Image3D& data, bool allocate_data = false, Progress* progress = 0);
78 mgx_EXPORT bool loadImage(QString filename, Image3D& data, bool allocate_data = false);
79 
80 mgx_EXPORT HVecUS resize(const HVecUS& data, const Point3u& before, const Point3u& after, bool center);
81 } // namespace mgx
82 
83 #endif // IMAGE_HPP
Definition: Image.hpp:31
bool labels
If the image contains labels.
Definition: Image.hpp:64
int plane
To load a 2D image in a 3D stack.
Definition: Image.hpp:63
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26
Definition: Progress.hpp:99
CU_HOST_DEVICE void z(const T &v)
Short access to the third element.
Definition: Vector.hpp:679
Defines the Vector class template This file is shared by cuda, do not include headers that nvcc can&#39;t...