コード例 #1
1
ファイル: Processing.cs プロジェクト: Narrya/Image_Processing
        private void cBFilters_SelectedIndexChanged(object sender, EventArgs e)
        {
            Bitmap pictureTransform = (Bitmap)pbChoose.Image;
                if ((string)cBFilters.SelectedItem == "HSL_Filter")
                {
                    AForge.Imaging.Filters.SaturationCorrection filter = new SaturationCorrection(0.1);
                    Bitmap newImage = filter.Apply(pictureTransform);
                    pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                    pBNew.Image = newImage;
                }

                if ((string)cBFilters.SelectedItem == "Mediana")
                {
                    AForge.Imaging.Filters.Median filter = new Median();
                    Bitmap newImage = filter.Apply(pictureTransform);
                    pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                    pBNew.Image = newImage;
                }

                /*if ((string)cBFilters.SelectedItem == "Fourier_Transformation")
                {
                 Complex[] dst = new Complex[n];

                    AForge.Math.FourierTransform filter = AForge.Math.FourierTransform.DFT();// .FromBitmap(pictureTransform);
                    Bitmap newImage = filter.Apply();
                    pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                    pBNew.Image = newImage;
                }*/

                if ((string)cBFilters.SelectedItem == "Binarization")
                {
                    pictureTransform = Grayscale.CommonAlgorithms.BT709.Apply(pictureTransform);
                    Threshold threshold = new Threshold(127);
                    threshold.ApplyInPlace(pictureTransform);
                    pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                    pBNew.Image = pictureTransform;
                }

                if ((string)cBFilters.SelectedItem == "Grayscale")
                {
                    AForge.Imaging.Filters.Grayscale filter = new AForge.Imaging.Filters.Grayscale(0.2125, 0.7154, 0.0721);
                    Bitmap newImage = filter.Apply(pictureTransform);
                    pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                    pBNew.Image = newImage;
                }

                if ((string)cBFilters.SelectedItem == "FillHoles")
                {

                    pictureTransform = Grayscale.CommonAlgorithms.BT709.Apply(pictureTransform);
                    Threshold threshold = new Threshold(127);
                    threshold.ApplyInPlace(pictureTransform);
                    AForge.Imaging.Filters.FillHoles filter = new AForge.Imaging.Filters.FillHoles();
                    filter.MaxHoleHeight = 5;
                    filter.MaxHoleWidth = 15;
                    filter.CoupledSizeFiltering = false;
                    Bitmap newImage = filter.Apply(pictureTransform);
                    pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                    pBNew.Image = newImage;
                }

                if ((string)cBFilters.SelectedItem == "Opening")
                {
                    AForge.Imaging.Filters.Opening filter = new AForge.Imaging.Filters.Opening();
                    Bitmap newImage = filter.Apply(pictureTransform);
                    pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                    pBNew.Image = newImage;
                }

                if ((string)cBFilters.SelectedItem == "Closing")
                {
                    AForge.Imaging.Filters.Closing filter = new AForge.Imaging.Filters.Closing();
                    Bitmap newImage = filter.Apply(pictureTransform);
                    pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                    pBNew.Image = newImage;
                }

                if ((string)cBFilters.SelectedItem == "Erosion")
                {
                    AForge.Imaging.Filters.Erosion filter = new AForge.Imaging.Filters.Erosion();
                    Bitmap newImage = filter.Apply(pictureTransform);
                    pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                    pBNew.Image = newImage;
                }

                if ((string)cBFilters.SelectedItem == "Dilatation")
                {
                    AForge.Imaging.Filters.Dilatation filter = new AForge.Imaging.Filters.Dilatation();
                    Bitmap newImage = filter.Apply(pictureTransform);
                    pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                    pBNew.Image = newImage;
                }

                if ((string)cBFilters.SelectedItem == "Edges")
                {
                    AForge.Imaging.Filters.Edges filter = new AForge.Imaging.Filters.Edges();
                    Bitmap newImage = filter.Apply(pictureTransform);
                    pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                    pBNew.Image = newImage;
                }
        }
