//-------------------------------------------------------------------------------------- private void tsbRemoveSmall_Click(object sender, EventArgs e) { try { CImageSplitter lImageSplitter = new CImageSplitter(); if (pbAfterClean.Image != null) { fMatrixAfterClean = lImageSplitter.RemoveSmallRegion(pbAfterClean.Image as Bitmap, (byte)cbClearColor.SelectedIndex, int.Parse(txtThreshold.Text)); Bitmap lNewBmp = CBlackWhiteExplorer.BinaryMatrixToBitmap(fMatrixAfterClean); pbAfterClean_RL.Image = lNewBmp; } if (pbAfterCleanExact.Image != null) { fMatrixAfterClean = lImageSplitter.RemoveSmallRegion(pbAfterCleanExact.Image as Bitmap, (byte)cbClearColor.SelectedIndex, int.Parse(txtThreshold.Text)); Bitmap lNewBmp = CBlackWhiteExplorer.BinaryMatrixToBitmap(fMatrixAfterClean); pbAfterCleanExact_RL.Image = lNewBmp; } if (pbAfterCleanExactDefault.Image != null) { fMatrixAfterClean = lImageSplitter.RemoveSmallRegion(pbAfterCleanExactDefault.Image as Bitmap, (byte)cbClearColor.SelectedIndex, int.Parse(txtThreshold.Text)); Bitmap lNewBmp = CBlackWhiteExplorer.BinaryMatrixToBitmap(fMatrixAfterClean); pbAfterCleanExactDefault_RL.Image = lNewBmp; } } catch (Exception ee) { MessageBox.Show(ee.ToString()); } }
//-------------------------------------------------------------------------------------- private void tsbCleanAccurateDefault_Click(object sender, EventArgs e) { try { Bitmap lInBmp = pbBlackWhite.Image as Bitmap; if (lInBmp == null) { MessageBox.Show("Нет картинки"); return; } byte[][] lMatrix = CBlackWhiteExplorer.BitmapToBinaryMatrix(lInBmp); if (cbClearColor.SelectedIndex < 3) { CBlackWhiteExplorer.RemoveIsolatePointAccurate(lMatrix, (byte)cbClearColor.SelectedIndex); } else if (cbClearColor.SelectedIndex == 3) { CBlackWhiteExplorer.RemoveIsolatePointAccurate(lMatrix, 0); CBlackWhiteExplorer.RemoveIsolatePointAccurate(lMatrix, 1); } else { CBlackWhiteExplorer.RemoveIsolatePointAccurate(lMatrix, 1); CBlackWhiteExplorer.RemoveIsolatePointAccurate(lMatrix, 0); } Bitmap lNewBmp = CBlackWhiteExplorer.BinaryMatrixToBitmap(lMatrix); pbAfterCleanExactDefault.Image = lNewBmp; } catch (Exception ee) { MessageBox.Show(ee.ToString()); } }
//-------------------------------------------------------------------------------------- private void toolStripButton1_Click(object sender, EventArgs e) { if (pbPicture1.Image == null || pbPicture2.Image == null || pbPicture3.Image == null) { return; } CBlackWhiteExplorer lBlackWhiteExplorer = new CBlackWhiteExplorer(); byte[][] lMatrix1 = CBlackWhiteExplorer.BitmapToBinaryMatrix(pbPicture1.Image as Bitmap); byte[][] lMatrix2 = CBlackWhiteExplorer.BitmapToBinaryMatrix(pbPicture2.Image as Bitmap); byte[][] lMatrix3 = CBlackWhiteExplorer.BitmapToBinaryMatrix(pbPicture3.Image as Bitmap); byte[][][] lMatrixs = lBlackWhiteExplorer.Compare3BWMatrix(lMatrix1, lMatrix2, lMatrix3, byte.Parse(tcbValColor.SelectedItem.ToString())); Bitmap lPictureIntersection = CBlackWhiteExplorer.BinaryMatrixToBitmap(lMatrixs[0]); Bitmap lPictureUnion = CBlackWhiteExplorer.BinaryMatrixToBitmap(lMatrixs[1]); Bitmap lPictureUnionDiffer = CBlackWhiteExplorer.BinaryMatrixToBitmap(lMatrixs[2]); Bitmap lPicture001 = CBlackWhiteExplorer.BinaryMatrixToBitmap(lMatrixs[3]); Bitmap lPicture010 = CBlackWhiteExplorer.BinaryMatrixToBitmap(lMatrixs[4]); Bitmap lPicture100 = CBlackWhiteExplorer.BinaryMatrixToBitmap(lMatrixs[5]); Bitmap lPicture011 = CBlackWhiteExplorer.BinaryMatrixToBitmap(lMatrixs[6]); Bitmap lPicture101 = CBlackWhiteExplorer.BinaryMatrixToBitmap(lMatrixs[7]); Bitmap lPicture110 = CBlackWhiteExplorer.BinaryMatrixToBitmap(lMatrixs[8]); pbIntersection.Image = lPictureIntersection; pbUnion.Image = lPictureUnion; pbUnionDiffer.Image = lPictureUnionDiffer; pb001.Image = lPicture001; pb010.Image = lPicture010; pb100.Image = lPicture100; pb011.Image = lPicture011; pb101.Image = lPicture101; pb110.Image = lPicture110; }
//-------------------------------------------------------------------------------------- private void tsbExec_Click(object sender, EventArgs e) { CreateBlackWhiteForRed(); CreateBlackWhiteForGreen(); CreateBlackWhiteForBlue(); CompareColorBorderInImage lComparerColor = new CompareColorBorderInImage(fSourceBitmap); lComparerColor.ComputePicture(tbRed.Value, tbGreen.Value, tbBlue.Value, fColorsOfVariant); pb000.Image = CBlackWhiteExplorer.BinaryMatrixToBitmap(lComparerColor.Matrix000); pb001.Image = CBlackWhiteExplorer.BinaryMatrixToBitmap(lComparerColor.Matrix001); pb010.Image = CBlackWhiteExplorer.BinaryMatrixToBitmap(lComparerColor.Matrix010); pb011.Image = CBlackWhiteExplorer.BinaryMatrixToBitmap(lComparerColor.Matrix011); pb100.Image = CBlackWhiteExplorer.BinaryMatrixToBitmap(lComparerColor.Matrix100); pb101.Image = CBlackWhiteExplorer.BinaryMatrixToBitmap(lComparerColor.Matrix101); pb110.Image = CBlackWhiteExplorer.BinaryMatrixToBitmap(lComparerColor.Matrix110); pb111.Image = CBlackWhiteExplorer.BinaryMatrixToBitmap(lComparerColor.Matrix111); pbColor.Image = lComparerColor.ColorPicture; DefineColorPartion(); }
//-------------------------------------------------------------------------------------- private void tsbExec_Click(object sender, EventArgs e) { if (pbPicture1.Image == null || pbPicture2.Image == null) { return; } CBlackWhiteExplorer lBlackWhiteExplorer = new CBlackWhiteExplorer(); byte[][] lMatrix1 = CBlackWhiteExplorer.BitmapToBinaryMatrix(pbPicture1.Image as Bitmap); byte[][] lMatrix2 = CBlackWhiteExplorer.BitmapToBinaryMatrix(pbPicture2.Image as Bitmap); byte[][][] lMatrixs = lBlackWhiteExplorer.Compare2BWMatrix(lMatrix1, lMatrix2, byte.Parse(tcbValColor.SelectedItem.ToString())); Bitmap lPictureIntersection = CBlackWhiteExplorer.BinaryMatrixToBitmap(lMatrixs[1]); Bitmap lPictureUnion = CBlackWhiteExplorer.BinaryMatrixToBitmap(lMatrixs[0]); Bitmap lPicture1_2 = CBlackWhiteExplorer.BinaryMatrixToBitmap(lMatrixs[2]); Bitmap lPicture2_1 = CBlackWhiteExplorer.BinaryMatrixToBitmap(lMatrixs[3]); Bitmap lPictureUnionDiffer = CBlackWhiteExplorer.BinaryMatrixToBitmap(lMatrixs[4]); pbIntersection.Image = lPictureIntersection; pbUnion.Image = lPictureUnion; pbUnionDiffer.Image = lPictureUnionDiffer; pb1_2.Image = lPicture1_2; pb2_1.Image = lPicture2_1; }