当前位置: 首页>>代码示例>>C#>>正文


C# BlobCounter.ProcessImage方法代码示例

本文整理汇总了C#中AForge.Imaging.BlobCounter.ProcessImage方法的典型用法代码示例。如果您正苦于以下问题:C# BlobCounter.ProcessImage方法的具体用法?C# BlobCounter.ProcessImage怎么用?C# BlobCounter.ProcessImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AForge.Imaging.BlobCounter的用法示例。


在下文中一共展示了BlobCounter.ProcessImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getBlobMaisAlto

        private Blob getBlobMaisAlto(String path)
        {
            try
            {
                Bitmap image = hslImage(path);

                // process image with blob counter
                BlobCounter blobCounter = new BlobCounter();
                blobCounter.ProcessImage(image);
                Blob[] blobs = blobCounter.GetObjectsInformation();

                Blob blobMaisAlto = blobs[0];

                // process each blob
                foreach (Blob blob in blobs)
                {
                    if (blob.CenterOfGravity.Y < blobMaisAlto.CenterOfGravity.Y)
                        blobMaisAlto = blob;
                }

                return blobMaisAlto;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:pablovin,项目名称:stardust,代码行数:27,代码来源:StarTrack.cs

示例2: TemplateColorTracking

        /// <summary>
        /// Get rectangle contain object in current frame
        /// </summary>
        /// <param name="templateInfo">Tracking template information</param>
        /// <param name="source">Frame</param>
        /// <returns>Rectangle contain object</returns>
        public static Rectangle TemplateColorTracking(ImageStatistics templateInfo, ref UnmanagedImage source)
        {
            UnmanagedImage image = source.Clone();
            // create filter
            EuclideanColorFiltering filter = new EuclideanColorFiltering();
            // set center colol and radius
            filter.CenterColor = new RGB(
                (byte)templateInfo.Red.Mean,
                (byte)templateInfo.Green.Mean,
                (byte)templateInfo.Blue.Mean);
            filter.Radius = 30;
            // apply the filter
            filter.ApplyInPlace(image);

            image = Grayscale.CommonAlgorithms.BT709.Apply(image);

            OtsuThreshold threshold = new OtsuThreshold();
            threshold.ApplyInPlace(image);

            BlobCounter blobCounter = new BlobCounter();
            blobCounter.ObjectsOrder = ObjectsOrder.Size;
            blobCounter.ProcessImage(image);

            Rectangle rect = blobCounter.ObjectsCount > 0 ? blobCounter.GetObjectsRectangles()[0] : Rectangle.Empty;
            return rect;
        }
开发者ID:pinkuyt,项目名称:a-pod-project-team-3,代码行数:32,代码来源:ObjectDetector.cs

示例3: calcDescriptorInfo

        public override void calcDescriptorInfo(Bitmap inImage)
        {
            shapeCount = new int[6];

            originalImage = image;
            image = imgProcessor.preProcessImage(inImage);

            g = Graphics.FromImage(originalImage);

            BlobCounter bCounter = new BlobCounter();
            bCounter.ProcessImage(image);
            Blob[] blobs = bCounter.GetObjectsInformation();

            SimpleShapeChecker shapeChecker = new SimpleShapeChecker();

            for (int i = 0; i < blobs.Length; i++)
            {
                if (blobs[i].Area < 100)
                {
                    continue;
                }
                List<IntPoint> edgePts = bCounter.GetBlobsEdgePoints(blobs[i]);
                checkShape(shapeChecker, edgePts);

            }

            g.Dispose();
        }
开发者ID:Buddhima,项目名称:MPEG7-FeatureExtractor,代码行数:28,代码来源:BlobHandler.cs

示例4: blob_setter

        public static void blob_setter(Bitmap video , Bitmap grayImage , int height , int width)
        {
            BlobCounter blobCounter = new BlobCounter();
            // configure it to filter out small objects
            blobCounter.MinWidth = width;
            blobCounter.MinHeight = height;
             //       blobCounter.FilterBlobs = true;
            // set ordering - bigger objects go first
            blobCounter.ObjectsOrder = ObjectsOrder.Size;
            // locate blobs
            blobCounter.ProcessImage(grayImage);
            Rectangle[] rects = blobCounter.GetObjectsRectangles();

            foreach (Rectangle recs in rects)
                if (rects.Length > 0)
                {
                    Rectangle objectRect = rects[0];
                    Graphics g = Graphics.FromImage(video);
                    using (Pen pen = new Pen(Color.FromArgb(160, 255, 160), 3))
                    {
                        g.DrawRectangle(pen, objectRect);
                    }
                    g.Dispose();
                }
        }
开发者ID:Rohail1,项目名称:OOP-Project,代码行数:25,代码来源:Blob+Detection.cs

示例5: FinalVideo_NewFrame

 void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs)
 {
     Icon newIcon = new Icon(@"c:\users\gregster\documents\visual studio 2012\Projects\WebCamTrack\WebCamTrack\bin\Debug\favicon.ico");
     BlobCounter bc = new BlobCounter();
     EuclideanColorFiltering filter = new EuclideanColorFiltering();
     Bitmap video = (Bitmap)eventArgs.Frame.Clone();//sem filtro
     Bitmap video1 = (Bitmap)eventArgs.Frame.Clone();// imagem com filtro
     //
     filter.CenterColor = new RGB(0, 0, 0);
     filter.Radius = 100;
     filter.ApplyInPlace(video1);//aplicando o filtro
     bc.MinWidth = 5;
     bc.MinHeight = 5;
     bc.FilterBlobs = true;
     //  bc.ObjectsOrder = ObjectsOrder.Size;
     bc.ProcessImage(video1);// processando a imagem que ja foi filtrada para identificar objetos
     Rectangle[] rects = bc.GetObjectsRectangles();
     foreach (Rectangle recs in rects)
         if (rects.Length > 0)
         {
             Rectangle objectRect = rects[0];
             Graphics g = Graphics.FromImage(video);//identificar objetos a partir da imagem com filtro
             Graphics h = Graphics.FromImage(video1);
             using (Pen pen = new Pen(Color.FromArgb(160, 255, 160), 5))
             {
                 g.DrawIcon(newIcon, objectRect);
                // g.DrawRectangle(pen, objectRect);
                 h.DrawRectangle(pen, objectRect);
             }
             g.Dispose();
             h.Dispose();
         }
     pictureBox1.Image = video;
     pictureBox2.Image = video1;
 }
开发者ID:GustavoGregorio,项目名称:Projetos-pessoais,代码行数:35,代码来源:Form1.cs

示例6: Execute

        public override void Execute(Bitmap Image)
        {
            BlobCounter blobCounter = new BlobCounter();
            blobCounter.MinHeight = 75;
            blobCounter.MinWidth = 75;
            blobCounter.CoupledSizeFiltering = true;
            blobCounter.ProcessImage(Image);
            Blob[] blobs = blobCounter.GetObjects(Image);
            int maxSize = 0;
            Blob maxObject = new Blob(0, new Rectangle(0, 0, 0, 0));
            // find biggest blob
            if (blobs != null)
            {
                foreach (Blob blob in blobs)
                {
                    int blobSize = blob.Rectangle.Width * blob.Rectangle.Height;

                    if (blobSize > maxSize)
                    {
                        maxSize = blobSize;
                        maxObject = blob;
                    }
                }
                if (maxSize > 100)
                {
                    if (Validity == ValidLocation.TRUE)
                    {
                        if (System.Math.Sqrt((CurrY - maxObject.Rectangle.Top) * (CurrY - maxObject.Rectangle.Top) + (CurrX - (maxObject.Rectangle.Left + maxObject.Rectangle.Right) / 2) * (CurrX - (maxObject.Rectangle.Left + maxObject.Rectangle.Right) / 2)) > 20)
                        {
                            Validity = ValidLocation.FALSE;
                            TargetFoundCycle = 0;
                            return;
                        }
                        else
                        {
                            TargetFoundCycle++;
                        }
                    }
                    CurrX = (maxObject.Rectangle.Left + maxObject.Rectangle.Right) / 2;
                    CurrY = maxObject.Rectangle.Top;
                    Validity = ValidLocation.TRUE;
                }
                else
                {
                    Validity = ValidLocation.FALSE;
                    TargetFoundCycle = 0;
                }
            }
            else
            {
                TargetFoundCycle = 0;
                Validity = ValidLocation.FALSE;
                return;
            }
        }
开发者ID:nakibli,项目名称:MouseCam,代码行数:55,代码来源:CState.cs

示例7: CropImage

        /// <summary>
        /// Celem metody jest przykadrowanie otrzymanego obrazka, tak aby widok zawierał jedynie kartkę papieru, oraz zwrócenie go do metody UploadFile
        /// </summary>
        /// <param name="img"></param>
        /// <returns></returns>
        public System.Drawing.Image CropImage(System.Drawing.Image img)
        {
            //DocumentSkewChecker skewChecker = new DocumentSkewChecker();
            //double angle = skewChecker.GetSkewAngle(image);
            //RotateBilinear rotationFilter = new RotateBilinear(-angle);
            //rotationFilter.FillColor = Color.White;
            //Bitmap rotatedImage = rotationFilter.Apply(image);

            Bitmap image = new Bitmap(img);

            UnmanagedImage grayImage = null;

            if (image.PixelFormat == PixelFormat.Format8bppIndexed)
            {
                grayImage = UnmanagedImage.FromManagedImage(image);
            }
            else
            {
                grayImage = UnmanagedImage.Create(image.Width, image.Height,
                    PixelFormat.Format8bppIndexed);
                Grayscale.CommonAlgorithms.BT709.Apply(UnmanagedImage.FromManagedImage(image), grayImage);
            }

            CannyEdgeDetector edgeDetector = new CannyEdgeDetector();
            UnmanagedImage edgesImage = edgeDetector.Apply(grayImage);

            OtsuThreshold thresholdFilter = new OtsuThreshold();
            thresholdFilter.ApplyInPlace(edgesImage);

            Dilatation DilatationFilter = new Dilatation();
            DilatationFilter.Apply(edgesImage);

            Opening OpeningFilter = new Opening();
            OpeningFilter.Apply(edgesImage);

            BlobCounter blobCounter = new BlobCounter();
            blobCounter.MinHeight = 32;
            blobCounter.MinWidth = 32;
            blobCounter.FilterBlobs = true;
            blobCounter.ObjectsOrder = ObjectsOrder.Size;

            blobCounter.ProcessImage(edgesImage);
            Blob[] blobs = blobCounter.GetObjectsInformation();

            ExtractBiggestBlob BiggestBlob = new ExtractBiggestBlob();
            Bitmap biggestBlobsImage = BiggestBlob.Apply(edgesImage.ToManagedImage());
            AForge.IntPoint BiggestBlogCorners = BiggestBlob.BlobPosition;

            Crop cropFilter = new Crop(new Rectangle(BiggestBlogCorners.X, BiggestBlogCorners.Y, biggestBlobsImage.Width, biggestBlobsImage.Height));
            Bitmap croppedImage = cropFilter.Apply(image);
            return croppedImage;
        }
开发者ID:BartekIL,项目名称:AutoCrop,代码行数:57,代码来源:Service.asmx.cs

示例8: Execute

 // 如果活动返回值,则从 CodeActivity<TResult>
 // 派生并从 Execute 方法返回该值。
 protected override void Execute(CodeActivityContext context)
 {
     // create an instance of blob counter algorithm
     BlobCounterBase bc = new BlobCounter();
     // set filtering options
     bc.FilterBlobs = true;
     bc.MinWidth = context.GetValue(最小宽度);
     bc.MinHeight = context.GetValue(最小高度);
     // set ordering options
     bc.ObjectsOrder = ObjectsOrder.Size;
     // process binary image
     bc.ProcessImage(context.GetValue(处理目标));
     var blobs = bc.GetObjectsInformation();
     context.SetValue(输出目标, blobs);
 }
开发者ID:manasheep,项目名称:Core3,代码行数:17,代码来源:从图像中分割图块.cs

示例9: Rectangle

        public static void Rectangle(WriteableBitmap bitmap, DrawingContext dc)
        {
            // locating objects
            BlobCounter blobCounter = new BlobCounter();
            blobCounter.FilterBlobs = true;
            blobCounter.MaxHeight = 375;
            blobCounter.MaxWidth = 375;
            System.Drawing.Bitmap image;
            using (var stream = new MemoryStream())
            {
                var encoder = new JpegBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(bitmap));
                encoder.Save(stream);
                image = new System.Drawing.Bitmap(stream);
            }
            blobCounter.ProcessImage(image);
            Blob[] blobs = blobCounter.GetObjectsInformation();

            // check for rectangles
            SimpleShapeChecker shapeChecker = new SimpleShapeChecker();

            foreach (var blob in blobs)
            {
                List<IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blob);
                List<IntPoint> cornerPoints;

                // use the shape checker to extract the corner points
                if (shapeChecker.IsQuadrilateral(edgePoints, out cornerPoints))
                {
                    // only do things if the corners form a rectangle
                    if (shapeChecker.CheckPolygonSubType(cornerPoints) == PolygonSubType.Rectangle)
                    {
                        // here i use the graphics class to draw an overlay, but you
                        // could also just use the cornerPoints list to calculate your
                        // x, y, width, height values.
                        List<AForge.Point> Points = new List<AForge.Point>();
                        foreach (var point in cornerPoints)
                        {
                            Points.Add(new AForge.Point(point.X, point.Y));
                        }
                        var path = new PathFigure(new System.Windows.Point(Points.First().X, Points.First().Y), Points.Select(row => new System.Windows.Media.LineSegment(new System.Windows.Point(row.X, row.Y), false)), true);

                        dc.DrawGeometry(Brushes.Red, null, new PathGeometry(new PathFigure[] { path }));
                    }
                }
            }
        }