コード例 #2
0
        public VideoProcessor()
        {
            background = null;

            pixelateFilter = new Pixellate();
            pixelateFilter.PixelSize = 10;

            differenceFilter = new Difference();
            thresholdFilter = new Threshold(15);
            grayscaleFilter = new Grayscale(0.2125, 0.7154, 0.0721);
            erosionFilter = new Erosion();

            moveTowardsFilter = new MoveTowards();

            filters1 = new FiltersSequence();
            filters1.Add(pixelateFilter);
            filters1.Add(grayscaleFilter);

            filters2 = new FiltersSequence();

            filters2.Add(differenceFilter);
            filters2.Add(thresholdFilter);
            filters2.Add(erosionFilter);

            rat1 = new Tracker(640 / 2, 480 / 2, Color.Red);

            rat2 = new Tracker(400, 300, Color.Green);

            counter = 0;
        }
コード例 #3
0
        public void GenerateThumbnails(ThumbnailGenerationParameters parameters)
        {
            var textureConverterFactory = new TextureConverterFactory();
             using (var textureConverter = textureConverterFactory.Create()) {
            IFilter grayscaleFilter = new Grayscale(0.3, 0.59, 0.11);
            IInPlaceFilter edgeDetectionFilter = new HomogenityEdgeDetector();
            SliceRatingCalculator ratingCalculator = new SliceRatingCalculator();
            var utilities = new ThumbnailGeneratorUtilities(textureConverter);
            var slicePicker = new SlicePicker(grayscaleFilter, edgeDetectionFilter, ratingCalculator, utilities);
            var aspectRatio = 16 / (double)9;
            var sliceCount = 5;
            var resultWidth = 400;
            var resultHeight = (int)(resultWidth / aspectRatio);
            var sliceWidth = resultWidth / sliceCount;

            var bitmaps = utilities.EnumerateBitmapsRandomly(parameters.SourceDirectory).Take(100).ToList();

            var slices = slicePicker.PickSlices(bitmaps, new Size(sliceWidth, resultHeight));
            var sliceCombiner = new SliceCombiner(utilities, grayscaleFilter);
            for (var i = 0; i < parameters.ThumbnailsToGenerate; i++) {
               var bitmap = sliceCombiner.CombineSlices(slices, kSlicesPerThumbnail);
               using (var ms = new MemoryStream()) {
                  bitmap.Save(ms, ImageFormat.Jpeg);
                  ms.Position = 0;
                  var hash = MD5.Create().ComputeHash(ms).ToHex();
                  var outputName = hash + "_" + DateTime.UtcNow.GetUnixTime().ToString() + ".jpg";
                  var outputPath = Path.Combine(parameters.DestinationDirectory, outputName);
                  ms.Position = 0;
                  using (var fs = File.OpenWrite(outputPath)) {
                     ms.CopyTo(fs);
                  }
               }
            }
             }
        }
