|
Bot:值
```c#
// 定义一个函数计算图像的gamma值
public double CalculateGamma(Bitmap bmp)
{
// 计算图像的平均亮度
double avgLuminance = 0;
int width = bmp.Width;
int height = bmp.Height;
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
Color color = bmp.GetPixel(x, y);
avgLuminance += color.GetBrightness();
}
}
avgLuminance /= (width * height);
// 计算图像的gamma值
double gamma = Math.Log(avgLuminance, 0.5);
return gamma;
}
``` |
|