问题
I am attempting to implement a Bayer ordered dithering matrix algorithm to convert a 24bit color image to a 3bit image. I have read the Wikipedia page, and several textbook sections on the topic and am a bit confused. This is what I have so far:
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);
}
}
However, I do not have a way of implementing GetClosestColor... how can I do this?
Also, I do not have the bayer4x4 matrix defined, I believe it should look like the following:
1, 9, 3, 11
13, 5, 15, 7
4, 12, 2, 10
16, 8, 14, 6
来源:https://stackoverflow.com/questions/36087038/how-to-implement-24bit-to-3bit-ordered-dither-algorithm