00001 // This file is part of the imaging2 class library. 00002 // 00003 // University of Innsbruck, Infmath Imaging, 2009. 00004 // http://infmath.uibk.ac.at 00005 // 00006 // All rights reserved. 00007 00008 00009 #ifndef IMAGE_GRAYVALUE_H 00010 #define IMAGE_GRAYVALUE_H 00011 00012 #include <core/imaging2.hpp> 00013 #include <image/Image.hpp> 00014 00015 namespace imaging 00016 { 00017 class Color; 00018 00026 class GrayValue 00027 { 00028 unsigned char _value; 00029 00030 public: 00031 GrayValue() {} 00032 00034 GrayValue(const GrayValue & value) : _value(value._value) {} 00035 00037 explicit GrayValue(const Color & c_value); 00038 00040 explicit GrayValue(unsigned char value) : _value(value) {} 00041 00043 explicit GrayValue(float_t value) : _value((unsigned char)(value * 255.0)) {} 00044 00046 GrayValue & operator=(GrayValue gray_value) { _value = gray_value._value; return *this; } 00047 00049 GrayValue & operator=(unsigned char value) { *this = GrayValue(value); return *this; } 00050 00052 GrayValue & operator=(float_t value) { *this = GrayValue(value); return *this; } 00053 00055 operator unsigned char() const { return (unsigned char)(_value); } 00056 00058 operator float_t() const { return float_t(_value) / 255.0; } 00059 }; 00060 00070 typedef Image<2, GrayValue> GrayImage2d; 00071 00072 template<> 00073 void GrayImage2d::read_image(const std::string & file_name); 00074 00075 template<> 00076 void GrayImage2d::write_image(const std::string & file_name) const; 00077 00087 typedef Image<3, GrayValue> GrayImage3d; 00088 00089 template<> 00090 void GrayImage3d::read_image(const std::string & file_name); 00091 00092 template<> 00093 void GrayImage3d::write_image(const std::string & file_name) const; 00094 } 00095 00096 #endif