【发布时间】:2012-07-22 09:01:45
【问题描述】:
我正在对我的图像进行标准化,并且我已经完成了图像的 RGB 值。任何人都可以帮助我对 c# 代码进行 RGB 规范化,比如一些关于如何写出规范化代码的初学者。谢谢!
private void normalization_Click(object sender, EventArgs e) { // for (int x = 0; x
// for (int y = 0; y < pictureBox1.Height; y++)
{
try
{
Bitmap img = new Bitmap(pictureBox1.Image);
Color c;
for (int i = 0; i < img.Width; i++)
{
for (int j = 0; j < img.Height; j++)
{
c = img.GetPixel(i, j);
int r = Convert.ToInt16(c.R);
int g = Convert.ToInt16(c.G);
int b = Convert.ToInt16(c.B);
d = r / (r + g + b);
h = g / (r + g + b);
f = b / (r + g + b);
img.SetPixel(i, j, Color.FromArgb(d, h, f));
Color pixelColor = img.GetPixel(i, j);
float normalizedPixel = (d + h + f);
Color normalizedPixelColor = System.Drawing.ColorConverter.(normalizedPixel);
img.SetPixel(x, y, normalizedPixelColor);
}
}
}
catch (Exception ex) { }
嗨。我已经完成了公式和所有规范化。我现在面临的问题是我无法从列表框中获取 RGB 像素的值并使用公式对其进行规范化,然后将像素放回图片框/图像中。以上是我尝试将标准化的 RGB 像素放回图片框的代码。我可以寻求一些帮助吗,因为它仍然无法正常化我的图像。谢谢。
【问题讨论】:
-
您可能会发现Normalizing Image Brightness in C# 很有用。
-
嗨。谢谢..我已经看过它并尝试弄清楚如何将其编译到我的程序中,但我无法弄清楚。你还有其他网站吗?哈哈。谢谢!
标签: c# image-processing colors normalization