3 ms·
directly when reading this code I cannot help myself but to get into review-mode. It is an awesome example, which i will probably use myself one day. However..
by dosshell 4y ago
directly when reading this code I cannot help myself but to get into review-mode. It is an awesome example, which i will probably use myself one day.
However...
inc.cpp:27
Gray is not the average of RGB, it is usally approximated with `Y = 0.299 R + 0.587 G + 0.114 B`.
- Datagenerator 4y agoMarvelous example of the bikeshed effect
- jhgb 4y agoThat doesn't seem applicable unless there are bigger problems to solve that are being ignored.
- syrusakbary 4y agoFor future readers, this is the code that is being referred: https://github.com/ern0/howto-wasm-minimal/blob/master/inc.cpp#L31-L35 https://github.com/ern0/howto-wasm-minimal/blob/master/inc.c... It should be: uint32_t gray = 0.299 * ptr[i] + 0.587 * ptr[i+1] + 0.114 * ptr[i+2]; ptr[i] = gray; ptr[i+1] = gray; ptr[i+2] = gray;
- ern0 4y agoI know it (see: https://github.com/ern0/kolorwheel.js https://github.com/ern0/kolorwheel.js ), but I did not wanted use floats.
- Asooka 4y agoAlso, you must work in linear colour space. In OP's case you would have to apply the inverse sRGB transform, do the calculation, then apply the forward sRGB transform. Best if you just work with linear colour end to end, if you have the memory to spare.
- astrange 4y agoWell, it's certainly traditional to get that wrong. Technically nothing's wrong in graphics as long as you get some kind of image out of it, it's just different :)