3d/image.hh
Go to the documentation of this file.
/* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef mia_3d_image_hh
#define mia_3d_image_hh
#include <mia/3d/vectorfield.hh>
#include <mia/3d/orientation.hh>
#include <mia/3d/rot.hh>
#include <mia/2d/image.hh>
#include <mia/3d/valueattributetranslator.hh>
#include <mia/core/pixeltype.hh>
#include <mia/core/filter.hh>
NS_MIA_BEGIN
class EXPORT_3D C3DImage : public CAttributedData
{
protected:
C3DImage(const CAttributedData& data, EPixelType type);
explicit C3DImage(EPixelType type);
C3DImage();
public:
static const char *data_descr;
typedef C3DBounds dimsize_type;
typedef std::shared_ptr<C3DImage > Pointer;
virtual ~C3DImage();
EPixelType get_pixel_type() const;
virtual size_t size() const = 0;
virtual const C3DBounds& get_size() const = 0;
virtual Pointer clone() const = 0;
C3DFVector get_voxel_size() const;
void set_voxel_size(const C3DFVector& voxel);
C3DFVector get_origin() const;
void set_origin(const C3DFVector& voxel);
C3DRotation get_rotation() const;
void set_rotation(const C3DRotation& voxel);
E3DImageOrientation get_orientation() const;
void set_orientation(E3DImageOrientation orient);
virtual std::pair<double, double> get_minmax_intensity() const = 0;
private:
EPixelType m_pixel_type;
};
typedef C3DImage::Pointer P3DImage;
typedef std::vector<P3DImage> C3DImageSeries;
typedef std::shared_ptr<C3DImageSeries> P3DImageSeries;
template <typename T>
class EXPORT_3D T3DImage : public C3DImage
{
public:
typedef C3DImage Super;
typedef typename T3DDatafield<T>::iterator iterator;
typedef typename T3DDatafield<T>::const_iterator const_iterator;
typedef typename T3DDatafield<T>::const_reference const_reference;
typedef typename T3DDatafield<T>::reference reference;
typedef typename T3DDatafield<T>::const_pointer const_pointer;
typedef typename T3DDatafield<T>::pointer pointer;
typedef typename T3DDatafield<T>::value_type value_type;
typedef typename T3DDatafield<T>::difference_type difference_type;
typedef typename T3DDatafield<T>::size_type size_type;
typedef typename T3DDatafield<T>::range_iterator range_iterator;
typedef typename T3DDatafield<T>::const_range_iterator const_range_iterator;
typedef typename T3DDatafield<T>::range_iterator_with_boundary_flag range_iterator_with_boundary_flag;
typedef typename T3DDatafield<T>::const_range_iterator_with_boundary_flag const_range_iterator_with_boundary_flag;
typedef typename T2DDatafield<T>::data_array data_array;
T3DImage(const C3DBounds& size, const T *init_data);
T3DImage(const C3DBounds& size, const CAttributedData& attr);
T3DImage(const C3DBounds& size, const data_array& init_data);
explicit T3DImage(const C3DBounds& size);
//T3DImage(const T3DDatafield<T>& size);
T3DImage(const T3DImage<T>& orig);
T3DImage(T3DImage<T>&& orig);
T3DImage& operator = (const T3DImage<T>& orig);
T3DImage& operator = (T3DImage<T>&& orig);
explicit T3DImage(const T3DDatafield<T>& orig);
T3DImage();
virtual Pointer clone() const;
void get_data_line_x(int y, int z, std::vector<T>& buffer)const;
void get_data_line_y(int x, int z, std::vector<T>& buffer)const;
void get_data_line_z(int x, int y, std::vector<T>& buffer)const;
void put_data_line_x(int y, int z, const std::vector<T>& buffer);
void put_data_line_y(int x, int z, const std::vector<T>& buffer);
void put_data_line_z(int x, int y, const std::vector<T>& buffer);
T2DImage<T> get_data_plane_xy(size_t z)const;
T2DImage<T> get_data_plane_yz(size_t x)const;
T2DImage<T> get_data_plane_xz(size_t y)const;
void put_data_plane_xy(size_t z, const T2DImage<T>& p);
void put_data_plane_yz(size_t x, const T2DImage<T>& p);
void put_data_plane_xz(size_t y, const T2DImage<T>& p);
const_reference operator()(size_t x, size_t y, size_t z) const
{
return m_image(x, y, z);
}
reference operator()(size_t x, size_t y, size_t z)
{
return m_image(x, y, z);
}
const_reference operator()(const C3DBounds& l) const
{
return m_image(l.x, l.y, l.z);
}
reference operator()(const C3DBounds& l)
{
return m_image(l.x, l.y, l.z);
}
const_iterator begin()const
{
return m_image.begin();
}
const_iterator end()const
{
return m_image.end();
}
range_iterator begin_range(const C3DBounds& begin, const C3DBounds& end)
{
return m_image.begin_range(begin, end);
}
range_iterator end_range(const C3DBounds& begin, const C3DBounds& end)
{
return m_image.end_range(begin, end);
}
const_range_iterator begin_range(const C3DBounds& begin, const C3DBounds& end)const
{
return m_image.begin_range(begin, end);
}
const_range_iterator end_range(const C3DBounds& begin, const C3DBounds& end) const
{
return m_image.end_range(begin, end);
}
range_iterator_with_boundary_flag begin_range_with_boundary_flags(const C3DBounds& begin, const C3DBounds& end)
{
return m_image.begin_range_with_boundary_flags(begin, end);
}
range_iterator_with_boundary_flag end_range_with_boundary_flags(const C3DBounds& begin, const C3DBounds& end)
{
return m_image.end_range_with_boundary_flags(begin, end);
}
const_range_iterator_with_boundary_flag begin_range_with_boundary_flags(const C3DBounds& begin, const C3DBounds& end)const
{
return m_image.begin_range_with_boundary_flags(begin, end);
}
const_range_iterator_with_boundary_flag end_range_with_boundary_flags(const C3DBounds& begin, const C3DBounds& end)const
{
return m_image.end_range_with_boundary_flags(begin, end);
}
size_t size() const;
iterator begin()
{
return m_image.begin();
}
iterator end()
{
return m_image.end();
}
const_iterator begin_at(size_t x, size_t y, size_t z) const
{
return m_image.begin_at(x, y, z);
}
iterator begin_at(size_t x, size_t y, size_t z)
{
return m_image.begin_at(x, y, z);
}
const_reference operator[](int i)const
{
return m_image[i];
}
reference operator[](int i)
{
return m_image[i];
}
const T3DDatafield<T>& data() const;
//T3DDatafield<T>& data();
C3DFVector get_gradient(int index) const
{
return m_image.template get_gradient<float>(index);
}
virtual const C3DBounds& get_size() const;
std::pair<double, double> get_minmax_intensity() const;
private:
T3DDatafield<T> m_image;
};
template <typename O>
struct FConvert3DImageToPixeltypeO: public TFilter<T3DImage<O>> {
template <typename T>
T3DImage<O> operator () (const T3DImage<T>& image) const
{
T3DImage<O> result(image.get_size(), image);
copy(image.begin(), image.end(), result.begin());
return result;
}
T3DImage<O> operator () (const C3DImage& image) const
{
return filter(*this, image);
}
T3DImage<O> operator () (P3DImage image) const
{
return filter(*this, *image);
}
};
typedef FConvert3DImageToPixeltypeO<float> FCopy3DImageToFloatRepn;
EXPORT_3D C3DFVectorfield get_gradient(const C3DImage& image);
typedef T3DImage<bool> C3DBitImage;
typedef T3DImage<int8_t> C3DSBImage;
typedef T3DImage<uint8_t> C3DUBImage;
typedef T3DImage<int16_t> C3DSSImage;
typedef T3DImage<uint16_t> C3DUSImage;
typedef T3DImage<int32_t> C3DSIImage;
typedef T3DImage<uint32_t> C3DUIImage;
typedef T3DImage<int64_t> C3DSLImage;
typedef T3DImage<uint64_t> C3DULImage;
typedef T3DImage<float> C3DFImage;
typedef T3DImage<double> C3DDImage;
template <>
struct Binder<C3DImage> {
typedef __bind_all<T3DImage> Derived;
};
NS_MIA_END
#endif
image.hh
get_gradient
EXPORT_2D C2DFVectorfield get_gradient(const C2DImage &image)
P3DImageSeries
std::shared_ptr< C3DImageSeries > P3DImageSeries
Definition 3d/image.hh:140
C3DSLImage
T3DImage< int64_t > C3DSLImage
3D image with signed 64 bit integer values
Definition 3d/image.hh:515
FCopy3DImageToFloatRepn
FConvert3DImageToPixeltypeO< float > FCopy3DImageToFloatRepn
short name for 3DImage to float pixel repn copy functor
Definition 3d/image.hh:478
C3DUSImage
T3DImage< uint16_t > C3DUSImage
3D image with unsigned 16 bit integer values
Definition 3d/image.hh:506
C3DUBImage
T3DImage< uint8_t > C3DUBImage
3D image with unsigned 8 bit integer values
Definition 3d/image.hh:500
C3DSIImage
T3DImage< int32_t > C3DSIImage
3D image with signed 32 bit integer values
Definition 3d/image.hh:509
C3DFImage
T3DImage< float > C3DFImage
3D image with signed 32 bit floating point values
Definition 3d/image.hh:521
C3DULImage
T3DImage< uint64_t > C3DULImage
3D image with unsigned 64 bit integer values
Definition 3d/image.hh:518
C3DImageSeries
std::vector< P3DImage > C3DImageSeries
helper type for image series
Definition 3d/image.hh:139
C3DDImage
T3DImage< double > C3DDImage
3D image with signed 64 bit floating point values
Definition 3d/image.hh:524
C3DBitImage
T3DImage< bool > C3DBitImage
3D image with binary values
Definition 3d/image.hh:494
C3DSSImage
T3DImage< int16_t > C3DSSImage
3D image with signed 16 bit integer values
Definition 3d/image.hh:503
C3DSBImage
T3DImage< int8_t > C3DSBImage
3D image with signed 8 bit integer values
Definition 3d/image.hh:497
C3DUIImage
T3DImage< uint32_t > C3DUIImage
3D image with unsigned 32 bit integer values
Definition 3d/image.hh:512
P3DImage
C3DImage::Pointer P3DImage
define a shortcut to the 3D image shared pointer.
Definition 3d/image.hh:135
C3DBounds
T3DVector< unsigned int > C3DBounds
A unsinged int 3D Vector (used for 3D field sizes).
Definition 3d/vector.hh:415
C3DFVector
T3DVector< float > C3DFVector
A float 3D Vector.
Definition 3d/vector.hh:409
vectorfield.hh
C3DFVectorfield
a 3D field of floating point single accuracy 3D vectors
Definition 3d/vectorfield.hh:103
C3DImage
The generic base type of a 3D image.
Definition 3d/image.hh:47
C3DImage::get_minmax_intensity
virtual std::pair< double, double > get_minmax_intensity() const =0
C3DImage::data_descr
static const char * data_descr
data type description for the plug-in path component
Definition 3d/image.hh:68
C3DImage::get_rotation
C3DRotation get_rotation() const
C3DImage::get_orientation
E3DImageOrientation get_orientation() const
C3DImage::get_voxel_size
C3DFVector get_voxel_size() const
C3DImage::set_voxel_size
void set_voxel_size(const C3DFVector &voxel)
set the voxel size on world units
C3DImage::~C3DImage
virtual ~C3DImage()
C3DImage::set_rotation
void set_rotation(const C3DRotation &voxel)
set the rotation about the origin of the image
C3DImage::get_pixel_type
EPixelType get_pixel_type() const
C3DImage::set_orientation
void set_orientation(E3DImageOrientation orient)
C3DImage::C3DImage
C3DImage(EPixelType type)
C3DImage::clone
virtual Pointer clone() const =0
C3DImage::get_size
virtual const C3DBounds & get_size() const =0
C3DImage::Pointer
std::shared_ptr< C3DImage > Pointer
Pointer type of the image.
Definition 3d/image.hh:74
C3DImage::set_origin
void set_origin(const C3DFVector &voxel)
set the origin i.e. world units of the pixel at (0,0,0)
C3DImage::C3DImage
C3DImage(const CAttributedData &data, EPixelType type)
C3DImage::get_origin
C3DFVector get_origin() const
C3DImage::size
virtual size_t size() const =0
C3DImage::dimsize_type
C3DBounds dimsize_type
generic type for the dimension of the image
Definition 3d/image.hh:71
C3DImage::C3DImage
C3DImage()
standard constructor
C3DRotation
Definition rot.hh:31
CAttributedData
A collection of attributes.
Definition attributes.hh:260
CAttributedData::CAttributedData
CAttributedData()
CAttributedData::operator=
CAttributedData & operator=(const CAttributedData &org)
Assignemt operator.
type
range_iterator
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
T2DDatafield::begin_range
range_iterator begin_range(const C2DBounds &begin, const C2DBounds &end)
T2DDatafield::end_range
range_iterator end_range(const C2DBounds &begin, const C2DBounds &end)
T2DImage
This is the template version of a 2D image that is used for holding real data.
Definition 2d/image.hh:140
T3DDatafield
A templated class of a 3D data field.
Definition 3d/datafield.hh:83
T3DImage
Specific type of the 3D images that hold real pixel data.
Definition 3d/image.hh:150
T3DImage::put_data_line_z
void put_data_line_z(int x, int y, const std::vector< T > &buffer)
T3DImage::put_data_line_y
void put_data_line_y(int x, int z, const std::vector< T > &buffer)
T3DImage::put_data_line_x
void put_data_line_x(int y, int z, const std::vector< T > &buffer)
T3DImage::put_data_plane_xy
void put_data_plane_xy(size_t z, const T2DImage< T > &p)
forwarding function to access the underlying T3DDatafield
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::get_data_line_y
void get_data_line_y(int x, int z, std::vector< T > &buffer) const
T3DImage::get_data_line_z
void get_data_line_z(int x, int y, std::vector< T > &buffer) const
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::begin
const_iterator begin() const
constant iterator
Definition 3d/image.hh:294
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
iterator begin()
read/write iterator, issues copy-on-write
Definition 3d/image.hh:360
T3DImage::get_data_plane_xz
T2DImage< T > get_data_plane_xz(size_t y) const
forwarding function to access the underlying T3DDatafield
T3DImage::T3DImage
T3DImage(const C3DBounds &size, const T *init_data)
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
T3DImage::operator()
reference operator()(const C3DBounds &l)
element access operator - read/write
Definition 3d/image.hh:288
T3DImage::T3DImage
T3DImage()
T3DImage::T3DImage
T3DImage(const C3DBounds &size, const data_array &init_data)
T3DImage::get_data_plane_xy
T2DImage< T > get_data_plane_xy(size_t z) const
forwarding function to access the underlying T3DDatafield
T3DImage::T3DImage
T3DImage(const T3DImage< T > &orig)
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
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
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
T3DImage::get_size
virtual const C3DBounds & get_size() const
T3DImage::operator[]
reference operator[](int i)
Definition 3d/image.hh:392
T3DImage::get_data_plane_yz
T2DImage< T > get_data_plane_yz(size_t x) const
forwarding function to access the underlying T3DDatafield
T3DImage::T3DImage
T3DImage(const C3DBounds &size)
T3DImage::operator[]
const_reference operator[](int i) const
Definition 3d/image.hh:384
T3DImage::put_data_plane_xz
void put_data_plane_xz(size_t y, const T2DImage< T > &p)
forwarding function to access the underlying T3DDatafield
T3DImage::put_data_plane_yz
void put_data_plane_yz(size_t x, const T2DImage< T > &p)
forwarding function to access the underlying T3DDatafield
T3DImage::T3DImage
T3DImage(const C3DBounds &size, const CAttributedData &attr)
T3DImage::get_data_line_x
void get_data_line_x(int y, int z, std::vector< T > &buffer) const
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::end
iterator end()
read/write iterator, issues copy-on-write
Definition 3d/image.hh:366
T3DImage::Super
C3DImage Super
define the super class of this class for generic processing
Definition 3d/image.hh:153
T3DImage::T3DImage
T3DImage(const T3DDatafield< T > &orig)
T3DImage::data
const T3DDatafield< T > & data() const
read only access to the underlying data
T3DImage::end
const_iterator end() const
constant iterator
Definition 3d/image.hh:300
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
T3DImage< bool >::size
size_t size() const
T3DImage::get_gradient
C3DFVector get_gradient(int index) const
read/write access to the underlying data
Definition 3d/image.hh:407
T3DImage::operator()
reference operator()(size_t x, size_t y, size_t z)
element access operator - read/write
Definition 3d/image.hh:276
T3DImage::operator()
const_reference operator()(const C3DBounds &l) const
element access operator - read only
Definition 3d/image.hh:282
T3DImage::get_minmax_intensity
std::pair< double, double > get_minmax_intensity() const
T3DImage::clone
virtual Pointer clone() const
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
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
T3DImage::T3DImage
T3DImage(T3DImage< T > &&orig)
T3DVector::y
T y
vector element
Definition 3d/vector.hh:54
T3DVector::z
T z
vector element
Definition 3d/vector.hh:56
T3DVector::x
T x
vector element
Definition 3d/vector.hh:52
const_iterator
TPluginHandler::end
const_iterator end() const
TPluginHandler::begin
const_iterator begin() const
filter.hh
EXPORT_3D
#define EXPORT_3D
Definition defines3d.hh:45
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
get_gradient
EXPORT_3D C3DFVectorfield get_gradient(const C3DImage &image)
E3DImageOrientation
E3DImageOrientation
Definition orientation.hh:40
filter
static F::result_type filter(const F &f, const B &b)
Definition core/filter.hh:258
orientation.hh
pixeltype.hh
EPixelType
EPixelType
Definition pixeltype.hh:33
rot.hh
FConvert3DImageToPixeltypeO
functor to convert an image with an abitrary pixel type to single floating point pixels
Definition 3d/image.hh:434
FConvert3DImageToPixeltypeO::operator()
T3DImage< O > operator()(const T3DImage< T > &image) const
Definition 3d/image.hh:442
TFilter
base class for all filer type functors.
Definition core/filter.hh:70
valueattributetranslator.hh