【发布时间】:2016-07-05 08:45:02
【问题描述】:
我正在尝试实现拜耳有序抖动矩阵算法以将 24 位彩色图像转换为 3 位图像。我已经阅读了维基百科页面,以及有关该主题的几个教科书部分,并且有点困惑。这是我目前所拥有的:
for (int y = 0; x < image.Height; y++)
{
for (int x = 0; x < image.Width; x++)
{
Color color = image.GetPixel(x,y);
color.R = color.R + bayer4x4[x % 4, y % 4];
color.G = color.G + bayer4x4[x % 4, y % 4];
color.B = color.B + bayer4x4[x % 4, y % 4];
image[x][y] = SetPixel(x, y, GetClosestColor(color, bitdepth);
}
}
但是,我没有办法实现 GetClosestColor... 我该怎么做?
另外,我没有定义 bayer4x4 矩阵,我相信它应该如下所示:
1, 9, 3, 11
13, 5, 15, 7
4, 12, 2, 10
16, 8, 14, 6
【问题讨论】:
-
GetClosestColor会查看目标托盘,那么您有什么托盘? -
另外,当您从 256 色缩放到 8 色时,您需要不同的阈值图
-
@Lashane 是的,但他们说源是 24 位的,所以我认为他们至少需要 8x8 矩阵,因此大小匹配 256:1 的缩小率,但如果这是灰度,我不知道是否有不同的数学适用。
-
这确实是灰度。我希望有 1 位红色、1 位绿色和 1 位蓝色。因此,有 16+1 种不同的灰度等级。
-
1 bit red, 1 bit green, and 1 bit blue.是 8 个级别
标签: c# image algorithm image-processing dithering