00001
00002 #ifndef vgui_range_map_h
00003 #define vgui_range_map_h
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 #include <vxl_config.h>
00072 #include <vbl/vbl_array_1d.h>
00073 #include <vgui/vgui_range_map_params.h>
00074
00075 template <class Type>
00076 class vgui_range_map : public vgui_range_map_params
00077 {
00078 public:
00079 vgui_range_map(vgui_range_map_params const& rmp);
00080 ~vgui_range_map();
00081
00082
00083 bool mapable() const {return mapable_;}
00084
00085
00086 bool table_mapable() const {return table_mapable_;}
00087
00088
00089 unsigned map_size() const {return size_;}
00090
00091
00092
00093
00094 vbl_array_1d<vxl_byte> Lmap() {return this->compute_byte_table(Type(min_L_), Type(max_L_), gamma_L_, ratio_L_);}
00095
00096 vbl_array_1d<vxl_byte> Rmap() {return this->compute_byte_table(Type(min_R_), Type(max_R_), gamma_R_, ratio_R_);}
00097
00098 vbl_array_1d<vxl_byte> Gmap() {return this->compute_byte_table(Type(min_G_), Type(max_G_), gamma_G_, ratio_G_);}
00099
00100 vbl_array_1d<vxl_byte> Bmap() {return this->compute_byte_table(Type(min_B_), Type(max_B_), gamma_B_, ratio_B_);}
00101
00102 vbl_array_1d<vxl_byte> Xmap() {return this->compute_byte_table(Type(min_X_), Type(max_X_), gamma_X_, ratio_X_);}
00103
00104
00105
00106
00107 vbl_array_1d<float> fLmap() {return this->compute_float_table(Type(min_L_), Type(max_L_), gamma_L_, ratio_L_);}
00108
00109 vbl_array_1d<float> fRmap() {return this->compute_float_table(Type(min_R_), Type(max_R_), gamma_R_, ratio_R_);}
00110
00111 vbl_array_1d<float> fGmap() {return this->compute_float_table(Type(min_G_), Type(max_G_), gamma_G_, ratio_G_);}
00112
00113 vbl_array_1d<float> fBmap() {return this->compute_float_table(Type(min_B_), Type(max_B_), gamma_B_, ratio_B_);}
00114
00115 vbl_array_1d<float> fXmap() {return this->compute_float_table(Type(min_X_), Type(max_X_), gamma_X_, ratio_X_);}
00116
00117
00118 vxl_byte map_L_pixel(const Type pix) {return this->map_pixel_byte(pix, Type(min_L_), Type(max_L_), gamma_L_, ratio_L_);}
00119
00120 vxl_byte map_R_pixel(const Type pix) {return this->map_pixel_byte(pix, Type(min_R_), Type(max_R_), gamma_R_, ratio_R_);}
00121
00122 vxl_byte map_G_pixel(const Type pix) {return this->map_pixel_byte(pix, Type(min_G_), Type(max_G_), gamma_G_, ratio_G_);}
00123
00124 vxl_byte map_B_pixel(const Type pix) {return this->map_pixel_byte(pix, Type(min_B_), Type(max_B_), gamma_B_, ratio_B_);}
00125
00126 vxl_byte map_X_pixel(const Type pix) {return this->map_pixel_byte(pix, Type(min_X_), Type(max_X_), gamma_X_, ratio_X_);}
00127
00128
00129 int offset();
00130
00131 private:
00132 vgui_range_map();
00133
00134 void init();
00135
00136
00137 void init_map_domain(const Type min, const Type max,
00138 long double& ratio);
00139
00140
00141 vxl_byte map_pixel_byte(const Type pix, const Type min, const Type max,
00142 const float gamma, const long double ratio);
00143
00144 float map_pixel_float(const Type pix, const Type min, const Type max,
00145 const float gamma, const long double ratio);
00146
00147
00148 vbl_array_1d<vxl_byte> compute_byte_table(const Type min, const Type max,
00149 const float gamma,
00150 const long double ratio);
00151
00152
00153 vbl_array_1d<float> compute_float_table(const Type min, const Type max,
00154 const float gamma,
00155 const long double ratio);
00156
00157 bool mapable_;
00158 bool table_mapable_;
00159 unsigned size_;
00160 long double ratio_L_;
00161 long double ratio_R_;
00162 long double ratio_G_;
00163 long double ratio_B_;
00164 long double ratio_X_;
00165 };
00166
00167 #define VGUI_RANGE_MAP_INSTANTIATE(T) extern "please include vgui/vgui_range_map.txx first"
00168
00169 #endif //vgui_range_map_h