From 40acf9ddc8f700b45d05bb2098be23a93c3bfa6a Mon Sep 17 00:00:00 2001 From: cathook Date: Fri, 27 Jun 2014 18:24:38 +0800 Subject: fix dimension size error --- doc/html/HSL__Space_8h_source.html | 196 +++++++++++++++++++------------------ 1 file changed, 100 insertions(+), 96 deletions(-) (limited to 'doc/html/HSL__Space_8h_source.html') diff --git a/doc/html/HSL__Space_8h_source.html b/doc/html/HSL__Space_8h_source.html index 4d13ede..8f7f375 100644 --- a/doc/html/HSL__Space_8h_source.html +++ b/doc/html/HSL__Space_8h_source.html @@ -28,7 +28,7 @@ Logo
Templates -- Meow -  204.13.18 +  1.2.9
A C++ template contains kinds of interesting classes and functions
@@ -74,9 +74,9 @@ $(document).ready(function(){initNavTree('HSL__Space_8h_source.html','');});
14 
22 class HSLf_Space: public Color3_Space<double> {
23 public:
-
24  HSLf_Space(): Color3_Space<double>(Vector3D<double>( 0.0, 0.0, 0.0),
-
25  Vector3D<double>(PI*2.0, 1.0, 1.0),
-
26  Vector3D<double>( 0.0, 0.0, 0.0)) {
+
24  HSLf_Space(): Color3_Space<double>(Vector3D<double>( 0.0, 0.0, 0.0),
+
25  Vector3D<double>(PI * 2.0, 1.0, 1.0),
+
26  Vector3D<double>( 0.0, 0.0, 0.0)) {
27  }
28  HSLf_Space(double c): Color3_Space<double>(Vector3D<double>( 0.0, 0.0, 0.0),
29  Vector3D<double>(PI*2.0, 1.0, 1.0),
@@ -132,95 +132,99 @@ $(document).ready(function(){initNavTree('HSL__Space_8h_source.html','');});
79  }
80 };
81 
-
85 inline void colorTransformate(RGBf_Space const& rgb, HSLf_Space* hsl) {
-
86  double r = normalize(rgb.rMin(), rgb.rMax(), rgb.r());
-
87  double g = normalize(rgb.gMin(), rgb.gMax(), rgb.g());
-
88  double b = normalize(rgb.bMin(), rgb.bMax(), rgb.b());
-
89  double mx = std::max(std::max(r, g), b);
-
90  double mn = std::min(std::min(r, g), b);
-
91  double h, s, l;
-
92  if (mx == mn ) h = 0;
-
93  else if(mx == r && g >= b) h = PI/3.0 * (g-b) / (mx-mn);
-
94  else if(mx == r && g < b) h = PI/3.0 * (g-b) / (mx-mn) + PI * 2.0;
-
95  else if(mx == g ) h = PI/3.0 * (b-r) / (mx-mn) + PI/3.0*2.0;
-
96  else h = PI/3.0 * (r-g) / (mx-mn) + PI/3.0*4.0;
-
97  l = 0.5 * (mx + mn);
-
98  if (l == 0 || mx == mn) s = 0;
-
99  else if(l < 0.5 ) s = (mx - mn) / (2.0 * l);
-
100  else s = (mx - mn) / (2 - 2.0 * l);
-
101  hsl->h(h);
-
102  hsl->s(s);
-
103  hsl->l(l);
-
104 }
-
105 
-
109 inline void colorTransformate(YUVf_Space const& yuv, HSLf_Space* hsl) {
-
110  RGBf_Space tmp;
-
111  colorTransformate(yuv, &tmp);
-
112  colorTransformate(tmp, hsl);
-
113 }
-
114 
-
118 inline void colorTransformate(HSLf_Space const& hsl, RGBf_Space* rgb) {
-
119  double h = normalize(hsl.hMin(), hsl.hMax(), hsl.h());
-
120  double s = normalize(hsl.sMin(), hsl.sMax(), hsl.s());
-
121  double l = normalize(hsl.lMin(), hsl.lMax(), hsl.l());
-
122  if(s == 0){
-
123  rgb->r(denormalize(rgb->rMin(), rgb->rMax(), l));
-
124  rgb->g(denormalize(rgb->gMin(), rgb->gMax(), l));
-
125  rgb->b(denormalize(rgb->bMin(), rgb->bMax(), l));
-
126  return ;
-
127  }
-
128  double q = (l < 0.5 ? (l * (1 + s)) : (l + s - (l * s)));
-
129  double p = 2 * l - q;
-
130  double t_r = h + 1.0 / 3.0;
-
131  double t_g = h;
-
132  double t_b = h - 1.0 / 3.0;
-
133  if(t_r < 0) t_r = t_r + 1.0;
-
134  if(t_r > 1) t_r = t_r - 1.0;
-
135  if(t_g < 0) t_g = t_g + 1.0;
-
136  if(t_g > 1) t_g = t_g - 1.0;
-
137  if(t_b < 0) t_b = t_b + 1.0;
-
138  if(t_b > 1) t_b = t_b - 1.0;
-
139  double r, g, b;
-
140  if (t_r < 1.0 / 6.0) r = p + (q - p) * 6 * t_r;
-
141  else if(t_r < 0.5 ) r = q;
-
142  else if(t_r < 2.0 / 3.0) r = p + (q - p) * 6 * (2.0 / 3.0 - t_r);
-
143  else r = p;
-
144  if (t_g < 1.0 / 6.0) g = p + (q - p) * 6 * t_g;
-
145  else if(t_g < 0.5 ) g = q;
-
146  else if(t_g < 2.0 / 3.0) g = p + (q - p) * 6 * (2.0 / 3.0 - t_g);
-
147  else g = p;
-
148  if (t_b < 1.0 / 6.0) b = p + (q - p) * 6 * t_b;
-
149  else if(t_b < 0.5 ) b = q;
-
150  else if(t_b < 2.0 / 3.0) b = p + (q - p) * 6 * (2.0 / 3.0 - t_b);
-
151  else b = p;
-
152  rgb->r(denormalize(rgb->rMin(), rgb->rMax(), r));
-
153  rgb->g(denormalize(rgb->gMin(), rgb->gMax(), g));
-
154  rgb->b(denormalize(rgb->bMin(), rgb->bMax(), b));
-
155 }
-
156 
-
160 inline void colorTransformate(HSLf_Space const& hsl, YUVf_Space* yuv) {
-
161  RGBf_Space tmp;
-
162  colorTransformate(hsl, &tmp);
-
163  colorTransformate(tmp, yuv);
-
164 }
-
165 
-
169 inline void colorTransformate(HSLf_Space const& hsl, RGBi_Space* rgb) {
-
170  RGBf_Space tmp;
-
171  colorTransformate(hsl, &tmp);
-
172  rgb->copyFrom(tmp);
-
173 }
-
174 
-
175 
-
179 inline void colorTransformate(RGBi_Space const& rgb, HSLf_Space* hsl) {
-
180  RGBf_Space tmp;
-
181  tmp.copyFrom(rgb);
-
182  colorTransformate(rgb, hsl);
-
183 }
-
184 
-
185 } // meow
-
186 
-
187 
-
188 #endif // colors_HSL_Space_H__
+
85 inline void colorTransformate(HSLf_Space const& in, HSLf_Space* out) {
+
86  *out = in;
+
87 }
+
88 
+
92 inline void colorTransformate(RGBf_Space const& rgb, HSLf_Space* hsl) {
+
93  double r = normalize(rgb.rMin(), rgb.rMax(), rgb.r());
+
94  double g = normalize(rgb.gMin(), rgb.gMax(), rgb.g());
+
95  double b = normalize(rgb.bMin(), rgb.bMax(), rgb.b());
+
96  double mx = std::max(std::max(r, g), b);
+
97  double mn = std::min(std::min(r, g), b);
+
98  double h, s, l;
+
99  if (mx == mn ) h = 0;
+
100  else if(mx == r && g >= b) h = PI/3.0 * (g-b) / (mx-mn);
+
101  else if(mx == r && g < b) h = PI/3.0 * (g-b) / (mx-mn) + PI * 2.0;
+
102  else if(mx == g ) h = PI/3.0 * (b-r) / (mx-mn) + PI/3.0*2.0;
+
103  else h = PI/3.0 * (r-g) / (mx-mn) + PI/3.0*4.0;
+
104  l = 0.5 * (mx + mn);
+
105  if (l == 0 || mx == mn) s = 0;
+
106  else if(l < 0.5 ) s = (mx - mn) / (2.0 * l);
+
107  else s = (mx - mn) / (2 - 2.0 * l);
+
108  hsl->h(h);
+
109  hsl->s(s);
+
110  hsl->l(l);
+
111 }
+
112 
+
116 inline void colorTransformate(YUVf_Space const& yuv, HSLf_Space* hsl) {
+
117  RGBf_Space tmp;
+
118  colorTransformate(yuv, &tmp);
+
119  colorTransformate(tmp, hsl);
+
120 }
+
121 
+
125 inline void colorTransformate(HSLf_Space const& hsl, RGBf_Space* rgb) {
+
126  double h = normalize(hsl.hMin(), hsl.hMax(), hsl.h());
+
127  double s = normalize(hsl.sMin(), hsl.sMax(), hsl.s());
+
128  double l = normalize(hsl.lMin(), hsl.lMax(), hsl.l());
+
129  if(s == 0){
+
130  rgb->r(denormalize(rgb->rMin(), rgb->rMax(), l));
+
131  rgb->g(denormalize(rgb->gMin(), rgb->gMax(), l));
+
132  rgb->b(denormalize(rgb->bMin(), rgb->bMax(), l));
+
133  return ;
+
134  }
+
135  double q = (l < 0.5 ? (l * (1 + s)) : (l + s - (l * s)));
+
136  double p = 2 * l - q;
+
137  double t_r = h + 1.0 / 3.0;
+
138  double t_g = h;
+
139  double t_b = h - 1.0 / 3.0;
+
140  if(t_r < 0) t_r = t_r + 1.0;
+
141  if(t_r > 1) t_r = t_r - 1.0;
+
142  if(t_g < 0) t_g = t_g + 1.0;
+
143  if(t_g > 1) t_g = t_g - 1.0;
+
144  if(t_b < 0) t_b = t_b + 1.0;
+
145  if(t_b > 1) t_b = t_b - 1.0;
+
146  double r, g, b;
+
147  if (t_r < 1.0 / 6.0) r = p + (q - p) * 6 * t_r;
+
148  else if(t_r < 0.5 ) r = q;
+
149  else if(t_r < 2.0 / 3.0) r = p + (q - p) * 6 * (2.0 / 3.0 - t_r);
+
150  else r = p;
+
151  if (t_g < 1.0 / 6.0) g = p + (q - p) * 6 * t_g;
+
152  else if(t_g < 0.5 ) g = q;
+
153  else if(t_g < 2.0 / 3.0) g = p + (q - p) * 6 * (2.0 / 3.0 - t_g);
+
154  else g = p;
+
155  if (t_b < 1.0 / 6.0) b = p + (q - p) * 6 * t_b;
+
156  else if(t_b < 0.5 ) b = q;
+
157  else if(t_b < 2.0 / 3.0) b = p + (q - p) * 6 * (2.0 / 3.0 - t_b);
+
158  else b = p;
+
159  rgb->r(denormalize(rgb->rMin(), rgb->rMax(), r));
+
160  rgb->g(denormalize(rgb->gMin(), rgb->gMax(), g));
+
161  rgb->b(denormalize(rgb->bMin(), rgb->bMax(), b));
+
162 }
+
163 
+
167 inline void colorTransformate(HSLf_Space const& hsl, YUVf_Space* yuv) {
+
168  RGBf_Space tmp;
+
169  colorTransformate(hsl, &tmp);
+
170  colorTransformate(tmp, yuv);
+
171 }
+
172 
+
176 inline void colorTransformate(HSLf_Space const& hsl, RGBi_Space* rgb) {
+
177  RGBf_Space tmp;
+
178  colorTransformate(hsl, &tmp);
+
179  rgb->copyFrom(tmp);
+
180 }
+
181 
+
182 
+
186 inline void colorTransformate(RGBi_Space const& rgb, HSLf_Space* hsl) {
+
187  RGBf_Space tmp;
+
188  tmp.copyFrom(rgb);
+
189  colorTransformate(rgb, hsl);
+
190 }
+
191 
+
192 } // meow
+
193 
+
194 
+
195 #endif // colors_HSL_Space_H__
HSLf_Space(Vector3D< double > const &v)
Definition: HSL_Space.h:32
T normalize(T lower, T upper, T value)
(value-lower)/(upper-lower)
Definition: utility.h:27
double const & rMin() const
Definition: RGB_Space.h:106
@@ -230,7 +234,6 @@ $(document).ready(function(){initNavTree('HSL__Space_8h_source.html','');});
double const & h() const
Definition: HSL_Space.h:50
double const & l() const
Definition: HSL_Space.h:52
HSLf_Space operator*(double const &c) const
Definition: HSL_Space.h:71
-
void colorTransformate(RGBf_Space const &rgb, HSLf_Space *hsl)
RGBf_Space to HSLf_Space
Definition: HSL_Space.h:85
double & hGet()
Definition: HSL_Space.h:58
以浮點數Red, Green, Blue 三個值所組成的色彩空間
Definition: RGB_Space.h:86
HSLf_Space(HSL_Space const &b)
Definition: HSL_Space.h:37
@@ -245,12 +248,13 @@ $(document).ready(function(){initNavTree('HSL__Space_8h_source.html','');});
double const & hslMin(size_t i) const
Definition: HSL_Space.h:41
double const & sMin() const
Definition: HSL_Space.h:43
T denormalize(T lower, T upper, T _ratio)
(lower+_ratio*(upper-lower))
Definition: utility.h:35
+
void colorTransformate(HSLf_Space const &in, HSLf_Space *out)
HSLf_Space to HSLf_Space
Definition: HSL_Space.h:85
double const & r() const
Definition: RGB_Space.h:114
doubleconst & max(size_t id) const
Return the maximum of the i -th channel.
Definition: Color3_Space.h:107
以浮點數Y(亮度), U(色度), V(濃度) 三個值所組成的色彩空間
Definition: YUV_Space.h:21
Base class of color space with 3 channels.
Definition: Color3_Space.h:18
-
3D's vector
Definition: Vectors.h:265
+
3D's vector
Definition: Vectors.h:245
double const & hMax() const
Definition: HSL_Space.h:46
double const & gMin() const
Definition: RGB_Space.h:107
HSLf_Space operator/(double const &c) const
Definition: HSL_Space.h:74
@@ -288,7 +292,7 @@ $(document).ready(function(){initNavTree('HSL__Space_8h_source.html','');});