计算点网格上的抗锯齿

时间:2017-01-04 13:15:35

标签: javascript image algorithm html5-canvas

我通过表示图像中每个像素强度的整数列表来表示图像。每个点都是0或1.根据这些数据,我如何计算抗锯齿值,以便最终结果是平滑的?

示例数据:

// What I have
const aliased = [
   0, 0, 0, 0, 0,
   0, 1, 1, 1, 0,
   0, 0, 0, 1, 0,
   0, 0, 1, 0, 0,
   0, 0, 0, 1, 0,
   0, 1, 0, 1, 0,
   0, 0, 1, 0, 0,
   0, 0, 0, 0, 0,
];

// What I want to calculate
const smoothed = [
   0, 0, 0, 0, 0,
   0, 1, 1, 1, 0,
   0, 0, 0, 1, 0,
   0, 0, 1, 0, 0.5, // <- point with intensity of 50%
   0, 0, 0, 1, 0,
   0, 1, 0, 1, 0,
   0, 0, 1, 0, 0,
   0, 0, 0, 0, 0,
];

当前输入

enter image description here

所需的输出

enter image description here

0 个答案:

没有答案