开发者ID:virrkharia,项目名称:dynamight,代码行数:47,代码来源:ImageProc.cs

示例10: Apply

        public IEnumerable<Bitmap> Apply(Bitmap bitmap)
        {
            // assuming scanned background is white we need to invert for the algo to work
            var copy = new Invert().Apply(bitmap);

            copy = EnsureGrayscale(copy);
            new Threshold { ThresholdValue = 25 }.ApplyInPlace(copy);
            new FillHoles().ApplyInPlace(copy);

            var blobCounter = new BlobCounter
            {
                // set filtering options
                FilterBlobs = true,
                MinWidth = 50,
                MinHeight = 50,
            };

            blobCounter.ProcessImage(copy);
            var blobs = blobCounter.GetObjectsInformation();

            if (blobs.Any())
            {
                var invertedOriginal = new Invert().Apply(bitmap);
                foreach (var blob in blobs)
                {
                    // use inverted source to ensure correct edge colors
                    blobCounter.ExtractBlobsImage(invertedOriginal, blob, false);
                    var blobImage = blob.Image.ToManagedImage();

                    // straighten
                    var angle = new DocumentSkewChecker().GetSkewAngle(EnsureGrayscale(blobImage));
                    var rotationFilter = new RotateBilinear(-angle) { FillColor = Color.Black };
                    blobImage = rotationFilter.Apply(blobImage);

                    // crop
                    blobImage = new ExtractBiggestBlob().Apply(blobImage);

                    new Invert().ApplyInPlace(blobImage);
                    yield return blobImage;
                }
            }
            else
            {
                yield return bitmap;
            }
        }
