12 #include <boost/shared_array.hpp> 30 #pragma warning (push) 31 #pragma warning (disable:4244) 39 template <
typename T >
40 class ImageC :
public ImageBase
92 void init(
const Self &im);
153 void copy(
const Self & im);
161 this->init(
param(im));
171 return m_data != im.m_data;
176 return m_data == im.m_data;
207 return this->
getPointer() + p[0] + this->
dim()[0] * ( p[1] + this->
dim()[1] * p[2]);
211 return this->
getPointer() + p[0] + this->
dim()[0] * ( p[1] + this->
dim()[1] * p[2]);
213 T * getUnsafePointerOf(
int n) {
return this->
getPointer() + n;}
215 const T * getUnsafePointerOf(
int n)
const {
return this->
getPointer() + n;}
232 return this->getUnsafePointerOf(p);
238 return this->getUnsafePointerOf(p);
241 void setData(T * data)
256 boost::shared_array<T> m_data;
261 template <
typename T >
274 template <
typename T >
282 template <
typename T >
300 template <
typename T >
308 T * data =
new T[dim[0]*dim[1]*dim[2]];
309 this->init(data, dim, vdim);
314 template <
typename T >
317 this->init(dim, vDim);
321 template <
typename T >
328 template <
typename T >
336 template <
typename T >
339 this->init(data, dim, vdim);
344 template <
typename T >
376 template <
typename T >
385 template <
typename T >
389 if (std::numeric_limits<T>::is_specialized)
396 for (
int i = 0; i < this->
size(); ++i)
435 template <
typename T >
441 throw std::invalid_argument(
"Unallocated image");
444 if (!((this->
dim()[0] == im.dim()[0]) &&
445 (this->
dim()[1] == im.dim()[1]) &&
446 (this->
dim()[2] == im.dim()[2]) &&
447 (this->
vdim()[0] == im.vdim()[0]) &&
448 (this->
vdim()[1] == im.vdim()[1]) &&
449 (this->
vdim()[2] == im.vdim()[2])))
451 throw std::invalid_argument(
"Incompatible images");
456 (
void*)(const_cast<T*>(im.getPointer())),
457 im.size()*
sizeof(T));
465 #pragma warning (pop)
A trait class to assign iterators to image types.
bool contains(const numeric_array< int, 3 > &p) const
bool isAllocated() const
Check whether data has been allocated or not.
void set_dim(const numeric_array< int, 3 > &dim)
const numeric_array< t_voxsize, 3 > & vdim() const
get voxel size
ConstLinearIterator< ImageC< T > > ConstLinear
ImageParameter param(const TImage &im)
Create an ImageParameter structure out of an Image.
Collects image information to create similar images.
void reset()
Set all values to default value (0 for numerical types)
Belongs to package Box Do not include directly, include til/Box.h instead.
T getUnsafeValue(const numeric_array< int, 3 > &p) const
numeric_array< t_voxsize, 3 > m_vDim
Voxel size.
void setValue(const T &v, const numeric_array< int, 3 > &p)
void set_vdim(const numeric_array< t_voxsize, 3 > &vdim)
Set the voxel coordinates.
LinearIterator< ImageC< T > > Linear
bool operator==(const Self &im) const
Check whether images point on the same buffer.
INLINE bool isAllocated(const TImage &im)
Check whether smart pointer and image are allocated.
void copy(const Self &im)
Copy an image.
const T & operator()(const numeric_array< int, 3 > &p) const
const numeric_array< int, 3 > & dim() const
get image dimension
bool operator!=(const Self &im) const
Check whether images point on the same buffer.
Collects common code accross all image classes.
const T * getPointer() const
ImageC(const Self &im)
Shallow copy.
void shallowCopy(const Self &im)
Shallow copy of an image.
Image class using contiguous memory.
ConstVolumetricIterator< ImageC< T > > ConstVolumetric
VolumetricIterator< ImageC< T > > Volumetric
void init(T *data, const numeric_array< int, 3 > &dim, const numeric_array< t_voxsize, 3 > &vdim)
T & operator()(const numeric_array< int, 3 > &p)
int size() const
Get total number of elements in image.
numeric_array< int, 3 > m_dim
Image dimensions.