我在Dimage.SetPixel使用了以下代码对接错误。“Dimage接受两个参数,但是给它一个”它的图像的扩张代码。
private void button6_Click(object sender, EventArgs e)
{
if (path == null)
{
MessageBox.Show("Please load an image");
return;
}
System.Drawing.Bitmap imageX = new Bitmap(pb1.Image);
System.Drawing.Bitmap image = AForge.Imaging.Image.Clone
(imageX, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
ConservativeSmoothing filterX = new ConservativeSmoothing();
filterX.ApplyInPlace(image);
Grayscale filter = new Grayscale(0.2125, 0.7154, 0.0721);
Bitmap grayImage = filter.Apply(image);
int temp;
var imW = image.Width;
var imH = image.Height;
Bitmap Dimage = grayImage;
for (int i = 1; i <= imW; i++)
{
for (int j = 2; j <= imH-1; j++)
{
temp = Math.Max(Convert.ToInt32(grayImage.GetPixel(i, j - 1)), Convert.ToInt32(grayImage.GetPixel(i, j)));
Dimage.SetPixel(i,j) = Math.Max(temp, Convert.ToInt32(grayImage.GetPixel(i, j + 1)));
}
}
答案 0 :(得分:1)
SetPixel需要3个参数:x,y,color。您只给它两个参数,然后以不寻常的方式使用第三个参数。抱歉,您应该将Max结果插入SetPixel的括号中。