Mercurial > hg > orthanc
comparison Core/Images/ImageProcessing.cpp @ 2491:a9459c7d4bc2
fix color-to-grayscale conversion
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 14 Mar 2018 16:50:31 +0100 |
parents | 0cacb38297a9 |
children | cd7b854dbc05 |
comparison
equal
deleted
inserted
replaced
2490:0cacb38297a9 | 2491:a9459c7d4bc2 |
---|---|
112 for (unsigned int x = 0; x < source.GetWidth(); x++, t++, s += 3) | 112 for (unsigned int x = 0; x < source.GetWidth(); x++, t++, s += 3) |
113 { | 113 { |
114 // Y = 0.2126 R + 0.7152 G + 0.0722 B | 114 // Y = 0.2126 R + 0.7152 G + 0.0722 B |
115 int32_t v = (2126 * static_cast<int32_t>(s[0]) + | 115 int32_t v = (2126 * static_cast<int32_t>(s[0]) + |
116 7152 * static_cast<int32_t>(s[1]) + | 116 7152 * static_cast<int32_t>(s[1]) + |
117 0722 * static_cast<int32_t>(s[2])) / 1000; | 117 0722 * static_cast<int32_t>(s[2])) / 10000; |
118 | 118 |
119 if (static_cast<int32_t>(v) < static_cast<int32_t>(minValue)) | 119 if (static_cast<int32_t>(v) < static_cast<int32_t>(minValue)) |
120 { | 120 { |
121 *t = minValue; | 121 *t = minValue; |
122 } | 122 } |