如何使用嘉洛斯在.NET来改变亮度,色彩,饱和度,色调饱和度、如何使用、亮度、色调

2023-09-03 05:48:08 作者:难免失落

我有一个包含一些随机的位图数据的位图类型。我已经写了我自己调整亮度,色彩,饱和度和色调上的每一位的个别行为,并勿庸置疑,这太可怕了缓慢的。

I have a 'Bitmap' type containing some random bitmap data. I've written my own adjustments for Brightness, Color, Saturation, and Hue that act on each bit individually and, unsurprisingly, it's awful slow.

在我的研究,我发现,使用矩阵可以非常快的调整这些。此外,.NET拥有嘉洛斯在那里你可以申请的基体效应,当你的DrawImage()。

In my research I've noticed that using matrices can be very fast in adjusting these. In addition, .NET has a ColorMatrix where you can apply the matrix effects when you DrawImage().

我们建立如下所示(从MSDN网站)矩阵:

The matrix we set up looks like the following (from MSDN website):

float[][] colorMatrixElements = { 
new float[] {2,  0,  0,  0, 0},        // red scaling factor of 2
new float[] {0,  1,  0,  0, 0},        // green scaling factor of 1
new float[] {0,  0,  1,  0, 0},        // blue scaling factor of 1
new float[] {0,  0,  0,  1, 0},        // alpha scaling factor of 1
new float[] {.2f, .2f, .2f, 0, 1}};    // three translations of 0.2

但我一直没能找到合适的范围或究竟这些数字中的任何实际执行。我不知道如何来调整亮度,色彩,饱和度和色调。

But I haven't been able to find proper ranges or what exactly any of these numbers actually do. I have no idea how to adjust for Brightness, Color, Saturation, and Hue.

任何帮助?我失去了一些好的文档的地方?

Any help?? Am I missing some good documentation somewhere?

谢谢!

推荐答案

有一些细节在 HTTP ://www.graficaobscura.com/matrix/index.html ,但你可能想发表您的另一code。每个像素做的操作是非常常见的,你通常不会遇到性能问题进行这种操作。 .NET的Bitmap.SetPixel是出了名的慢。这是一个很好的 C#图像处理系列在$ C $的CProject呈现出更快的方法。我没有与C ++的经验 - CLI但我会看看

There are some details at http://www.graficaobscura.com/matrix/index.html but you may want to post your other code. Doing operations per-pixel is very common and you wouldn't usually encounter performance issues for this kind of operation. .NET's Bitmap.SetPixel is notoriously slow. There is a good C# image processing series at codeproject showing a faster method. I don't have experience with c++-cli but I'll take a look.