]> git.seodisparate.com - EN605.617.81.FA21_StephenSeo_DitheringProject/commitdiff
Fix Image::ColorToGray()
authorStephen Seo <seo.disparate@gmail.com>
Sat, 4 Dec 2021 02:40:07 +0000 (11:40 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Sat, 4 Dec 2021 02:40:24 +0000 (11:40 +0900)
Previous implementation had images brighter than usual. The algorithm
used was probably not necessary as it was for converting from
linear-space to a different one.

src/image.cc

index ca9b2dcf2c9c504cc504d26f6ed79487a6911bd1..840ff245e11f0680141d2a4591e580c01b679362 100644 (file)
@@ -355,11 +355,7 @@ uint8_t Image::ColorToGray(uint8_t red, uint8_t green, uint8_t blue) {
   double y_linear = 0.2126 * (red / 255.0) + 0.7152 * (green / 255.0) +
                     0.0722 * (blue / 255.0);
 
-  if (y_linear <= 0.0031308) {
-    return std::round((12.92 * y_linear) * 255.0);
-  } else {
-    return std::round((1.055 * std::pow(y_linear, 1 / 2.4) - 0.055) * 255.0);
-  }
+  return std::round(y_linear * 255.0);
 }
 
 std::unique_ptr<Image> Image::ToGrayscale() const {