using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace derivative { public partial class Form1 : Form { public Form1() { InitializeComponent(); } Bitmap newbitmap; private void button1_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp"; if (open.ShowDialog() == DialogResult.OK) { pictureBox1.ImageLocation = open.FileName; newbitmap = new Bitmap(open.FileName); //opened = true; /* System.Drawing.Image img = System.Drawing.Image.FromFile( open.FileName ); MessageBox.Show("Width: " + img.Width + ", Height: " + img.Height);*/ } } private void button2_Click(object sender, EventArgs e) { Color n = new Color(); int x; int y; int []s; s = new int[1000]; int a; for (a = 0; a < s.Length;a++) { for (x = 1; x <= newbitmap.Width - 1; x++) { for (y = 1; y <= newbitmap.Height - 1; y++) { //derivative of each pixel s[a] = (int)((newbitmap.GetPixel(x + 1, y).R) + (newbitmap.GetPixel(x - 1, y).R) + (newbitmap.GetPixel(x, y + 1).R) + (newbitmap.GetPixel(x, y - 1).R) - (newbitmap.GetPixel(x, y).R * 4)); } } } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)