示例#1
0
        //--------------------------------------------------------------------------------------
        /// <summary>
        /// разбить рисунок на отдельные куски
        /// в виде списка рисунков по методу множеств
        /// </summary>
        /// <param name="pImage"></param>
        /// <returns></returns>
        public List <Bitmap> SplitBySetToImages(Bitmap pImage)
        {
            List <byte[][]> lMatrixList = SplitBySet(pImage);
            List <Bitmap>   lImages     = CBlackWhiteExplorer.BinaryMatrixListToBitmapList(lMatrixList);

            return(lImages);
        }
示例#2
0
        //--------------------------------------------------------------------------------------
        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;
        }
示例#3
0
 //--------------------------------------------------------------------------------------
 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());
     }
 }
示例#4
0
        //--------------------------------------------------------------------------------------
        /// <summary>
        /// разбить рисунок(представленный как матрица) на отдельные куски
        /// в виде списка рисунков по методу матриц
        /// </summary>
        /// <param name="pMatrix"></param>
        /// <param name="pWhat"></param>
        /// <returns></returns>
        public List <Bitmap> SplitByMatrixToImages(byte[][] pMatrix, byte pWhat)
        {
            List <byte[][]> lMatrixList = SplitByMatrix(pMatrix, pWhat);
            List <Bitmap>   lImages     = CBlackWhiteExplorer.BinaryMatrixListToBitmapList(lMatrixList);

            return(lImages);
        }
示例#5
0
 //--------------------------------------------------------------------------------------
 private void tsbColorSplit_Click(object sender, EventArgs e)
 {
     try
     {
         byte           lWhat          = (byte)cbClearColor.SelectedIndex;
         CImageSplitter lImageSplitter = new CImageSplitter();
         if (pbAfterClean_RL.Image != null)
         {
             Bitmap lNewBmp = CBlackWhiteExplorer.BWImageToColorImage(pbAfterClean_RL.Image as Bitmap, lWhat);
             pbAfterCleanColor.Image = lNewBmp;
         }
         if (pbAfterCleanExact_RL.Image != null)
         {
             Bitmap lNewBmp = CBlackWhiteExplorer.BWImageToColorImage(pbAfterCleanExact_RL.Image as Bitmap, lWhat);
             pbAfterCleanExactColor.Image = lNewBmp;
         }
         if (pbAfterCleanExactDefault_RL.Image != null)
         {
             Bitmap lNewBmp = CBlackWhiteExplorer.BWImageToColorImage(pbAfterCleanExactDefault_RL.Image as Bitmap, lWhat);
             pbAfterCleanExactDefaultColor.Image = lNewBmp;
         }
     }
     catch (Exception ee)
     {
         MessageBox.Show(ee.ToString());
     }
 }
示例#6
0
 //--------------------------------------------------------------------------------------
 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());
     }
 }
示例#7
0
 //--------------------------------------------------------------------------------------
 public FColorBorderExplorer(Image pImage)
 {
     InitializeComponent();
     tsbRun.Image          = ilCom.Images[0];
     cbColor.SelectedIndex = 0;
     fImage = pImage as Bitmap;
     if (fImage != null)
     {
         pbSourve.Image = fImage;
     }
     fBlackWhiteExplorer = new CBlackWhiteExplorer();
 }
