Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何实现24位到3位的有序抖动算法?_C#_Image_Algorithm_Image Processing_Dithering - Fatal编程技术网

C# 如何实现24位到3位的有序抖动算法?

C# 如何实现24位到3位的有序抖动算法?,c#,image,algorithm,image-processing,dithering,C#,Image,Algorithm,Image Processing,Dithering,我正在尝试实现拜耳有序抖动矩阵算法,将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.

我正在尝试实现拜耳有序抖动矩阵算法,将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
将查看目标托盘,那么您有什么托盘?另外,当您从256色缩放到256色时,您需要不同的阈值贴图8@Lashane是的,但他们说源是24位的,所以我认为他们至少需要8x8矩阵,以便大小匹配256:1的缩减比,但如果这是灰度,我不知道不同的数学是否适用。这确实是灰度。我希望有1位红色,1位绿色和1位蓝色。因此,有16+1个不同级别的灰度。
1位红色、1位绿色和1位蓝色。
是8个级别
GetClosestColor
将查看目标托盘,那么您有什么托盘?另外,当您从256色缩放到256色时,您需要不同的阈值贴图8@Lashane是的,但他们说源是24位的,所以我认为他们至少需要8x8矩阵,这样大小匹配256:1的缩小比,但如果这是灰度,我不知道是否适用不同的数学。这确实是灰度。我希望有1位红色,1位绿色和1位蓝色。因此,有16+1个不同级别的灰度。
1位红色、1位绿色和1位蓝色。
是8个级别
1,  9,  3, 11
13, 5, 15, 7
4, 12,  2, 10
16, 8, 14, 6