开发者ID:x-skywalker,项目名称:Enhance,代码行数:46,代码来源:CropAndStraighten.cs

示例11: FindPlate

        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;
        }
开发者ID:andremn,项目名称:SPS,代码行数:46,代码来源:PlateRecognizer.cs

示例12: blobRecognition

        private static Blob[] blobRecognition(Bitmap thresholdedInverted)
        {
            //Use the AForge.NET BlobCounter to perform Blob Recognition / Connected Region Analysis
            BlobCounter blobRecognition = new BlobCounter();

            //Filter out blobs that are abviously the wrong size to be characters
            blobRecognition.MinWidth = (int)(thresholdedInverted.Width * (BLOB_FILTER_MIN_DIMENSION_IMAGE_PERCENTAGE / 100));
            blobRecognition.MinHeight = (int)(thresholdedInverted.Height * (BLOB_FILTER_MIN_DIMENSION_IMAGE_PERCENTAGE / 100));
            blobRecognition.MaxWidth = (int)(thresholdedInverted.Width * (BLOB_FILTER_MAX_DIMENSION_IMAGE_PERCENTAGE / 100));
            blobRecognition.MaxHeight = (int)(thresholdedInverted.Height * (BLOB_FILTER_MAX_DIMENSION_IMAGE_PERCENTAGE / 100));
            blobRecognition.FilterBlobs = true;

            blobRecognition.ProcessImage(thresholdedInverted);
            Blob[] blobs = blobRecognition.GetObjectsInformation();

            return blobs;
        }
