23 #ifndef SIRF_ABSTRACT_IMAGE_DATA_TYPE
24 #define SIRF_ABSTRACT_IMAGE_DATA_TYPE
26 #include "sirf/common/ANumRef.h"
27 #include "sirf/common/DataContainer.h"
28 #include "sirf/common/ANumRef.h"
29 #include "sirf/common/GeometricalInfo.h"
41 virtual Dimensions dimensions()
const = 0;
48 virtual ANumRef& operator*() = 0;
49 virtual bool operator==(
const Iterator&)
const = 0;
50 virtual bool operator!=(
const Iterator&)
const = 0;
56 virtual const ANumRef& operator*()
const = 0;
64 virtual void scale(
float s) = 0;
65 virtual bool ordered()
const
69 void copy(Iterator_const& src, Iterator& dst, Iterator& end)
const
71 for (; dst != end; ++dst, ++src)
74 void fill(
const ImageData& im)
76 Iterator_const& src = im.begin();
77 Iterator& dst = this->begin();
78 Iterator& end = this->end();
79 for (; dst != end; ++dst, ++src)
84 Iterator& dst = this->begin();
85 Iterator& end = this->end();
87 for (; dst != end; ++dst)
98 if (gi_self != gi_other)
107 for (; x != this->end(); ++x, ++y) {
108 zx = (*x).complex_float();
109 zy = (*y).complex_float();
110 sx += std::abs(zx*zx);
111 sy += std::abs(zy*zy);
113 s += std::abs(zx*zx);
115 float t = std::max(sx, sy);
116 bool same = (s <= 1e-6*t);
119 virtual bool operator!=(
const ImageData&
id)
const
121 return !(*
this == id);
127 if (!_geom_info_sptr)
128 throw std::runtime_error(
"Geometrical info not initialised. This implies that"
129 " your constructor did not call set_up_geom_info() or there was "
130 "an error. Build in debug mode and lookout for any printed text "
131 "containing '::set_up_geom_info()'.");
132 return _geom_info_sptr;
135 std::unique_ptr<ImageData>
clone()
const
137 return std::unique_ptr<ImageData>(this->
clone_impl());
151 void set_geom_info(
const std::shared_ptr<VoxelisedGeometricalInfo3D> geom_info_sptr) { _geom_info_sptr = geom_info_sptr; }
153 std::shared_ptr<VoxelisedGeometricalInfo3D> _geom_info_sptr;
Definition: DataContainer.h:42
Definition: GeometricalInfo.h:32
Definition: ImageData.h:52
Definition: ImageData.h:44
Definition: ImageData.h:38
virtual ImageData * clone_impl() const =0
Clone helper function. Don't use.
static bool can_reorient(const VoxelisedGeometricalInfo3D &geom_1, const VoxelisedGeometricalInfo3D &geom_2, const bool throw_error)
Can reorient? (check dimensions and spacing)
Definition: ImageData.cpp:30
virtual bool operator==(const ImageData &id) const
Write image to file.
Definition: ImageData.h:92
virtual bool is_complex() const
Is complex? Unless overwridden (Gadgetron), assume not complex.
Definition: ImageData.h:140
virtual void set_up_geom_info()=0
Populate the geometrical info metadata (from the image's own metadata)
std::unique_ptr< ImageData > clone() const
Clone and return as unique pointer.
Definition: ImageData.h:135
virtual void reorient(const VoxelisedGeometricalInfo3D &)
Reorient image. Requires that dimesions and spacing match.
Definition: ImageData.cpp:25
std::shared_ptr< const VoxelisedGeometricalInfo3D > get_geom_info_sptr() const
Get geometrical info.
Definition: ImageData.h:124
void set_geom_info(const std::shared_ptr< VoxelisedGeometricalInfo3D > geom_info_sptr)
Set geom info.
Definition: ImageData.h:151
Definition: GeometricalInfo.h:50
Abstract data container.
Definition: GeometricalInfo.cpp:141