For future readers, this is the code that is being referred:
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;