开发者ID:JoshKeegan,项目名称:CVWS.NET,代码行数:17,代码来源:SegmentByBlobRecognition.cs

示例13: FindAny

        public static FoundBlobs FindAny(FoundColorSpaces colorSpaces)
        {
            FoundBlobs foundBlobs = new FoundBlobs();

            SobelEdgeDetector edge = new SobelEdgeDetector();
            Bitmap edges = edge.Apply(colorSpaces.GrayColorSpace);

            Threshold threshold = new Threshold(50);
            threshold.ApplyInPlace(edges);

            BlobCounter blobCounter = new BlobCounter();
            blobCounter.ProcessImage(edges);
            foundBlobs.Blobs = blobCounter.GetObjects(colorSpaces.GrayColorSpace, false).ToArray();

            foundBlobs.BlobCounter = blobCounter;

            return foundBlobs;
        }
开发者ID:kwende,项目名称:SetSpotter,代码行数:18,代码来源:BlobFinder.cs

示例14: DetectBlobs

        Blob[] DetectBlobs(Bitmap bmp)
        {
            Invert filter = new Invert();
            filter.ApplyInPlace(bmp);

            BlobCounter bc = new BlobCounter();
            bc.BackgroundThreshold = Color.FromArgb(8, 8, 8);

            bc.BlobsFilter = new BlobsFilter(bmp.Size);
            bc.FilterBlobs = true;

            bc.ProcessImage(bmp);

            // Revert back
            filter.ApplyInPlace(bmp);

            return bc.GetObjectsInformation();
        }
开发者ID:jazzlife,项目名称:pdf-ebook-reader,代码行数:18,代码来源:ConnectedBlobLayoutStrategy.cs

示例15: ExtractBlob

        public List<Blob> ExtractBlob()
        {
            // create instance of blob counter
            BlobCounter blobCounter = new BlobCounter();
            // process input image
            blobCounter.ProcessImage(ImageBitmap);
            
            // get information about detected objects   
            
            Blob[] blobArray = blobCounter.GetObjectsInformation();

            foreach(Blob blobdata in blobArray)
            {
                blobCounter.ExtractBlobsImage(ImageBitmap, blobdata, true);
            }
            
            return blobArray.ToList();
        }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:18,代码来源:ImageProcessor.cs


注:本文中的AForge.Imaging.BlobCounter.ProcessImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。