示例#8
0
        //--------------------------------------------------------------------------------------
        public FBordersByColorForImage(Image pImage)
        {
            InitializeComponent();

            fSourceBitmap = pImage as Bitmap;
            if (fSourceBitmap != null)
            {
                pbSourceImage.Image = fSourceBitmap;
            }

            fBlackWhiteExplorer = new CBlackWhiteExplorer();

            Color[] lFinalColors = CBlackWhiteExplorer.DefineExactNeedColor(8);
            fColorsOfVariant = new Color[8];
            fTextOfColors    = new string[8];
            for (int i = 0; i < 6; i++)
            {
                fColorsOfVariant[i + 1] = lFinalColors[i];
            }
            fColorsOfVariant[0] = Color.FromArgb(255, 0, 0, 0);
            fColorsOfVariant[7] = Color.FromArgb(255, 255, 255, 255);
            for (int i = 0; i < fTextOfColors.Length; i++)
            {
                fTextOfColors[i] = fColorsOfVariant[i].R.ToString() + ":" +
                                   fColorsOfVariant[i].G.ToString() + ":" + fColorsOfVariant[i].B.ToString();
            }
            l000.Text              += "   (" + fTextOfColors[0] + ")";
            l001.Text              += "   (" + fTextOfColors[1] + ")";
            l010.Text              += "   (" + fTextOfColors[2] + ")";
            l011.Text              += "   (" + fTextOfColors[3] + ")";
            l100.Text              += "   (" + fTextOfColors[4] + ")";
            l101.Text              += "   (" + fTextOfColors[5] + ")";
            l110.Text              += "   (" + fTextOfColors[6] + ")";
            l111.Text              += "   (" + fTextOfColors[7] + ")";
            l000.BackColor          = fColorsOfVariant[0];
            l001.BackColor          = fColorsOfVariant[1];
            l010.BackColor          = fColorsOfVariant[2];
            l011.BackColor          = fColorsOfVariant[3];
            l100.BackColor          = fColorsOfVariant[4];
            l101.BackColor          = fColorsOfVariant[5];
            l110.BackColor          = fColorsOfVariant[6];
            l111.BackColor          = fColorsOfVariant[7];
            l000.ForeColor          = CImageSplitter.DefineBestBackColor(fColorsOfVariant[0]);
            l001.ForeColor          = CImageSplitter.DefineBestBackColor(fColorsOfVariant[1]);
            l010.ForeColor          = CImageSplitter.DefineBestBackColor(fColorsOfVariant[2]);
            l011.ForeColor          = CImageSplitter.DefineBestBackColor(fColorsOfVariant[3]);
            l100.ForeColor          = CImageSplitter.DefineBestBackColor(fColorsOfVariant[4]);
            l101.ForeColor          = CImageSplitter.DefineBestBackColor(fColorsOfVariant[5]);
            l110.ForeColor          = CImageSplitter.DefineBestBackColor(fColorsOfVariant[6]);
            l111.ForeColor          = CImageSplitter.DefineBestBackColor(fColorsOfVariant[7]);
            fBordersByColorForImage = new CBordersByColorForImage(fSourceBitmap);
        }
示例#9
0
        //--------------------------------------------------------------------------------------
        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();
        }
示例#10
0
        //--------------------------------------------------------------------------------------
        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);
        }
示例#11
0
        //--------------------------------------------------------------------------------------
        public FImageExplorer()
        {
            InitializeComponent();
            tsbExec.Image                   = ilCom.Images[0];
            tsbBWExec.Image                 = ilCom.Images[0];
            tsbByRed.Image                  = ilCom.Images[4];
            tsbByBlue.Image                 = ilCom.Images[2];
            tsbByGreen.Image                = ilCom.Images[3];
            tsbShadow.Image                 = ilCom.Images[8];
            tsbShadowRed.Image              = ilCom.Images[7];
            tsbShadowBlue.Image             = ilCom.Images[5];
            tsbShadowGreen.Image            = ilCom.Images[6];
            tsbClean.Image                  = ilCom.Images[9];
            tsbCleanAccurate.Image          = ilCom.Images[10];
            tsbCleanAccurateDefault.Image   = ilCom.Images[11];
            tsbCleanSplit.Image             = ilCom.Images[13];
            tsbCleanExactSplit.Image        = ilCom.Images[13];
            tsbCleanExactDefaultSplit.Image = ilCom.Images[13];
            tsbColorSplit.Image             = ilCom.Images[14];
            tsbSplitByColor.Image           = ilCom.Images[15];
            tsbSplitByColorResult.Image     = ilCom.Images[15];
            fBlackWhiteExplorer             = new CBlackWhiteExplorer();
            tscbTypeSplit.SelectedIndex     = 0;
            cbClearColor.SelectedIndex      = 0;
            txtA0.Text    = "1.0";
            txtA1.Text    = Math.Round(1.0 / Math.Sqrt(2.0), 3).ToString();
            txtB0.Text    = "0.5";
            txtB1.Text    = Math.Round(1.0 / Math.Sqrt(5.0), 3).ToString();
            txtB2.Text    = Math.Round(1.0 / Math.Sqrt(8.0), 3).ToString();
            txtLimit.Text = "0.26";
            cbClearColor.SelectedIndex = 1;
            lShow.BackColor            = Color.Black;
            toolStrip2.Visible         = true;
            toolStrip5.Visible         = true;
            tabControl1.SelectedIndex  = 1;

            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("");
        }
示例#12
0
        //--------------------------------------------------------------------------------------
        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;
        }
