From a4d7156e10052ee1d60ca2922328fbee85efc92d Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Sat, 4 Dec 2021 11:40:07 +0900 Subject: [PATCH] Fix Image::ColorToGray() 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 | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/image.cc b/src/image.cc index ca9b2dc..840ff24 100644 --- a/src/image.cc +++ b/src/image.cc @@ -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::ToGrayscale() const {