我对抖动感兴趣,命令抖动更精确。我花了很多时间在研究和实验上。并希望经过所有努力,我的代码能够正常工作。
我将提供执行抖动的代码和一些示例。
我的问题
这是这篇维基百科文章中抖动算法的伪代码,我的代码基于该文章。
以下是变量解释:
M(i, j)是第i行第j列c上的阈值图?是变换后的颜色,r是颜色空间中的扩散量。假设一个 RGB 调色板具有N³均匀选择的颜色,其中每个颜色坐标由一个八位字节表示,通常会选择:
现在,这是我的实现(伪代码):
ditherMatrix = 4x4; // By 4x4 I mean the normal 4x4 dither matrix from the wikipedia article
ditherMatrixSize = 4;
offset = (ditherMatrixSize * (ditherMatrixSize / 2) - 0.5);
/* In the wiki article it uses 0.5 as an offset,
but I have to do this instead.
Is this correct? …
Run Code Online (Sandbox Code Playgroud)