示例#13
0
        //--------------------------------------------------------------------------------------
        private void toolStripButton2_Click_1(object sender, EventArgs e)
        {
            try
            {
                int     lWishColors  = Convert.ToInt32(tstWishfulColos.Text);
                Color[] lRealColors  = CBlackWhiteExplorer.DefineNeedColor(lWishColors);
                Color[] lFinalColors = CBlackWhiteExplorer.DefineExactNeedColor(lWishColors);
                tstSatisfColor.Text = lRealColors.Length.ToString();
                flpColors.Controls.Clear();
                int lNumberInString = 0;
                for (int i = 0; i < lRealColors.Length; i++)
                {
                    Panel lPanel = new Panel();
                    lPanel.BackColor = lRealColors[i];
                    lPanel.Width     = 50;
                    lPanel.Height    = 50;
                    TextBox lLabel = new TextBox();
                    lLabel.Multiline = true;
                    lLabel.Text      = "R:" +
                                       lRealColors[i].R.ToString("G") + Environment.NewLine + " G:" +
                                       lRealColors[i].G.ToString("G") + Environment.NewLine + " B:" +
                                       lRealColors[i].B.ToString("G");
                    lLabel.Width  = 50;
                    lLabel.Height = 50;
//                    lLabel.AutoSize = true;
                    flpColors.Controls.Add(lLabel);
                    flpColors.Controls.Add(lPanel);
                    lNumberInString += 2;
                    if (lNumberInString == 6)
                    {
                        //                        flpColors.SetFlowBreak(flpColors.Controls[flpColors.Controls.Count - 1]);
                        flpColors.SetFlowBreak(lPanel, true);
                        lNumberInString = 0;
                    }
                }
                lNumberInString = 0;
                flpFinalColors.Controls.Clear();
                for (int i = 0; i < lFinalColors.Length; i++)
                {
                    Panel lPanel = new Panel();
                    lPanel.BackColor = lFinalColors[i];
                    lPanel.Width     = 50;
                    lPanel.Height    = 50;
                    TextBox lLabel = new TextBox();
                    lLabel.Multiline = true;
                    lLabel.Text      = "R:" +
                                       lFinalColors[i].R.ToString("G") + Environment.NewLine + " G:" +
                                       lFinalColors[i].G.ToString("G") + Environment.NewLine + " B:" +
                                       lFinalColors[i].B.ToString("G");
                    lLabel.Width  = 50;
                    lLabel.Height = 50;
                    //                    lLabel.AutoSize = true;
                    flpFinalColors.Controls.Add(lLabel);
                    flpFinalColors.Controls.Add(lPanel);
                    lNumberInString += 2;
                    if (lNumberInString == 6)
                    {
                        //                        flpColors.SetFlowBreak(flpColors.Controls[flpColors.Controls.Count - 1]);
                        flpColors.SetFlowBreak(lPanel, true);
                        lNumberInString = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
示例#14
0
 //--------------------------------------------------------------------------------------
 /// <summary>
 /// удалить маленькие области из картинки (предварительно преобразовав ее в 0.1 матрицу)
 /// </summary>
 /// <param name="pImage">картинка для преобразования</param>
 /// <param name="pWhat">цвет рисунка</param>
 /// <param name="pThreshold">предельный размер удаляемых</param>
 /// <returns>результирующая матрица очищенная от маленьких связанных областей</returns>
 public byte[][] RemoveSmallRegion(Bitmap pImage, byte pWhat, int pThreshold)
 {
     byte[][] lMatrix = CBlackWhiteExplorer.BitmapToBinaryMatrix(pImage);
     return(RemoveSmallRegion(lMatrix, pWhat, pThreshold));
 }
示例#15
0
 //--------------------------------------------------------------------------------------
 /// <summary>
 /// разбить рисунок на отдельные куски в виде списка матриц по методу единной матрицы
 /// </summary>
 /// <param name="pImage"></param>
 /// <param name="pNumberColor"></param>
 /// <returns></returns>
 public int[][] SplitByOneMatrix(Bitmap pImage, out int pNumberColor)
 {
     byte[][] lMatrix = CBlackWhiteExplorer.BitmapToBinaryMatrix(pImage);
     return(SplitByOneMatrix(lMatrix, out pNumberColor));
 }
示例#16
0
 //--------------------------------------------------------------------------------------
 /// <summary>
 /// разбить рисунок на отдельные куски в виде списка матриц по методу матриц
 /// </summary>
 /// <param name="pImage"></param>
 /// <param name="pWhat"></param>
 /// <returns></returns>
 public List <byte[][]> SplitByMatrix(Bitmap pImage, byte pWhat)
 {
     byte[][] lMatrix = CBlackWhiteExplorer.BitmapToBinaryMatrix(pImage);
     return(SplitByMatrix(lMatrix, pWhat));
 }
示例#17
0
 //--------------------------------------------------------------------------------------
 /// <summary>
 /// разбить рисунок на отдельные куски в виде списка матриц по методу множеств
 /// </summary>
 /// <param name="pImage"></param>
 /// <returns></returns>
 public List <byte[][]> SplitBySet(Bitmap pImage)
 {
     byte[][] lMatrix = CBlackWhiteExplorer.BitmapToBinaryMatrix(pImage);
     return(SplitBySet(lMatrix));
 }
示例#18
0
 //--------------------------------------------------------------------------------------
 public CBordersByColorForImage(Bitmap pImage)
 {
     fBlackWhiteExplorer = new CBlackWhiteExplorer();
     fSourceBitmap       = pImage;
     fBadPointList       = new List <CBadPointData>();
 }