用C#写图像的椒盐噪声、高斯噪声、中值滤波、高斯低通、高通程序

我现在要用C#写图像的椒盐噪声、高斯噪声、中值滤波和高斯低通、高通变换,可是我没有学过C#,而且对图像处理也不是很懂,各位大侠帮帮忙,帮我把这四个功能函数写一下。非常感谢!很急用!!
namespace image
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e) //打开待处理图片
{
OpenFileDialog open = new OpenFileDialog();
if (open.ShowDialog() == DialogResult.OK)
{
string path = open.FileName;
pictureBox1.Image = new Bitmap(path);
}
}

private void button2_Click(object sender, EventArgs e)
{
Bitmap result = abc((Bitmap)pictureBox1.Image); //调用功能函数处理图片
pictureBox1.Image = result; //显示处理后的图片
}

//功能函数 我要的就是这块
private Bitmap abc(Bitmap a)
{return a;
}
}
}

第1个回答  推荐于2016-10-30
Bitmap image = new Bitmap(50,22);
Graphics g = Graphics.FromImage(image);

try
{
//生成随机生成器
Random random = new Random();

//清空图片背景色
g.Clear(Color.White);

//画图片的背景噪音线
for (int i = 0; i < 25; i++)
{
int x1 = random.Next(image.Width);
int x2 = random.Next(image.Width);
int y1 = random.Next(image.Height);
int y2 = random.Next(image.Height);

g.DrawLine(new Pen(Color.Silver), x1, y1, x2, y2);
}

Font font = new Font("Arial", 12, (FontStyle.Bold | FontStyle.Italic));
LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Red, Color.Crimson, 1.2f, true);
g.DrawString(checkCode, font, brush, 0, 0);

//画图片的前景噪音点
for (int i = 0; i < 100; i++)
{
int x = random.Next(image.Width);
int y = random.Next(image.Height);

image.SetPixel(x, y, Color.FromArgb(random.Next()));
}

//画图片的边框线
g.DrawRectangle(new Pen(Color.Silver), 0, 0, image.Width - 1, image.Height - 1);

System.IO.MemoryStream ms = new System.IO.MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
Response.ClearContent();
Response.ContentType = "image/Gif";
Response.BinaryWrite(ms.ToArray());
}
finally
{
g.Dispose();
image.Dispose();
}
希望对你有帮助本回答被提问者采纳
第2个回答  2016-05-14
啥意思呢 木有明白 是降噪音 么
相似回答