img_attributes.h
Go to the documentation of this file.
00001 #ifndef IMG_ATTRIBUTES_H_
00002 #define IMG_ATTRIBUTES_H_
00003 
00004 #include "img/img_base.h"
00005 
00006 namespace img {
00007 
00008   enum COLORSPACE {
00009     UNDEFINED,
00010     RGB,
00011     SRGB,
00012     CIE_XYZ,
00013     CIE_LAB,
00014     CIE_LUV,
00015   };
00016 
00017 template <typename ScalarType=double>
00018 class ImgAttributes
00019 {
00020 public:
00021 
00022 private:
00023   COLORSPACE _colorspace;
00024   
00025   ScalarType _gamma;
00026   
00027   ScalarType _range_min;
00028   ScalarType _range_max;
00029   
00030   ScalarType _reference_white_x;
00031   ScalarType _reference_white_y;
00032   ScalarType _reference_white_z;
00033 
00034 public:
00035   ImgAttributes()
00036   : _colorspace(UNDEFINED), _gamma(ScalarType(0.0)),
00037     _range_min(ScalarType(0.0)), _range_max(ScalarType(0.0)),
00038     _reference_white_x(ScalarType(0.0)), _reference_white_y(ScalarType(0.0)), _reference_white_z(ScalarType(0.0))
00039   {
00040     STATIC_FLOAT_OR_DOUBLE_TYPECHECK( ScalarType );
00041   }
00042   
00043   ImgAttributes(const ImgAttributes<ScalarType>  &attributes)
00044   {
00045     STATIC_FLOAT_OR_DOUBLE_TYPECHECK( ScalarType );
00046     _colorspace = attributes._colorspace;
00047     _gamma = attributes._gamma;
00048     _range_min = attributes._range_min;
00049     _range_max = attributes._range_max;
00050     _reference_white_x = attributes._reference_white_x;
00051     _reference_white_y = attributes._reference_white_y;
00052     _reference_white_z = attributes._reference_white_z;
00053   }
00054   
00055   template<typename OtherScalarType>
00056   ImgAttributes(const ImgAttributes<OtherScalarType>  &attributes)
00057   {
00058     STATIC_FLOAT_OR_DOUBLE_TYPECHECK( ScalarType );
00059     _colorspace = attributes._colorspace;
00060     _gamma = static_cast<ScalarType>(attributes._gamma);
00061     _range_min = static_cast<ScalarType>(attributes._range_min);
00062     _range_max = static_cast<ScalarType>(attributes._range_max);
00063     _reference_white_x = static_cast<ScalarType>(attributes._reference_white_x);
00064     _reference_white_y = static_cast<ScalarType>(attributes._reference_white_y);
00065     _reference_white_z = static_cast<ScalarType>(attributes._reference_white_z);
00066   }
00067   
00068   template<typename OtherScalarType> 
00069   inline ImgAttributes< ScalarType> & operator =(const ImgAttributes<OtherScalarType> &attributes)
00070   {
00071     _colorspace = attributes._colorspace;
00072     _gamma = static_cast<ScalarType>(attributes._gamma);
00073     _range_min = static_cast<ScalarType>(attributes._range_min);
00074     _range_max = static_cast<ScalarType>(attributes._range_max);
00075     _reference_white_x = static_cast<ScalarType>(attributes._reference_white_x);
00076     _reference_white_y = static_cast<ScalarType>(attributes._reference_white_y);
00077     _reference_white_z = static_cast<ScalarType>(attributes._reference_white_z);
00078   }
00079   
00080   inline void reset()
00081   {
00082     _colorspace = UNDEFINED;
00083     _gamma = ScalarType(0.0);
00084     _range_min = ScalarType(0.0);
00085     _range_max = ScalarType(0.0);
00086     _reference_white_x = ScalarType(0.0);
00087     _reference_white_y = ScalarType(0.0);
00088     _reference_white_z = ScalarType(0.0);
00089   }
00090 
00091   // getters
00092   void getColorspace(COLORSPACE &ret_colorspace) const
00093   {
00094     ret_colorspace = _colorspace;
00095   }
00096 
00097   template<typename OtherScalarType> 
00098   void getGamma(OtherScalarType &ret_gamma) const
00099   {
00100     STATIC_FLOAT_OR_DOUBLE_TYPECHECK( OtherScalarType );
00101     ret_gamma = static_cast<OtherScalarType>(_gamma);
00102   }
00103 
00104   template<typename OtherScalarType> 
00105   void getRange(OtherScalarType &ret_range_min, OtherScalarType &ret_range_max) const
00106   {
00107     STATIC_FLOAT_OR_DOUBLE_TYPECHECK( OtherScalarType );
00108     ret_range_min = static_cast<OtherScalarType>(_range_min);
00109     ret_range_max = static_cast<OtherScalarType>(_range_max);
00110   }
00111 
00112   template<typename OtherScalarType> 
00113   void getReferenceWhite(OtherScalarType &ret_reference_white_x, OtherScalarType &ret_reference_white_y, OtherScalarType &ret_reference_white_z) const
00114   {
00115     STATIC_FLOAT_OR_DOUBLE_TYPECHECK( OtherScalarType );
00116     ret_reference_white_x = static_cast<OtherScalarType>(_reference_white_x);
00117     ret_reference_white_y = static_cast<OtherScalarType>(_reference_white_y);
00118     ret_reference_white_z = static_cast<OtherScalarType>(_reference_white_z);
00119   }
00120 
00121   // setters
00122   void setColorspace(COLORSPACE arg_colorspace)
00123   {
00124     _colorspace = arg_colorspace;
00125   }
00126   
00127   void setGamma(ScalarType arg_gamma)
00128   {
00129     _gamma = arg_gamma;
00130   }
00131   
00132   void setRange(ScalarType arg_range_min, ScalarType arg_range_max)
00133   {
00134     assert(arg_range_min<=arg_range_max);
00135     _range_min = arg_range_min;
00136     _range_max = arg_range_max;
00137   }
00138   
00139   void setReferenceWhite(ScalarType arg_reference_white_x, ScalarType arg_reference_white_y, ScalarType arg_reference_white_z)
00140   {
00141     _reference_white_x = arg_reference_white_x;
00142     _reference_white_y = arg_reference_white_y;
00143     _reference_white_z = arg_reference_white_z;
00144   }
00145 
00146   void setColorspace(const ImgAttributes<ScalarType> &attributes)
00147   {
00148     _colorspace = attributes._colorspace;
00149   }
00150   
00151   void setGamma(const ImgAttributes<ScalarType> &attributes)
00152   {
00153     _gamma = attributes._gamma;
00154   }
00155   
00156   void setRange(const ImgAttributes<ScalarType> &attributes)
00157   {
00158     _range_min = attributes._range_min;
00159     _range_max = attributes._range_max;
00160   }
00161   
00162   void setReferenceWhite(const ImgAttributes<ScalarType> &attributes)
00163   {
00164     _reference_white_x = attributes._reference_white_x;
00165     _reference_white_y = attributes._reference_white_y;
00166     _reference_white_z = attributes._reference_white_z;
00167   }
00168 
00169   // checks
00170   bool hasColorspace(COLORSPACE arg_colorspace) const
00171   {
00172     return _colorspace == arg_colorspace;
00173   }
00174   
00175   bool hasGamma(ScalarType arg_gamma) const
00176   {
00177     return _gamma == arg_gamma;
00178   }
00179   
00180   
00181   bool hasRange(ScalarType arg_range_min, ScalarType arg_range_max) const
00182   {
00183     return (_range_min == arg_range_min) &&
00184            (_range_max == arg_range_max);
00185   }
00186   
00187   bool hasReferenceWhite(ScalarType arg_reference_white_x, ScalarType arg_reference_white_y, ScalarType arg_reference_white_z) const
00188   {
00189     return (_reference_white_x == arg_reference_white_x) &&
00190            (_reference_white_y == arg_reference_white_y) &&
00191            (_reference_white_z == arg_reference_white_z);
00192   }
00193   
00194   bool hasColorspace(const ImgAttributes<ScalarType> &attributes) const
00195   {
00196     return _colorspace == attributes._colorspace;
00197   }
00198   
00199   bool hasGamma(const ImgAttributes<ScalarType> &attributes) const
00200   {
00201     return _gamma == attributes._gamma;
00202   }
00203   
00204   bool hasRange(const ImgAttributes<ScalarType> &attributes) const
00205   {
00206     return (_range_min == attributes._range_min) &&
00207            (_range_max == attributes._range_max);
00208   }
00209   
00210   bool hasReferenceWhite(const ImgAttributes<ScalarType> &attributes) const
00211   {
00212     return (_reference_white_x == attributes._reference_white_x) &&
00213            (_reference_white_y == attributes._reference_white_y) &&
00214            (_reference_white_z == attributes._reference_white_z);
00215   }
00216   
00217   
00218   bool operator==(const ImgAttributes<ScalarType> &attributes) const
00219   {
00220     return hasColorspace(attributes) && 
00221            hasGamma(attributes) &&
00222            hasRange(attributes) &&
00223            hasReferenceWhite(attributes);
00224   }
00225 
00226   static ImgAttributes createImgAttributes(COLORSPACE arg_colorspace = ScalarType(UNDEFINED),
00227                                    ScalarType arg_gamma = ScalarType(0.0),
00228                                    ScalarType arg_range_min = ScalarType(0.0),
00229                                    ScalarType arg_range_max = ScalarType(0.0),
00230                                    ScalarType arg_reference_white_x = ScalarType(0.0),
00231                                    ScalarType arg_reference_white_y = ScalarType(0.0),
00232                                    ScalarType arg_reference_white_z = ScalarType(0.0))
00233   {
00234     ImgAttributes attributes;
00235     attributes.setColorspace(arg_colorspace);
00236     attributes.setGamma(arg_gamma);
00237     attributes.setRange(arg_range_min, arg_range_max);
00238     attributes.setReferenceWhite(arg_reference_white_x, arg_reference_white_y, arg_reference_white_z);
00239     return attributes;
00240   }
00241   
00242 };
00243 
00244 } // end namespace img
00245 
00246 #endif /*IMG_ATTRIBUTES_H_*/


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:31:53