private Mat Fill(Mat input, int maxWidth, int maxHeight) { Stopwatch w = new Stopwatch(); w.Start(); Bitmap bm = input.Bitmap; Image <Gray, byte> im = new Image <Gray, byte>(bm); FillHoles fh = new FillHoles(); im = im.Dilate(1); fh.MaxHoleWidth = maxWidth; fh.MaxHoleHeight = maxHeight; try { bm = fh.Apply(im.Bitmap); } catch (Exception e) { MessageBox.Show("" + e.ToString(), "System Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } im = new Image <Gray, byte>(bm); im = im.Erode(1); w.Stop(); input = im.Mat; return(input); }
private void fillHoles() { Closing close = new Closing(); imageGot = close.Apply(imageGot); imageGot = close.Apply(imageGot); Opening opening = new Opening(); imageGot = opening.Apply(imageGot); FillHoles fillHoles = new FillHoles(); fillHoles.MaxHoleHeight = 20; fillHoles.MaxHoleWidth = 20; fillHoles.CoupledSizeFiltering = false; imageGot = fillHoles.Apply(imageGot); pictureBox1.Image = imageGot; }