Exemplo n.º 1
0
        //tabcontrol indexChange
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            TabControl page = sender as TabControl;
            switch (page.SelectedIndex)
            {
                case 1:
                    #region Transfer to grayscale
                    imageConverter.Progress += ImageConverter_Progress;
                    if (originalImage != null)
                    {
                        grayBitmap = imageConverter.TransferToGrayscaleGetBitmap(originalImage);
                        GrayScalePictureBox.Image = grayBitmap;
                    }
                    else
                    {
                        grayBitmap = OpenImage();
                        GrayScalePictureBox.Image = grayBitmap;
                    }

                    break;
                #endregion
                case 2:
                    #region Binarization image
                    ThresholdValue();
                    if (grayBitmap != null)
                    {
                        imageConverter.Progress += ImageConverter_Progress;
                        Bitmap binarizationImage = imageConverter.BinarizationThresholdMethodGetBitmap(grayBitmap);
                        binary = binarizationImage;
                        //rotate image
                        Bitmap afterRotete = rotateBitmapImage.RotateBitmap(binary, GetAngleRotate());
                        binary = afterRotete;
                        BinarizationPictureBox.Image = binary;
                        var resultGisto = transformation.Parameters(imageConverter.BinarizationThresholdMethodGetArray(binary));
                        mainList = resultGisto;

                    }
                    else if (binary == null)
                    {
                        binary = OpenImage();
                        //rotate image
                        Bitmap afterRotete = rotateBitmapImage.RotateBitmap(binary, GetAngleRotate());
                        BinarizationPictureBox.Image = afterRotete;
                        binary = afterRotete;
                        var resultGisto = transformation.Parameters(imageConverter.BinarizationThresholdMethodGetArray(afterRotete));
                        mainList = resultGisto;
                    }
                    break;
                #endregion
                case 3:
                    #region Segmentation
                    imageConverter.Progress += ImageConverter_Progress;
                    var arrayImage = imageConverter.BinarizationThresholdMethodGetArray(binary);
                    Segmentation segment = new Segmentation(arrayImage, mainList);
                    // remove up and down element image and
                    Bitmap UpDownRemove = imageConverter.CreateBitmap(segment.RemoveUpAndDownElementImage(mainList, arrayImage));
                    //removing unnecessary lines segment.SelectionOfAreas()
                    var segmentImageInfo = imageConverter.CreateBitmap(segment.SelectionOfAreas());
                    //get array new small image
                    var arrayNewImage = imageConverter.BinarizationThresholdMethodGetArray(segmentImageInfo);
                    //get list params histogramm
                    var paramsForHistogrammNewImage = transformation.HorizontalImageGetParameters(arrayNewImage);
                    var miniArray = segment.SelectionOfAreasInHorizontalImage(paramsForHistogrammNewImage, arrayNewImage);
                    miniArray = segment.RemoveBorder(miniArray);
                    var finishImageRecognition = imageConverter.CreateBitmap(miniArray);
                    SegmentationPictureBox.Image = finishImageRecognition;
                    //var afterBin = imageConverter.BinarizationThresholdMethodGetArray(seg);
                    //var Gisto2 = trans.HorizontalImageGetParameters(afterBin);
                    DividedImage = miniArray;
                    //get params miniImage fo segmentations numbers
                    DividedImageList = transformation.HorizontalImageGetParameters(miniArray);
                    ImageRecognitionPictureBox1.Image = finishImageRecognition;
                    DividedIntoImageButton.Enabled = true;
                    binary = null;
                    grayBitmap = null;
                    numberImageCollection.Clear();
                    #endregion
                    break;
            }
        }