00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef IMAGE_STATE_FREQUENCY_DOMAIN_HH
00026 #define IMAGE_STATE_FREQUENCY_DOMAIN_HH
00027
00028 #include <ost/base.hh>
00029 #include <ost/img/point.hh>
00030 #include <ost/img/size.hh>
00031 #include <ost/img/extent.hh>
00032 #include <ost/img/pixel_sampling.hh>
00033
00034 #include "value_holder.hh"
00035 #include "index.hh"
00036
00037 namespace ost { namespace img { namespace image_state {
00038
00039
00040
00041
00042
00043 class DLLEXPORT_OST_IMG_BASE FrequencyDomain {
00044 public:
00045 FrequencyDomain(const Extent& e):
00046 extent_(Extent(e.GetSize(),Point(0,0,0))),
00047 spat_ori_(extent_.GetStart())
00048 {}
00049
00050
00051 DataDomain GetDomain() const {return FREQUENCY;}
00052
00053 void SetSpatialOrigin(const Point& o) {spat_ori_=o;}
00054
00055 Point GetSpatialOrigin() const {return spat_ori_;}
00056
00057 Extent GetExtent() const {return extent_;}
00058
00059 Extent GetLogicalExtent() const {return extent_;}
00060
00061 Extent GetPhysicalExtent() const {return extent_;}
00062
00063 template <typename V>
00064 Real GetReal(const Point &p, const ValueHolder<V>& data) const {
00065 if(extent_.Contains(p)) {
00066 return Val2Val<V,Real>(data.Value(Point2Index(p)));
00067 } else {
00068 return 0.0;
00069 }
00070 }
00071
00072 template <typename V>
00073 void SetReal(const Point &p, const Real& r, ValueHolder<V>& data) {
00074 if(extent_.Contains(p)) {
00075 data.Value(Point2Index(p))=Val2Val<Real,V>(r);
00076 }
00077 }
00078
00079 template <typename V>
00080 Complex GetComplex(const Point &p, const ValueHolder<V>& data) const {
00081 if(extent_.Contains(p)) {
00082 return Val2Val<V,Complex>(data.Value(Point2Index(p)));
00083 } else {
00084 return Complex(0.0,0.0);
00085 }
00086 }
00087
00088 template <typename V>
00089 void SetComplex(const Point &p, const Complex& c, ValueHolder<V>& data) {
00090 if(extent_.Contains(p)) {
00091 data.Value(Point2Index(p))=Val2Val<Complex,V>(c);
00092 }
00093 }
00094
00095 Index Point2Index(const Point& p) const {
00096 const Size& size=extent_.GetSize();
00097 return Index(p[0]<0 ? size[0]+p[0] : p[0],
00098 p[1]<0 ? size[1]+p[1] : p[1],
00099 p[2]<0 ? size[2]+p[2] : p[2]);
00100 }
00101
00102 private:
00103 Extent extent_;
00104 Point spat_ori_;
00105
00106 };
00107
00108 }}}
00109
00110 #endif