MorphoGraphX  2.0-1-227
Image.hpp
Go to the documentation of this file.
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 Vector<3, unsigned int> Point3u;
27 
28  mgx_EXPORT QStringList supportedImageReadFormats();
29  mgx_EXPORT QStringList supportedImageWriteFormats();
30 
31  struct mgx_EXPORT 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 
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);
78  mgx_EXPORT bool loadImage(QString filename, Image3D& data, bool allocate_data = false);
79 
80  mgx_EXPORT HVecUS resize(const HVecUS& data, const Point3i& before, const Point3i& after, bool center);
81 }
82 
83 #endif
mgx::Image3D::operator[]
ushort & operator[](int i)
Definition: Image.hpp:53
mgx::uint
unsigned int uint
Definition: Geometry.hpp:41
Vector.hpp
mgx::Image3D::data
HVecUS * data
Definition: Image.hpp:57
mgx::Image3D::setPlane
void setPlane(int i)
Definition: Image.hpp:41
mgx::Image3D::allocated
bool allocated
Definition: Image.hpp:67
mgx::Image3D::labels
bool labels
If the image contains labels.
Definition: Image.hpp:64
mgx::Vector::z
CU_HOST_DEVICE void z(const T &v)
Short access to the third element.
Definition: Vector.hpp:739
mgx::HVecUS
thrust::host_vector< ushort > HVecUS
Definition: CudaExport.hpp:23
mgx::Image3D::brightness
float brightness
Definition: Image.hpp:62
mgx::ushort
unsigned short ushort
Simpler names for the various containers and iterators.
Definition: Geometry.hpp:42
mgx::Image3D::plane
int plane
To load a 2D image in a 3D stack.
Definition: Image.hpp:63
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::supportedImageReadFormats
mgx_EXPORT QStringList supportedImageReadFormats()
mgx::Point3f
Vector< 3, float > Point3f
Definition: CuttingSurface.hpp:25
mgx::Image3D::step
Point3f step
Definition: Image.hpp:59
mgx::resize
mgx_EXPORT HVecUS resize(const HVecUS &data, const Point3i &before, const Point3i &after, bool center)
mgx::Image3D::origin
Point3f origin
Definition: Image.hpp:60
CudaExport.hpp
mgx::Image3D::minc
uint minc
Definition: Image.hpp:61
mgx::saveTIFFImage
mgx_EXPORT bool saveTIFFImage(QString filename, const Image3D &data)
mgx::Image3D::size
Point3u size
Definition: Image.hpp:58
mgx::Vector< 3, uint >
mgx::Point3u
Vector< 3, uint > Point3u
Definition: Geometry.hpp:75
mgx::saveImage
mgx_EXPORT bool saveImage(QString filename, const Image3D &data, QString type="CImg Auto", unsigned int nb_digits=0)
mgx::Image3D
Definition: Image.hpp:31
mgx::supportedImageWriteFormats
mgx_EXPORT QStringList supportedImageWriteFormats()
mgx::Image3D::operator[]
const ushort & operator[](int i) const
Definition: Image.hpp:49
mgx::loadTIFFImage
mgx_EXPORT bool loadTIFFImage(QString filename, Image3D &data, bool allocate_data=false)
mgx::loadImage
mgx_EXPORT bool loadImage(QString filename, Image3D &data, bool allocate_data=false)