コード例 #4
0
ファイル: ImageProcessor.cs プロジェクト: vzavadko/DA
        static ImageProcessor()
        {
            imageQuantizer = new ColorImageQuantizer(new MedianCutQuantizer());

            grayscale = Grayscale.CommonAlgorithms.BT709;

            edgeDetector = new CannyEdgeDetector();
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: bdus/AForge
        private void button1_Click(object sender, EventArgs e)
        {
            //Grayscale
            Bitmap b = new Bitmap(pictureBox2.Image);
            b = new Grayscale(0.299, 0.587, 0.114).Apply(b);

            this.pictureBox2.Image = b;
        }
コード例 #6
0
        private Bitmap preProcessImage(Bitmap image, Grayscale gScale, SobelEdgeDetector sEgDetector, SimplePosterization posterization)
        {
            Bitmap temp = image;
            temp = gScale.Apply(temp);
            posterization.ApplyInPlace(temp);

            return temp;
        }
コード例 #7
0
ファイル: DeskewFilter.cs プロジェクト: SuperJMN/Glass
 public BitmapSource Apply(BitmapSource image)
 {
     var filter = new DocumentSkewChecker();
     var bitmap = image.ToBitmap();
     var grayscale = new Grayscale(0.2125, 0.7154, 0.0721).Apply(bitmap);
     var angle = filter.GetSkewAngle(grayscale);
     var rotationFilter = new RotateBilinear(-angle);
     return rotationFilter.Apply(grayscale).ToBitmapImage();
 }
コード例 #8
0
 private void grayscaleButton_Click(object sender, RoutedEventArgs e)
 {
     Bitmap temp = Compatibility.Compatibility.BitmapImageToBitmap((BitmapImage)image1.Source.Clone());
     // create grayscale filter (BT709)
     Grayscale filter = new Grayscale(0.2125, 0.7154, 0.0721);
     // apply the filter
     grayImage = filter.Apply(temp);
     bi = Compatibility.Compatibility.BitmapToBitmapImage(grayImage);
     image1.Source = bi;
 }
コード例 #9
0
ファイル: Form1.cs プロジェクト: bdus/AForge
        private void button2_Click(object sender, EventArgs e)
        {
            Bitmap b = new Bitmap(pictureBox2.Image);
            //            b = new Grayscale(0.7, 0.2, 0.1).Apply(b);
            b = new Grayscale(0.299, 0.587, 0.114).Apply(b);

            b = new Threshold(50).Apply(b);

            this.pictureBox2.Image = b;
        }
コード例 #10
0
ファイル: ImageHelpers.cs プロジェクト: nikodemrafalski/Fuzz
        public static Bitmap ConvertToGrayScale(this Bitmap sourceImage)
        {
            var filter = new Grayscale(0.2125, 0.7154, 0.0721);
            if (Image.IsGrayscale(sourceImage))
            {
                return sourceImage;
            }

            Bitmap converted = filter.Apply(sourceImage);
            return converted;
        }
コード例 #11
0
ファイル: OMRSoft.cs プロジェクト: SevaSoluation/OMR-Scanner
 private Bitmap filter()
 {
     Bitmap filtered_image;
     AForge.Imaging.Filters.Grayscale gr = new AForge.Imaging.Filters.Grayscale(0.2125, 0.7154, 0.0721);
     AForge.Imaging.Filters.Threshold th = new AForge.Imaging.Filters.Threshold(100);
     AForge.Imaging.Filters.Invert invert = new AForge.Imaging.Filters.Invert();
     filtered_image = gr.Apply(scanned_image);
     filtered_image = invert.Apply(filtered_image);
     filtered_image = th.Apply(filtered_image);
     return filtered_image;
 }
コード例 #12
0
ファイル: OMRSoft.cs プロジェクト: srvsk/OMR-Scanner
        private Bitmap filter()
        {
            Bitmap filtered_image;

            AForge.Imaging.Filters.Grayscale gr     = new AForge.Imaging.Filters.Grayscale(0.2125, 0.7154, 0.0721);
            AForge.Imaging.Filters.Threshold th     = new AForge.Imaging.Filters.Threshold(100);
            AForge.Imaging.Filters.Invert    invert = new AForge.Imaging.Filters.Invert();
            filtered_image = gr.Apply(scanned_image);
            filtered_image = invert.Apply(filtered_image);
            filtered_image = th.Apply(filtered_image);
            return(filtered_image);
        }
コード例 #13
0
        public static Bitmap DoIt(Bitmap bmp)
        {
            GaussianBlur blur = new GaussianBlur(10, 50);
            Bitmap blurred = blur.Apply(bmp);

            Bitmap ret = new Bitmap(blurred.Width, blurred.Height, blurred.PixelFormat);

            for (int y = 0; y < blurred.Height; y++)
            {
                for (int x = 0; x < blurred.Width; x++)
                {
                    Color blurredColor = blurred.GetPixel(x, y);
                    Color orinalColor = bmp.GetPixel(x, y);

                    Color newColor = Color.FromArgb((blurredColor.R + orinalColor.R * 2) / 3,
                        (blurredColor.G + orinalColor.G * 2) / 3,
                        (blurredColor.B + orinalColor.B * 2) / 3);

                    ret.SetPixel(x, y, newColor);
                }
            }

            GammaCorrection gc = new GammaCorrection(.8);
            gc.ApplyInPlace(ret);

            Sharpen sharpen = new Sharpen();
            sharpen.ApplyInPlace(ret);

            Grayscale filter = new Grayscale(0.2125, 0.7154, 0.0721);
            Bitmap gray = filter.Apply(ret);

            CannyEdgeDetector canny = new CannyEdgeDetector();
            gray = canny.Apply(gray);

            for (int y = 0; y < gray.Height; y++)
            {
                for (int x=0;x < gray.Width; x++)
                {
                    if(gray.GetPixel(x,y).R > 0)
                    {
                        Color retColor = ret.GetPixel(x, y);
                        Color newColor = Color.FromArgb(
                            (int)(retColor.R * .7),
                            (int)(retColor.G * .7),
                            (int)(retColor.B * .7));

                        ret.SetPixel(x, y, newColor);
                    }
                }
            }

            return ret;
        }
コード例 #14
0
 public static Bitmap EscalaGrises(Bitmap image)
 {
     try
     {
         AForge.Imaging.Filters.Grayscale filter   = new AForge.Imaging.Filters.Grayscale(0.30, 0.59, 0.11);
         System.Drawing.Bitmap            newImage = filter.Apply(image);
         return(newImage);
     }
     catch (ArgumentException ex)
     {
         MessageBox.Show("No se puede apllicar el filtro" + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(null);
     }
 }
コード例 #15
0
        private void initiateButton_Click(object sender, RoutedEventArgs e)
        {
            // create grayscale filter (BT709)
            Grayscale filter = new Grayscale(0.2125, 0.7154, 0.0721);
            // apply the filter
            img1 = filter.Apply(img1);
            img2 = filter.Apply(img2);

            Stopwatch st = new Stopwatch();
            st.Start();

            // collect reference points using corners detector (for example)
            SusanCornersDetector scd = new SusanCornersDetector(30, 18);
            List<IntPoint> points = scd.ProcessImage(img1);

            // create block matching algorithm's instance
            ExhaustiveBlockMatching bm = new ExhaustiveBlockMatching(12, 36);
            // process images searching for block matchings
            List<BlockMatch> matches = bm.ProcessImage(img1, points, img2);

            st.Stop();
            TimeSpan elapsed = st.Elapsed;
            timedisp.Text = "Elapsed time = " + elapsed.ToString();

            // draw displacement vectors
            BitmapData data = img1.LockBits(
                new System.Drawing.Rectangle(0, 0, img1.Width, img1.Height),
                ImageLockMode.ReadWrite, img1.PixelFormat);

            foreach (BlockMatch match in matches)
            {
                // highlight the original point in source image
                AForge.Imaging.Drawing.FillRectangle(data,
                    new System.Drawing.Rectangle(match.SourcePoint.X - 1, match.SourcePoint.Y - 1, 3, 3),
                    System.Drawing.Color.Yellow);
                // draw line to the point in search image
                AForge.Imaging.Drawing.Line(data, match.SourcePoint, match.MatchPoint, System.Drawing.Color.Red);

                // check similarity
                if (match.Similarity > 0.98f)
                {
                    // process block with high similarity
                }
            }

            img1.UnlockBits(data);
            bi = Compatibility.Compatibility.BitmapToBitmapImage(img1);
            image1.Source = bi;
        }
コード例 #16
0
ファイル: PlateRecognizer.cs プロジェクト: andremn/SPS
        private WriteableBitmap FindPlate(IEnumerable<Rect> rects, WriteableBitmap image)
        {
            WriteableBitmap bestCandidate = null;
            
            foreach (var rect in rects)
            {
                var croppedImage = image.Crop(rect);
                var edgeFilter = new CannyEdgeDetector();
                var smoothFilter = new Median();
                var grayFilter = new Grayscale(0.2125, 0.7154, 0.0721);
                var blobCounter = new BlobCounter();
                var cutTop = croppedImage.PixelHeight * 0.3;

                croppedImage = croppedImage.Crop(new Rect(0, cutTop, croppedImage.PixelWidth, croppedImage.PixelHeight));

                var bitmap = (Bitmap)croppedImage;
                var grayImage = grayFilter.Apply(bitmap);

                bitmap = smoothFilter.Apply(grayImage);
                edgeFilter.ApplyInPlace(bitmap);
                blobCounter.ProcessImage(bitmap);

                var blobs = blobCounter.GetObjectsInformation();
                var possibleChars = new List<Rectangle>();

                foreach (var blob in blobs)
                {
                    var objRectangle = blob.Rectangle;
                    var ratio = (double)objRectangle.Height / (double)objRectangle.Width;
                    
                    if (ratio >= 1.16d && ratio <= 6.3d)
                    {
                        possibleChars.Add(objRectangle);
                    }
                }

                if (possibleChars.Count == 0)
                {
                    continue;
                }

                bestCandidate = croppedImage;
            }

            return bestCandidate;
        }
コード例 #17
0
 public bool applyGrayscale()
 {
     if (currentImage != null)
     {
         try
         {
             // create grayscale filter (BT709)
             Grayscale filter = new Grayscale(0.2125, 0.7154, 0.0721);
             // apply the filter
             currentImage = filter.Apply(currentImage);
             return true;
         }
         catch (Exception)
         { }
     }
     return false;
 }
コード例 #18
0
ファイル: MotionDetector.cs プロジェクト: raze1392/Motionizer
        /// <summary>
        /// processes Frame for Motion Detection based on background generation
        /// </summary>
        /// <param name="frame">
        /// Takes in 2 Bitmap parameters, currentFrame and backgroundFrame
        /// </param>
        /// <returns>
        /// frame in which motion is marked
        /// </returns>
        public Bitmap processFrame(params Bitmap[] frame)
        {
            Bitmap currentFrame = frame[0];
            // create grayscale filter (BT709)
            Grayscale filter = new Grayscale(0.2125, 0.7154, 0.0721);
            Bitmap GScurrentFrame = filter.Apply(currentFrame);
            if (this.backgroundFrame == null)
            {
                this.backgroundFrame = (Bitmap)GScurrentFrame.Clone();
                GScurrentFrame.Dispose();
                return currentFrame;
            }
            else
            {
                Morph filterx = new Morph(GScurrentFrame);
                filterx.SourcePercent = 0.75;
                Bitmap tmp = filterx.Apply(backgroundFrame);
                // dispose old background
                backgroundFrame.Dispose();
                backgroundFrame = tmp;

                // create processing filters sequence
                FiltersSequence processingFilter = new FiltersSequence();
                processingFilter.Add(new Difference(backgroundFrame));
                processingFilter.Add(new Threshold(threshold_val));
                processingFilter.Add(new Opening());
                processingFilter.Add(new Edges());
                // apply the filter
                Bitmap tmp1 = processingFilter.Apply(GScurrentFrame);

                IFilter extractChannel = new ExtractChannel(RGB.R);
                Bitmap redChannel = extractChannel.Apply(currentFrame);
                Merge mergeFilter = new Merge();
                mergeFilter.OverlayImage = tmp1;
                Bitmap t3 = mergeFilter.Apply(redChannel);
                ReplaceChannel rc = new ReplaceChannel(RGB.R, t3);
                t3 = rc.Apply(currentFrame);
                redChannel.Dispose();
                tmp1.Dispose();
                GScurrentFrame.Dispose();
                return t3;
            }
        }
コード例 #19
0
        public double GetTemperature()
        {
            var temp = 0.0;

            var image = Image.FromFile(filename);

            var grayscale = new Grayscale(0.2125, 0.7154, 0.0721);
            image = grayscale.Apply(image);

            var invert = new Invert();
            image = invert.Apply(image);

            var stats = new ImageStatistics(image);
            var levelsLinear = new LevelsLinear
            {
                InGray = stats.Gray.GetRange(2.90)
            };

            image = levelsLinear.Apply(image);

            var contrast = new ContrastStretch();
            image = contrast.Apply(image);

            var erosion = new Erosion();
            image = erosion.Apply(image);

            var blur = new GaussianBlur(2, 3);
            image = blur.Apply(image);

            var threshold = new Threshold(79);
            image = threshold.Apply(image);

            image.Save(processedFileName, System.Drawing.Imaging.ImageFormat.Jpeg);
            image.Dispose();
            var text = Recognise();

            double.TryParse(text.Replace(',', '.'), out temp);

            return temp;
        }
コード例 #20
0
 /// <summary>
 /// processes Frame for Motion Detection based on frame comparison
 /// </summary>
 /// <param name="frame">
 /// Takes in 2 Bitmap parameters, currentFrame and backgroundFrame
 /// </param>
 /// <returns>
 /// frame in which motion is marked
 /// </returns>
 public Bitmap processFrame(params Bitmap[] frame)
 {
     Bitmap currentFrame = frame[0];
     // create grayscale filter (BT709)
     Grayscale filter = new Grayscale(0.2125, 0.7154, 0.0721);
     Bitmap GScurrentFrame = filter.Apply(currentFrame);
     if (this.backgroundFrame == null)
     {
         this.backgroundFrame = (Bitmap)GScurrentFrame.Clone();
         GScurrentFrame.Dispose();
         return currentFrame;
     }
     else
     {
         Difference differenceFilter = new Difference();
         IFilter thresholdFilter = new Threshold(15);
         // set backgroud frame as an overlay for difference filter
         differenceFilter.OverlayImage = backgroundFrame;
         Bitmap tmp = thresholdFilter.Apply(differenceFilter.Apply(GScurrentFrame));
         //reduce noise
         IFilter erosionFilter = new Erosion();
         Bitmap tmp1 = erosionFilter.Apply(tmp);
         tmp.Dispose();
         // Highlight Motions
         IFilter extractChannel = new ExtractChannel(RGB.G);
         Bitmap redChannel = extractChannel.Apply(currentFrame);
         Merge mergeFilter = new Merge();
         mergeFilter.OverlayImage = tmp1;
         Bitmap t3 = mergeFilter.Apply(redChannel);
         ReplaceChannel rc = new ReplaceChannel(RGB.G, t3);
         t3 = rc.Apply(currentFrame);
         this.backgroundFrame = (Bitmap)GScurrentFrame.Clone();
         redChannel.Dispose();
         tmp1.Dispose();
         GScurrentFrame.Dispose();
         return t3;
     }
 }
コード例 #21
0
ファイル: Form1.cs プロジェクト: zStyle/GoRecorder
        // Process image
        private void ProcessImage(Bitmap bitmap)
        {
            // create filter
            HistogramEqualization hisFilter = new HistogramEqualization();
            // process image
            //hisFilter.ApplyInPlace(Image);

            // create filter
            ContrastCorrection contrastFilter = new ContrastCorrection(4);
            // apply the filter
            contrastFilter.ApplyInPlace(bitmap);

            //QuantizeImage(bitmap);

            Grayscale grayscaleFilter = new Grayscale(0.33, 0.33, 0.34);
            // apply the filter
            Bitmap grayImage = grayscaleFilter.Apply(bitmap);

            // create filter
            SobelEdgeDetector sobelFilter = new SobelEdgeDetector();
            // apply the filter
            sobelFilter.ApplyInPlace(grayImage);
            Threshold filter = new Threshold(110);
            // apply the filter
            filter.ApplyInPlace(grayImage);

            if (GetIntersect(grayImage, bitmap, intersectPoint)) {
                //MessageBox.Show("draw");
                Graphics g = Graphics.FromImage(bitmap);
                //Sorting

                for (int i = 0; i < 19; i++)
                {
                    for (int j = 0; j < 19; j++)
                    {
                        for (int k = 0; k < 19 - 1; k++)
                        {
                            if (Math.Abs(intersectPoint[1, i, k]) > Math.Abs(intersectPoint[1, i, k + 1]))
                            {
                                int tempX = Math.Abs(intersectPoint[0, i, k]);
                                int tempY = Math.Abs(intersectPoint[1, i, k]);
                                intersectPoint[0, i, k] = Math.Abs(intersectPoint[0, i, k + 1]);
                                intersectPoint[1, i, k] = Math.Abs(intersectPoint[1, i, k + 1]);
                                intersectPoint[0, i, k + 1] = tempX;
                                intersectPoint[1, i, k + 1] = tempY;
                                //MessageBox.Show(i + " " + k +" " +tempX + " " + tempY + " " + intersectPoint[0, i, k] + " " + intersectPoint[1, i, k] ,"ok", MessageBoxButtons.OK);
                            }
                        }
                    }
                }

                for (int i = 0; i < 19; i++)
                {
                    for (int j = 0; j < 19; j++)
                    {
                        for (int k = 0; k < 19 - 1; k++)
                        {
                            if (Math.Abs(intersectPoint[0, k, i]) > Math.Abs(intersectPoint[0, k + 1, i]))
                            {
                                int tempX = Math.Abs(intersectPoint[0, k, i]);
                                int tempY = Math.Abs(intersectPoint[1, k, i]);
                                intersectPoint[0, k, i] = intersectPoint[0, k + 1, i];
                                intersectPoint[1, k, i] = intersectPoint[1, k + 1, i];
                                intersectPoint[0, k + 1, i] = tempX;
                                intersectPoint[1, k + 1, i] = tempY;
                            }
                        }
                    }
                }

                Pen redPen = new Pen(Color.Red, 4);
                for (int i = 0; i < 19; i++)
                {
                    for (int j = 0; j < 19; j++)
                    {
                        g.DrawEllipse(redPen, Math.Abs(intersectPoint[0, i, j]) , Math.Abs(intersectPoint[1, i, j]) , (int)5, (int)5);
                        //g.DrawEllipse(redPen, 0, 0, (int)5, (int)5);

                        //Debug.WriteLine((Math.Abs(intersectPoint[0, i, j]) - 2) + " " + (Math.Abs(intersectPoint[1, i, j]) - 2));
                    }
                }

                Pen greenPen = new Pen(Color.Green, 4);

                greenPen.Dispose();
                redPen.Dispose();
                g.Dispose();

                // Initializes the variables to pass to the MessageBox.Show method.
                EspacioCamera.Image = bitmap;
                string message = "Do you accecpt this detection?";
                string caption = "The system found totally 38 lines.";
                MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                DialogResult result;

                // Displays the MessageBox.

                result = MessageBox.Show(message, caption, buttons);

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    // Closes the parent form.
                    locked = true;
                }
            }

            EspacioCamera.Image = bitmap;
        }
コード例 #22
0
 public static Bitmap ToBlackAndWhite(this Bitmap bitmap)
 {
     AForge.Imaging.Filters.Grayscale filter = Grayscale.CommonAlgorithms.Y;
     return(filter.Apply(AForge.Imaging.Image.Clone(bitmap, PixelFormat.Format24bppRgb)));
 }
コード例 #23
0
        public static Image ToGrayScale(Image img)
        {
            var filterGreyScale = new Grayscale(0.2125, 0.7154, 0.0721);

            return filterGreyScale.Apply((Bitmap)img);
        }
コード例 #24
0
        public void Dilatate()
        {
            var se = new short[,] {  {1, 1, 1},
                                     {1, 1, 1},
                                     {1, 1, 1}  };

            Grayscale grayScaler = new Grayscale(0.2125, 0.7154, 0.0721);
            Dilatation dilatationFilter = new Dilatation(se);
            _digit = dilatationFilter.Apply(grayScaler.Apply(new Bitmap(_digit)));
        }
コード例 #25
0
        public void HitAndMiss()
        {
            var se = new short[,] { { -1, -1, -1 },
                                    {  1,  1,  0 },
                                    { -1, -1, -1 } };

            HitAndMiss filter = new HitAndMiss(se, AForge.Imaging.Filters.HitAndMiss.Modes.Thinning);
            Grayscale grayScaler = new Grayscale(0.2125, 0.7154, 0.0721);
            _digit = filter.Apply(grayScaler.Apply(new Bitmap(_digit)));
        }
コード例 #26
0
 public void ClosingMorfology()
 {
     Grayscale grayScaler = new Grayscale(0.2125, 0.7154, 0.0721);
     Closing closingFilter = new Closing();
     _digit = closingFilter.Apply(grayScaler.Apply(new Bitmap(_digit)));
 }
コード例 #27
0
 public Histogram DigitHistogram()
 {
     Grayscale grayScaler = new Grayscale(0.2125, 0.7154, 0.0721);
     ImageStatistics stat = new ImageStatistics(grayScaler.Apply(new Bitmap(_digit)));
     return stat.Gray;
 }
コード例 #28
0
ファイル: GrayscaleFilter.cs プロジェクト: SuperJMN/Glass
 protected Bitmap ToGrayScale(BitmapSource image)
 {
     var bitmap = image.ToBitmap();
     var grayScale = new Grayscale(0.2125, 0.7154, 0.0721).Apply(bitmap);
     return grayScale;
 }
コード例 #29
0
ファイル: Camera.cs プロジェクト: daveframe/LitePlacer-DEV
 // ========================================================= Contrast_scretchFunc
 private void GrayscaleFunc(ref Bitmap frame, int par_int, double par_d, int par_R, int par_G, int par_B)
 {
     Grayscale toGrFilter = new Grayscale(0.2125, 0.7154, 0.0721);       // create grayscale MirrFilter (BT709)
     Bitmap fr = toGrFilter.Apply(frame);
     GrayscaleToRGB toColFilter = new GrayscaleToRGB();
     frame = toColFilter.Apply(fr);
 }
コード例 #30
0
        private void cBFilters_SelectedIndexChanged(object sender, EventArgs e)
        {
            Bitmap pictureTransform = (Bitmap)pbChoose.Image;

            if ((string)cBFilters.SelectedItem == "HSL_Filter")
            {
                AForge.Imaging.Filters.SaturationCorrection filter = new SaturationCorrection(0.1);
                Bitmap newImage = filter.Apply(pictureTransform);
                pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                pBNew.Image       = newImage;
            }

            if ((string)cBFilters.SelectedItem == "Mediana")
            {
                AForge.Imaging.Filters.Median filter = new Median();
                Bitmap newImage = filter.Apply(pictureTransform);
                pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                pBNew.Image       = newImage;
            }

            /*if ((string)cBFilters.SelectedItem == "Fourier_Transformation")
             * {
             * Complex[] dst = new Complex[n];
             *
             *  AForge.Math.FourierTransform filter = AForge.Math.FourierTransform.DFT();// .FromBitmap(pictureTransform);
             *  Bitmap newImage = filter.Apply();
             *  pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
             *  pBNew.Image = newImage;
             * }*/

            if ((string)cBFilters.SelectedItem == "Binarization")
            {
                pictureTransform = Grayscale.CommonAlgorithms.BT709.Apply(pictureTransform);
                Threshold threshold = new Threshold(127);
                threshold.ApplyInPlace(pictureTransform);
                pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                pBNew.Image       = pictureTransform;
            }

            if ((string)cBFilters.SelectedItem == "Grayscale")
            {
                AForge.Imaging.Filters.Grayscale filter = new AForge.Imaging.Filters.Grayscale(0.2125, 0.7154, 0.0721);
                Bitmap newImage = filter.Apply(pictureTransform);
                pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                pBNew.Image       = newImage;
            }

            if ((string)cBFilters.SelectedItem == "FillHoles")
            {
                pictureTransform = Grayscale.CommonAlgorithms.BT709.Apply(pictureTransform);
                Threshold threshold = new Threshold(127);
                threshold.ApplyInPlace(pictureTransform);
                AForge.Imaging.Filters.FillHoles filter = new AForge.Imaging.Filters.FillHoles();
                filter.MaxHoleHeight        = 5;
                filter.MaxHoleWidth         = 15;
                filter.CoupledSizeFiltering = false;
                Bitmap newImage = filter.Apply(pictureTransform);
                pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                pBNew.Image       = newImage;
            }

            if ((string)cBFilters.SelectedItem == "Opening")
            {
                AForge.Imaging.Filters.Opening filter = new AForge.Imaging.Filters.Opening();
                Bitmap newImage = filter.Apply(pictureTransform);
                pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                pBNew.Image       = newImage;
            }

            if ((string)cBFilters.SelectedItem == "Closing")
            {
                AForge.Imaging.Filters.Closing filter = new AForge.Imaging.Filters.Closing();
                Bitmap newImage = filter.Apply(pictureTransform);
                pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                pBNew.Image       = newImage;
            }

            if ((string)cBFilters.SelectedItem == "Erosion")
            {
                AForge.Imaging.Filters.Erosion filter = new AForge.Imaging.Filters.Erosion();
                Bitmap newImage = filter.Apply(pictureTransform);
                pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                pBNew.Image       = newImage;
            }

            if ((string)cBFilters.SelectedItem == "Dilatation")
            {
                AForge.Imaging.Filters.Dilatation filter = new AForge.Imaging.Filters.Dilatation();
                Bitmap newImage = filter.Apply(pictureTransform);
                pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                pBNew.Image       = newImage;
            }

            if ((string)cBFilters.SelectedItem == "Edges")
            {
                AForge.Imaging.Filters.Edges filter = new AForge.Imaging.Filters.Edges();
                Bitmap newImage = filter.Apply(pictureTransform);
                pbChoose.SizeMode = PictureBoxSizeMode.CenterImage;
                pBNew.Image       = newImage;
            }
        }
コード例 #31
0
ファイル: PlateRecognizer.cs プロジェクト: andremn/SPS
        private Bitmap GetEdgedImage(WriteableBitmap writeableBitmap)
        {
            var edgeFilter = new CannyEdgeDetector(255, 0);
            var smoothFilter = new Median();
            var grayFilter = new Grayscale(0.2125, 0.7154, 0.0721);
            var bitmap = (Bitmap)writeableBitmap;

            bitmap = grayFilter.Apply(bitmap);
            smoothFilter.ApplyInPlace(bitmap);
            edgeFilter.ApplyInPlace(bitmap);

            return bitmap;
        }
コード例 #32
0
ファイル: Canvas.cs プロジェクト: ondister/Recog
 private void ToGrayScale()
 {
     Grayscale gf = new Grayscale(0.2125, 0.7154, 0.0721);
     _recogimg = gf.Apply(_recogimg);
 }
コード例 #33
0
 protected override void UpdateFilter()
 {
     filter = new Grayscale(Cr, Cg, Cb);
 }
コード例 #34
0
 public Bitmap ConvertTOGrayScale(double cr, double cg, double cb)
 {
     Grayscale grayScaleFilter = new Grayscale(cr, cg, cb);
     Bitmap convertedImage = grayScaleFilter.Apply(ImageBitmap);
     ImageBitmap = convertedImage;
     return convertedImage;
 }