0

我对我的图像进行了标准化,并且我已经完成了图像的 RGB 值。任何人都可以帮助我对 c# 代码进行 RGB 规范化,比如一些关于如何写出规范化代码的初学者。谢谢!


private void normalization_Click(object sender, EventArgs e) { // for (int x = 0; x < pictureBox1.Width; 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 像素放回图片框的代码。我可以寻求一些帮助吗,因为它仍然没有使我的图像正常化。谢谢。

4

1 回答 1

-1

如果您不介意在您的项目中有依赖项,请查看AForge.NET 。作为奖励,您将拥有许多其他可用的算法,而无需重新发明 for 循环......

于 2012-07-24T05:00:43.480 回答