My Project
3d/image.hh
Go to the documentation of this file.
1 /* -*- mia-c++ -*-
2  *
3  * This file is part of MIA - a toolbox for medical image analysis
4  * Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
5  *
6  * MIA 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  * (at your option) 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 MIA; if not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef mia_3d_image_hh
22 #define mia_3d_image_hh
23 
24 #include <mia/3d/vectorfield.hh>
25 #include <mia/3d/orientation.hh>
26 #include <mia/3d/rot.hh>
27 
28 #include <mia/2d/image.hh>
29 
31 #include <mia/core/pixeltype.hh>
32 #include <mia/core/filter.hh>
33 
34 
36 
47 {
48 protected:
55  C3DImage(const CAttributedData& data, EPixelType type);
56 
61  explicit C3DImage(EPixelType type);
62 
63 
65  C3DImage();
66 public:
68  static const char *data_descr;
69 
72 
74  typedef std::shared_ptr<C3DImage > Pointer;
75 
76  virtual ~C3DImage();
77 
81  EPixelType get_pixel_type() const;
82 
83 
87  virtual size_t size() const = 0;
88 
92  virtual const C3DBounds& get_size() const = 0;
93 
97  virtual Pointer clone() const = 0;
98 
100  C3DFVector get_voxel_size() const;
101 
103  void set_voxel_size(const C3DFVector& voxel);
104 
105 
107  C3DFVector get_origin() const;
108 
110  void set_origin(const C3DFVector& voxel);
111 
112 
114  C3DRotation get_rotation() const;
115 
117  void set_rotation(const C3DRotation& voxel);
118 
120  E3DImageOrientation get_orientation() const;
121 
126  void set_orientation(E3DImageOrientation orient);
127 
129  virtual std::pair<double, double> get_minmax_intensity() const = 0;
130 private:
131  EPixelType m_pixel_type;
132 };
133 
136 
137 
139 typedef std::vector<P3DImage> C3DImageSeries;
140 typedef std::shared_ptr<C3DImageSeries> P3DImageSeries;
141 
148 template <typename T>
150 {
151 public:
153  typedef C3DImage Super;
154 
156  typedef typename T3DDatafield<T>::iterator iterator;
157  typedef typename T3DDatafield<T>::const_iterator const_iterator;
158  typedef typename T3DDatafield<T>::const_reference const_reference;
159  typedef typename T3DDatafield<T>::reference reference;
160  typedef typename T3DDatafield<T>::const_pointer const_pointer;
161  typedef typename T3DDatafield<T>::pointer pointer;
162  typedef typename T3DDatafield<T>::value_type value_type;
163  typedef typename T3DDatafield<T>::difference_type difference_type;
164  typedef typename T3DDatafield<T>::size_type size_type;
165  typedef typename T3DDatafield<T>::range_iterator range_iterator;
166  typedef typename T3DDatafield<T>::const_range_iterator const_range_iterator;
167  typedef typename T3DDatafield<T>::range_iterator_with_boundary_flag range_iterator_with_boundary_flag;
168  typedef typename T3DDatafield<T>::const_range_iterator_with_boundary_flag const_range_iterator_with_boundary_flag;
169 
170  typedef typename T2DDatafield<T>::data_array data_array;
172 
178  T3DImage(const C3DBounds& size, const T *init_data);
179 
185  T3DImage(const C3DBounds& size, const CAttributedData& attr);
186 
187 
188  T3DImage(const C3DBounds& size, const data_array& init_data);
193  explicit T3DImage(const C3DBounds& size);
194 
195  //T3DImage(const T3DDatafield<T>& size);
196 
200  T3DImage(const T3DImage<T>& orig);
201 
205  T3DImage(T3DImage<T>&& orig);
206 
210  T3DImage& operator = (const T3DImage<T>& orig);
211 
216 
221  explicit T3DImage(const T3DDatafield<T>& orig);
222 
226  T3DImage();
227 
228 
230  virtual Pointer clone() const;
231 
233  void get_data_line_x(int y, int z, std::vector<T>& buffer)const;
234 
236  void get_data_line_y(int x, int z, std::vector<T>& buffer)const;
237 
239  void get_data_line_z(int x, int y, std::vector<T>& buffer)const;
240 
242  void put_data_line_x(int y, int z, const std::vector<T>& buffer);
243 
245  void put_data_line_y(int x, int z, const std::vector<T>& buffer);
246 
248  void put_data_line_z(int x, int y, const std::vector<T>& buffer);
249 
251  T2DImage<T> get_data_plane_xy(size_t z)const;
252 
254  T2DImage<T> get_data_plane_yz(size_t x)const;
255 
257  T2DImage<T> get_data_plane_xz(size_t y)const;
258 
260  void put_data_plane_xy(size_t z, const T2DImage<T>& p);
261 
263  void put_data_plane_yz(size_t x, const T2DImage<T>& p);
264 
266  void put_data_plane_xz(size_t y, const T2DImage<T>& p);
267 
268 
270  const_reference operator()(size_t x, size_t y, size_t z) const
271  {
272  return m_image(x, y, z);
273  }
274 
276  reference operator()(size_t x, size_t y, size_t z)
277  {
278  return m_image(x, y, z);
279  }
280 
282  const_reference operator()(const C3DBounds& l) const
283  {
284  return m_image(l.x, l.y, l.z);
285  }
286 
288  reference operator()(const C3DBounds& l)
289  {
290  return m_image(l.x, l.y, l.z);
291  }
292 
294  const_iterator begin()const
295  {
296  return m_image.begin();
297  }
298 
300  const_iterator end()const
301  {
302  return m_image.end();
303  }
304 
306  range_iterator begin_range(const C3DBounds& begin, const C3DBounds& end)
307  {
308  return m_image.begin_range(begin, end);
309  }
310 
312  range_iterator end_range(const C3DBounds& begin, const C3DBounds& end)
313  {
314  return m_image.end_range(begin, end);
315  }
316 
318  const_range_iterator begin_range(const C3DBounds& begin, const C3DBounds& end)const
319  {
320  return m_image.begin_range(begin, end);
321  }
322 
324  const_range_iterator end_range(const C3DBounds& begin, const C3DBounds& end) const
325  {
326  return m_image.end_range(begin, end);
327  }
328 
329 
331  range_iterator_with_boundary_flag begin_range_with_boundary_flags(const C3DBounds& begin, const C3DBounds& end)
332  {
333  return m_image.begin_range_with_boundary_flags(begin, end);
334  }
335 
337  range_iterator_with_boundary_flag end_range_with_boundary_flags(const C3DBounds& begin, const C3DBounds& end)
338  {
339  return m_image.end_range_with_boundary_flags(begin, end);
340  }
341 
342 
345  const_range_iterator_with_boundary_flag begin_range_with_boundary_flags(const C3DBounds& begin, const C3DBounds& end)const
346  {
347  return m_image.begin_range_with_boundary_flags(begin, end);
348  }
349 
351  const_range_iterator_with_boundary_flag end_range_with_boundary_flags(const C3DBounds& begin, const C3DBounds& end)const
352  {
353  return m_image.end_range_with_boundary_flags(begin, end);
354  }
355 
357  size_t size() const;
358 
360  iterator begin()
361  {
362  return m_image.begin();
363  }
364 
366  iterator end()
367  {
368  return m_image.end();
369  }
370 
372  const_iterator begin_at(size_t x, size_t y, size_t z) const
373  {
374  return m_image.begin_at(x, y, z);
375  }
376 
378  iterator begin_at(size_t x, size_t y, size_t z)
379  {
380  return m_image.begin_at(x, y, z);
381  }
382 
384  const_reference operator[](int i)const
385  {
386  return m_image[i];
387  }
388 
392  reference operator[](int i)
393  {
394  return m_image[i];
395  }
396 
398  const T3DDatafield<T>& data() const;
399 
401  //T3DDatafield<T>& data();
402 
407  C3DFVector get_gradient(int index) const
408  {
409  return m_image.template get_gradient<float>(index);
410  }
411 
413  virtual const C3DBounds& get_size() const;
414 
416  std::pair<double, double> get_minmax_intensity() const;
417 private:
418  T3DDatafield<T> m_image;
419 };
420 
421 
433 template <typename O>
434 struct FConvert3DImageToPixeltypeO: public TFilter<T3DImage<O>> {
435 
441  template <typename T>
443  {
444  T3DImage<O> result(image.get_size(), image);
445  copy(image.begin(), image.end(), result.begin());
446  return result;
447  }
448 
455  T3DImage<O> operator () (const C3DImage& image) const
456  {
457  return filter(*this, image);
458  }
459 
467  {
468  return filter(*this, *image);
469  }
470 };
471 
479 
480 
491 
492 
495 
498 
501 
504 
507 
510 
513 
516 
519 
522 
525 
531 template <>
532 struct Binder<C3DImage> {
533  typedef __bind_all<T3DImage> Derived;
534 };
535 
537 
539 
540 #endif
get_gradient
EXPORT_3D C3DFVectorfield get_gradient(const C3DImage &image)
orientation.hh
C3DImage::clone
virtual Pointer clone() const =0
C3DImage
The generic base type of a 3D image.
Definition: 3d/image.hh:46
C3DULImage
T3DImage< uint64_t > C3DULImage
3D image with unsigned 64 bit integer values
Definition: 3d/image.hh:518
T3DImage::end_range
range_iterator end_range(const C3DBounds &begin, const C3DBounds &end)
forwarding function to access the specified range of the underlying T3DDatafield
Definition: 3d/image.hh:312
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
valueattributetranslator.hh
rot.hh
T3DImage::end_range_with_boundary_flags
range_iterator_with_boundary_flag end_range_with_boundary_flags(const C3DBounds &begin, const C3DBounds &end)
Definition: 3d/image.hh:337
T2DDatafield::data_array
::std::vector< typename __holder_type_dispatch< T >::type > data_array
type for the flat reprentation of the 2D data field
Definition: 2d/datafield.hh:95
T3DImage::operator()
const_reference operator()(size_t x, size_t y, size_t z) const
element access operator - read only
Definition: 3d/image.hh:270
T3DImage::begin
iterator begin()
read/write iterator, issues copy-on-write
Definition: 3d/image.hh:360
T3DImage::operator()
const_reference operator()(const C3DBounds &l) const
element access operator - read only
Definition: 3d/image.hh:282
T3DImage::operator()
reference operator()(const C3DBounds &l)
element access operator - read/write
Definition: 3d/image.hh:288
T3DDatafield
A templated class of a 3D data field.
Definition: 3d/datafield.hh:82
T3DVector::x
T x
vector element
Definition: 3d/vector.hh:52
T3DImage::get_gradient
C3DFVector get_gradient(int index) const
read/write access to the underlying data
Definition: 3d/image.hh:407
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36
TFilter
base class for all filer type functors.
Definition: core/filter.hh:70
C3DImage::get_minmax_intensity
virtual std::pair< double, double > get_minmax_intensity() const =0
C3DFImage
T3DImage< float > C3DFImage
3D image with signed 32 bit floating point values
Definition: 3d/image.hh:521
T3DImage::begin_range_with_boundary_flags
range_iterator_with_boundary_flag begin_range_with_boundary_flags(const C3DBounds &begin, const C3DBounds &end)
Definition: 3d/image.hh:331
C3DImage::Pointer
std::shared_ptr< C3DImage > Pointer
Pointer type of the image.
Definition: 3d/image.hh:74
C3DFVectorfield
a 3D field of floating point single accuracy 3D vectors
Definition: 3d/vectorfield.hh:102
T3DImage::operator()
reference operator()(size_t x, size_t y, size_t z)
element access operator - read/write
Definition: 3d/image.hh:276
filter
static F::result_type filter(const F &f, const B &b)
Definition: core/filter.hh:258
C3DUIImage
T3DImage< uint32_t > C3DUIImage
3D image with unsigned 32 bit integer values
Definition: 3d/image.hh:512
C3DImageSeries
std::vector< P3DImage > C3DImageSeries
helper type for image series
Definition: 3d/image.hh:139
P3DImageSeries
std::shared_ptr< C3DImageSeries > P3DImageSeries
Definition: 3d/image.hh:140
C3DDImage
T3DImage< double > C3DDImage
3D image with signed 64 bit floating point values
Definition: 3d/image.hh:524
FCopy3DImageToFloatRepn
FConvert3DImageToPixeltypeO< float > FCopy3DImageToFloatRepn
short name for 3DImage to float pixel repn copy functor
Definition: 3d/image.hh:478
T3DImage::get_size
virtual const C3DBounds & get_size() const
T3DImage::operator[]
reference operator[](int i)
Definition: 3d/image.hh:392
C3DImage::get_size
virtual const C3DBounds & get_size() const =0
T3DImage::operator[]
const_reference operator[](int i) const
Definition: 3d/image.hh:384
CAttributedData::operator=
CAttributedData & operator=(const CAttributedData &org)
Assignemt operator.
C3DSBImage
T3DImage< int8_t > C3DSBImage
3D image with signed 8 bit integer values
Definition: 3d/image.hh:497
CAttributedData
A collection of attributes.
Definition: attributes.hh:259
FConvert3DImageToPixeltypeO
functor to convert an image with an abitrary pixel type to single floating point pixels
Definition: 3d/image.hh:434
T3DImage::begin_range_with_boundary_flags
const_range_iterator_with_boundary_flag begin_range_with_boundary_flags(const C3DBounds &begin, const C3DBounds &end) const
Definition: 3d/image.hh:345
C3DImage::data_descr
static const char * data_descr
data type description for the plug-in path component
Definition: 3d/image.hh:68
C3DImage::dimsize_type
C3DBounds dimsize_type
generic type for the dimension of the image
Definition: 3d/image.hh:71
T3DImage::end
const_iterator end() const
constant iterator
Definition: 3d/image.hh:300
vectorfield.hh
T3DImage::begin_range
const_range_iterator begin_range(const C3DBounds &begin, const C3DBounds &end) const
forwarding function to access the specified range of the underlying T3DDatafield
Definition: 3d/image.hh:318
T3DImage::end_range_with_boundary_flags
const_range_iterator_with_boundary_flag end_range_with_boundary_flags(const C3DBounds &begin, const C3DBounds &end) const
Definition: 3d/image.hh:351
FConvert3DImageToPixeltypeO::operator()
T3DImage< O > operator()(const T3DImage< T > &image) const
Definition: 3d/image.hh:442
EXPORT_3D
#define EXPORT_3D
Definition: defines3d.hh:45
C3DUBImage
T3DImage< uint8_t > C3DUBImage
3D image with unsigned 8 bit integer values
Definition: 3d/image.hh:500
T3DImage
Specific type of the 3D images that hold real pixel data.
Definition: 3d/image.hh:149
T3DImage::Super
C3DImage Super
define the super class of this class for generic processing
Definition: 3d/image.hh:153
T3DImage::begin_at
iterator begin_at(size_t x, size_t y, size_t z)
read/write iterator starting at the given location
Definition: 3d/image.hh:378
C3DBitImage
T3DImage< bool > C3DBitImage
3D image with binary values
Definition: 3d/image.hh:494
E3DImageOrientation
E3DImageOrientation
Definition: orientation.hh:40
T3DImage::begin_at
const_iterator begin_at(size_t x, size_t y, size_t z) const
constant iterator starting at the given location
Definition: 3d/image.hh:372
C3DSIImage
T3DImage< int32_t > C3DSIImage
3D image with signed 32 bit integer values
Definition: 3d/image.hh:509
C3DSSImage
T3DImage< int16_t > C3DSSImage
3D image with signed 16 bit integer values
Definition: 3d/image.hh:503
C3DRotation
Definition: rot.hh:30
T3DVector::y
T y
vector element
Definition: 3d/vector.hh:54
EPixelType
EPixelType
Definition: pixeltype.hh:32
T2DImage
This is the template version of a 2D image that is used for holding real data.
Definition: 2d/image.hh:139
T3DImage::end
iterator end()
read/write iterator, issues copy-on-write
Definition: 3d/image.hh:366
P3DImage
C3DImage::Pointer P3DImage
define a shortcut to the 3D image shared pointer.
Definition: 3d/image.hh:135
T3DImage::begin_range
range_iterator begin_range(const C3DBounds &begin, const C3DBounds &end)
forwarding function to access the specified range of the underlying T3DDatafield
Definition: 3d/image.hh:306
T3DImage::end_range
const_range_iterator end_range(const C3DBounds &begin, const C3DBounds &end) const
forwarding function to access the specified range of the underlying T3DDatafield
Definition: 3d/image.hh:324
T3DImage::begin
const_iterator begin() const
constant iterator
Definition: 3d/image.hh:294
image.hh
T3DVector< unsigned int >
filter.hh
C3DSLImage
T3DImage< int64_t > C3DSLImage
3D image with signed 64 bit integer values
Definition: 3d/image.hh:515
C3DUSImage
T3DImage< uint16_t > C3DUSImage
3D image with unsigned 16 bit integer values
Definition: 3d/image.hh:506
T3DVector::z
T z
vector element
Definition: 3d/vector.hh:56
C3DImage::size
virtual size_t size() const =0
pixeltype.hh