//-------------------------------------------------------------------------------------- private void PrepareLookSeparatePartForPicture(Bitmap pPictureForLook) { try { CImageSplitter lImageSplitter = new CImageSplitter(); FLookSeparatePart form = new FLookSeparatePart(); Dictionary <Color, Bitmap> lDictPicture = lImageSplitter.SplitImageByColor(pPictureForLook); List <Bitmap> lImages = new List <Bitmap>(); List <Color> lColors = new List <Color>(); form.PictureList = lImages; form.ColorList = lColors; form.PictureForLook = pPictureForLook; int lNumber = 0; foreach (Color lWhat in lDictPicture.Keys) { Bitmap lBitmap = lDictPicture[lWhat]; lImages.Add(lBitmap); lColors.Add(lWhat); int lQuantity = 0; int lQuantityAll = 0; int lCentreX = 0; int lCentreY = 0; for (int n = 0; n < lBitmap.Width; n++) { lQuantityAll += lBitmap.Height; for (int m = 0; m < lBitmap.Height; m++) { if (lBitmap.GetPixel(n, m) == lWhat) { lQuantity++; lCentreX += n; lCentreY += m; } } } lCentreX /= lQuantity; lCentreY /= lQuantity; form.imageListDataSet1.Images.AddImagesRow(lNumber++, lQuantity, lCentreX, lCentreY, "R:" + lWhat.R.ToString("G") + "G:" + lWhat.G.ToString("G") + "B:" + lWhat.B.ToString("G"), lWhat.R + lWhat.G + lWhat.B); } form.Show(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
//-------------------------------------------------------------------------------------- private Bitmap CommonSplit(Bitmap pInBitmap) { byte lWhat = (byte)cbClearColor.SelectedIndex; CImageSplitter lImageSplitter = new CImageSplitter(); FLookSeparatePart form = new FLookSeparatePart(); List <byte[][]> lMatrixList = lImageSplitter.SplitByMatrix(pInBitmap, lWhat); List <Bitmap> lImages = CBlackWhiteExplorer.BinaryMatrixListToBitmapList(lMatrixList); form.PictureList = lImages; for (int i = 0; i < lMatrixList.Count; i++) { int lNumber = i; int lQuantity = 0; int lQuantityAll = 0; int lCentreX = 0; int lCentreY = 0; byte[][] lMatrix = lMatrixList[i]; for (int n = 0; n < lMatrix.Length; n++) { lQuantityAll += lMatrix[n].Length; for (int m = 0; m < lMatrix[n].Length; m++) { if (lMatrix[n][m] == lWhat) { lQuantity++; lCentreX += n; lCentreY += m; } } } lCentreX /= lQuantityAll; lCentreY /= lQuantityAll; form.imageListDataSet1.Images.AddImagesRow(lNumber, lQuantity, lCentreX, lCentreY, "", 0); } form.Show(); int[][] lColorMatrix = CBlackWhiteExplorer.BinaryMatrixListToColorMatrix(lMatrixList, lWhat); Bitmap lColorImage = CBlackWhiteExplorer.ColorMatrixToColorBitmap(lColorMatrix, lMatrixList.Count); // pbAfterCleanColor.Image = lColorImage; return(lColorImage); }