6. 影像處理之邊緣偵測實作
這題真的蠻有趣的,卷積邊緣偵測操作
# 按像素操作圖片要用 BitMap (該class繼承 Image)
BitMap (該class繼承 Image)灰階轉換
private void button3_Click(object sender, EventArgs e)
{
var img = (Bitmap)pictureBox1.Image;
Bitmap map = new Bitmap(img.Width, img.Height);
for (int x = 0; x < img.Width; x++)
{
for (int y = 0; y < img.Height; y++)
{
var color = img.GetPixel(x, y);
int gay = (int)(color.R * 0.3 + color.G * 0.59 + color.B * 0.11);
map.SetPixel(x, y, Color.FromArgb(gay, gay, gay));
}
}
pictureBox2.Image = map;
}邊緣偵測
Last updated