private void button1_Click(object sender, EventArgs e) { Digit d = generateDigit(); BinImage bi = new BinImage((byte[,])d.matr.Clone(), MATRIX_SIZE, MATRIX_SIZE); byte[,] copy = (byte[,])bi.matr.Clone(); int maskSize = 0; DrawMatrix(bi, pictureBox1); int fullpoints = goodPointsCount(bi.matr); while (checkImage(bi.matr,fullpoints)) { maskSize += 1; bi.matr = (byte[,])copy.Clone(); byte[,] ball = createCircleMatr(maskSize); bi.LoadMask(ball); bi.Dilation(); DrawMatrix(bi, pictureBox2); } maskSize += 1; bi.MaskSize--; bi.matr = (byte[,])copy.Clone(); byte[,] ball1 = createCircleMatr(maskSize); bi.LoadMask(ball1); ; bi.Dilation(); DrawMatrix(bi, pictureBox2); }
private void DrawMatrix(BinImage bi, PictureBox p) { // pictureBox1.Dispose(); btp = new Bitmap(bi.Width, bi.Height); for (int i = 0; i < bi.Width; ++i) for (int j = 0; j < bi.Height; ++j) if (bi.matr[i, j] == 1) btp.SetPixel(i, j, Color.White); else btp.SetPixel(i, j, Color.Black); p.Image = btp; p.Invalidate(); p.Update(); }