private static void DemoBottomHat() { StructuringElement se = StructuringElement.CreateSquare(3); BottomHat bothat = new BottomHat(se); using (StreamReader sr = new StreamReader("img.txt")) { String line; while ((line = sr.ReadLine()) != null) { string source = string.Format("grayscale_img/{0}.jpg", line); Bitmap bmp = Bitmap.FromFile(source) as Bitmap; Matrix img_matrix = Matrix.FromBitmap(bmp); //Matrix thres_matrix = img_matrix < 100; Matrix result = bothat.Execute(img_matrix); string dest = string.Format("bottomhat/{0}.txt", line); using (StreamWriter sw = new StreamWriter(dest, false)) { sw.Write(result.ToString()); } result.ToBitmap().Save(string.Format("bottomhat/{0}.png", line)); } } }
private void reapplyToolStripMenuItem3_Click(object sender, EventArgs e) { BottomHat filter = new BottomHat(); // apply the filter pictureBox2.Image = filter.Apply((Bitmap)pictureBox1.Image); }
public mErosionHatBottom() { BitmapType = BitmapTypes.Rgb24bpp; Effect = new BottomHat(); filter = Effect; }