我正在对我的图像进行规范化,我已经完成了图像的RGB值。有谁能帮我完成c#代码的RGB规范化,比如如何编写标准化代码的一些初学者。谢谢!
私有空normalization_Click(对象发送方,EventArgs e) { // for (int = 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像素的值,并使用公式将其规范化,然后将像素放回picturebox/image中。上面是我尝试将标准化的RGB像素放回picturebox的代码。我能在这方面寻求一些帮助吗,因为它仍然没有使我的形象正常化。谢谢。
发布于 2012-07-24 05:00:43
如果您不介意在项目中有依赖项,请查看AForge.NET。作为一个奖励,您将有许多其他算法在您的可用性,而不需要您重新发明for循环.
https://stackoverflow.com/questions/11624176
复制相似问题