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


C# Image.Not方法代码示例

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


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

示例1: GetTheBestNoteExtraction

 public static Bitmap GetTheBestNoteExtraction(Bitmap bmp1, Bitmap bmp2)
 {
     lock (sync)
     {
         Image<Gray, byte> extraction_1 = new Image<Gray, byte>(bmp1);
         Image<Gray, byte> extraction_2 = new Image<Gray, byte>(bmp2);
         Image<Gray, byte> dif = extraction_1.AbsDiff(extraction_2);
         extraction_1 = extraction_1.Not();
         Gray sum_1 = extraction_1.GetSum();
         extraction_2 = extraction_2.Not();
         Gray sum_2 = extraction_2.GetSum();
         Gray sum_dif = dif.GetSum();
         Bitmap big = sum_1.Intensity >= sum_2.Intensity ? bmp1 : bmp2;
         Bitmap small = sum_1.Intensity < sum_2.Intensity ? bmp1 : bmp2;
         Gray bigSum = sum_1.Intensity >= sum_2.Intensity ? sum_1 : sum_2;
         Gray smallSum = sum_1.Intensity < sum_2.Intensity ? sum_1 : sum_2;
         if (smallSum.Intensity == 0)
         {
             return big;
         }
         else
         {
             if (sum_dif.Intensity / smallSum.Intensity > 0.3)
             {
                 return small;
             }
             else
             {
                 return big;
             }
         }
     }
 }
开发者ID:lekd,项目名称:XNAStickyNoteDetector,代码行数:33,代码来源:StickyNoteExtractor.cs

示例2: GetMoving

        public Image<Bgr, Byte> GetMoving(Image<Bgr, Byte> source)
        {
            //var sub = currentImage.AbsDiff(_prevImage).Convert<Gray, Byte>();
            var difference = MovingDetection(source).Convert<Gray, Byte>();
            _prevImage = source.Copy();
            difference = difference.ThresholdBinary(new Gray(50), new Gray(255));
            var distTransformed = new Image<Gray, float>(source.Width, source.Height);
            CvInvoke.cvDistTransform(difference.Ptr, distTransformed.Ptr, DIST_TYPE.CV_DIST_L2, 3, new[] { 1f, 1f }, IntPtr.Zero);
            var byteDist = distTransformed.ThresholdBinary(new Gray(2), new Gray(255)).Convert<Gray, byte>();

            Image<Gray, byte> mask = new Image<Gray, byte>(byteDist.Width + 2, byteDist.Height + 2);
            mask.ROI = new Rectangle(1, 1, byteDist.Width, byteDist.Height);
            CvInvoke.cvCopy(byteDist, mask, IntPtr.Zero);
            mask.ROI = new Rectangle(0, 0, byteDist.Width + 2, byteDist.Height + 2);
            mask = mask.Not();
            //return mask.Convert<Bgr, Byte>();

            var result = mask.Convert<Bgr, Byte>();

            for (int i = 0; i < difference.Width; i++)
            {
                for (int j = 0; j < difference.Height; j++)
                {
                    if (mask.Data[j, i, 0] == 0)
                    {
                        var comp = new MCvConnectedComp();
                        CvInvoke.cvFloodFill(
                            difference.Ptr,
                            new Point(i, j),
                            new MCvScalar(200, 200, 200, 0), // Color
                            new MCvScalar(0, 0, 0), // Lo
                            new MCvScalar(0, 0, 0),  // Up
                            out comp,
                            Emgu.CV.CvEnum.CONNECTIVITY.EIGHT_CONNECTED,
                            Emgu.CV.CvEnum.FLOODFILL_FLAG.DEFAULT,
                            mask.Ptr
                        );

                        if (comp.area > 500 && comp.area < 2500
                            && comp.rect.Size.Height > 10 && comp.rect.Size.Height < 230
                            && comp.rect.Size.Width > 10 && comp.rect.Size.Width < 230)
                        {
                            ReplaceColors(result, comp.rect);
                        }
                    }
                }
            }

            return result.Convert<Bgr, Byte>();
        }
开发者ID:floatdrop,项目名称:information-processing,代码行数:50,代码来源:MovingEventsDetector.cs

示例3: InvertColors

 public static Bitmap InvertColors(Bitmap srcimg)
 {
     using (Image<Gray, byte> img = new Image<Gray, byte>(srcimg))
     { return img.Not().ToBitmap(); }
 }
开发者ID:spatial-computing,项目名称:strabo-learning-ocr-transformation,代码行数:5,代码来源:ImageUtils.cs

示例4: MainLoop

        private void MainLoop()
        {
            CurrentFrame = Cam.QueryFrame().Convert<Hsv, byte>();
            Image<Gray, byte>[] channels;
            Image<Gray, byte> HistImg1 = new Image<Gray, byte>(500, 500);
            Image<Gray, byte> HistImg2 = new Image<Gray, byte>(500, 500);
            Image<Gray, byte> ProbImage;
            DenseHistogram hist1 = new DenseHistogram(new int[] { 10, 10 }, new RangeF[] { new RangeF(0, 255), new RangeF(0, 255) });
            DenseHistogram hist2 = new DenseHistogram(new int[] { 10, 10 }, new RangeF[] { new RangeF(0, 255), new RangeF(0, 255) });


            MCvConnectedComp comp;
            MCvTermCriteria criteria = new MCvTermCriteria(10, 1);
            MCvBox2D box;

            while (true)
            {
                    CurrentFrame = Cam.QueryFrame().Convert<Hsv, byte>();
                    if (OnSettingArea && TrackArea != Rectangle.Empty)
                    {
                        CurrentFrame.ROI = TrackArea;
                        channels = CurrentFrame.Split();
                        hist1.Calculate(new Image<Gray, byte>[] { channels[0], channels[1] }, false, null);
                        CurrentFrame.Not().CopyTo(CurrentFrame);

                        CurrentFrame.ROI = Rectangle.Empty;
                        CurrentFrame.Draw(TrackArea, new Hsv(100, 100, 100), 2);
                        imageBox1.Image = CurrentFrame;
                    }
                    else
                    {
                        if (TrackArea != Rectangle.Empty)
                        {      
                            channels = CurrentFrame.Split();
                            ProbImage = hist1.BackProject<byte>(new Image<Gray, byte>[] { channels[0], channels[1] });
                            imageBox_Hist2.Image = ProbImage.Convert<Gray, byte>();

                            lock (LockObject)
                            {
                                if (TrackArea.Height * TrackArea.Width > 0)
                                {
                                    CvInvoke.cvCamShift(ProbImage, TrackArea, criteria, out comp, out box);

                                    TrackArea = comp.rect;
                                    CurrentFrame.Draw(box, new Hsv(100, 100, 100), 2);
                                }
                                /**
                                ResetContourPoints();
                                for (int i = 0; i < 60; i++)
                                {
                                    ProbImage.Snake(ContourPoints, (float)1.0, (float)0.5, (float)1.5, new Size(17, 17), criteria, true);
                                }
                                CurrentFrame.DrawPolyline(ContourPoints, true, new Hsv(100, 100, 100), 2);
                                */
                            }
                        }
                        imageBox1.Image = CurrentFrame;
                        //calculate histogram;
                        //channels = CurrentFrame.Split();
                        //hist2.Calculate(new Image<Gray, byte>[] { channels[0], channels[1] }, false, null);
                        //hist2.Normalize(1);
                        //HistImg1.SetZero();
                        //DrawHist2D(HistImg1, hist1);
                        //imageBox_Hist1.Image = HistImg1;
                    }
            }
        }
开发者ID:jgmanz,项目名称:asial-arbeit,代码行数:67,代码来源:Form1.cs

示例5: TestSub

      public void TestSub()
      {
         Image<Bgr, Byte> img = new Image<Bgr, Byte>(101, 133);
         Image<Bgr, Byte> r1 = img.Not();
         Image<Bgr, Byte> r2 = 255 - img;
         EmguAssert.IsTrue(r1.Equals(r2));

         Image<Bgr, Byte> img2 = img - 10;
      }
开发者ID:neutmute,项目名称:emgucv,代码行数:9,代码来源:AutoTestImage.cs

示例6: TestInplaceNot

 public void TestInplaceNot()
 {
    if (CudaInvoke.HasCuda)
    {
       Image<Bgr, Byte> img = new Image<Bgr, byte>(300, 400);
       CudaImage<Bgr, Byte> gpuMat = new CudaImage<Bgr, byte>(img);
       CudaInvoke.BitwiseNot(gpuMat, gpuMat, null, null);
       Assert.IsTrue(gpuMat.Equals(new CudaImage<Bgr, Byte>(img.Not())));
    }
 }
开发者ID:Warren-GH,项目名称:emgucv,代码行数:10,代码来源:AutoTestCuda.cs

示例7: GetMovingEvents

        public List<Event> GetMovingEvents(Image<Bgr, Byte> source)
        {
            var events = new List<Event>();

            var difference = MovingDetection(source).Convert<Gray, Byte>();
            _prevImage = source.Copy();
            difference = difference.ThresholdBinary(new Gray(80), new Gray(255));
            var distTransformed = new Image<Gray, float>(source.Width, source.Height);
            CvInvoke.cvDistTransform(difference.Ptr, distTransformed.Ptr, DIST_TYPE.CV_DIST_L2, 3, new[] { 1f, 1f }, IntPtr.Zero);
            var byteDist = distTransformed.ThresholdBinary(new Gray(1), new Gray(255)).Convert<Gray, byte>();

            Image<Gray, byte> mask = new Image<Gray, byte>(byteDist.Width + 2, byteDist.Height + 2);
            mask.ROI = new Rectangle(1, 1, byteDist.Width, byteDist.Height);
            CvInvoke.cvCopy(byteDist, mask, IntPtr.Zero);
            mask.ROI = new Rectangle(0, 0, byteDist.Width + 2, byteDist.Height + 2);
            mask = mask.Not();
            //return mask.Convert<Bgr, Byte>();

            var result = difference.Convert<Bgr, Byte>();

            for (int i = 0; i < difference.Width; i++)
            {
                for (int j = 0; j < difference.Height; j++)
                {
                    if (mask.Data[j, i, 0] == 0)
                    {
                        var comp = new MCvConnectedComp();
                        CvInvoke.cvFloodFill(
                            difference.Ptr,
                            new Point(i, j),
                            new MCvScalar(200, 200, 200, 0), // Color
                            new MCvScalar(0, 0, 0), // Lo
                            new MCvScalar(0, 0, 0),  // Up
                            out comp,
                            Emgu.CV.CvEnum.CONNECTIVITY.EIGHT_CONNECTED,
                            Emgu.CV.CvEnum.FLOODFILL_FLAG.DEFAULT,
                            mask.Ptr
                        );

                        if (comp.area > 500 && comp.area < 2500
                            && comp.rect.Size.Height > 10 && comp.rect.Size.Height < 230
                            && comp.rect.Size.Width > 10 && comp.rect.Size.Width < 230
                            && BlobDetector.IsAreaColorMousable(comp, source, mask))
                        {
                            events.Add(new Event(comp.rect, Event.EventType.SomethingIsMoving));
                        }
                    }
                }
            }
            return events.Count > 3 ? new List<Event>() : events;
        }
开发者ID:floatdrop,项目名称:information-processing,代码行数:51,代码来源:MovingEventsDetector.cs

示例8: ProcessImage

        public Image<Bgr, byte> ProcessImage(Image<Bgr, byte> img)
        {
            //return ProcessImageHough(img);

            var inputImage = img.Clone();
            _bg.Update(img);
            img = _bg.BackgroundMask.Convert<Bgr, Byte>();
            _a.OnFrameUpdated(img);
            img = img.Erode(1);
            img = img.Dilate(1);
            _b.OnFrameUpdated(img);
            //img.SmoothBlur(3, 3);
            img = FillBlobs(img);
            //DrawBlobs(img);
            _c.OnFrameUpdated(img);

            //use image as mask to display original image
            var temp = inputImage.Sub(img);
            _d.OnFrameUpdated(temp);

            //float[] BlueHist = GetHistogramData(img[0]);

            //Image<Bgr, byte> image = new Image<Bgr, byte>(img.Width, img.Height);

            //for (int i = 0; i < BlueHist.Length; i++)
            //{
            //    image.Draw(new LineSegment2D(new Point(i, (int)BlueHist[i]), new Point(i, 0)), new Bgr(Color.Red), 1);
            //}

            //_e.OnFrameUpdated(image);

            //only display skin
            img = img.Not();
            //img = DetectSkin(img);
            //img = img.Erode(2);
            //img = img.Dilate(2);
            //img = img.Not();

            //DrawHoughLines(img);

            _e.OnFrameUpdated(ProcessImageLinearOptimization(img));
            //img.MorphologyEx()

            //List<Contour<Point>> allContours;
            //var contours = DetectBlobs(img.Convert<Gray, byte>(), out allContours);

            //Image<Bgr, byte> image = new Image<Bgr, byte>(img.Width, img.Height, new Bgr(Color.White));
            //if (allContours != null)
            //{

            //    foreach (Contour<Point> contour in allContours.Take(3))
            //    {
            //        var convexityDefact = contour.GetConvexityDefacts(new MemStorage(), Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);

            //        foreach (MCvConvexityDefect mCvConvexityDefect in convexityDefact)
            //        {
            //            PointF startPoint = new PointF(mCvConvexityDefect.StartPoint.X, mCvConvexityDefect.StartPoint.Y);
            //            CircleF startCircle = new CircleF(startPoint, 5f);
            //            image.Draw(startCircle, new Bgr(Color.Red), 5);
            //        }
            //        Draw(image, contour, false);
            //        //Draw(image, contour, true);
            //    }
            //}

            //_a.OnFrameUpdated(image);

            return img;
        }
开发者ID:HumanRemote,项目名称:HumanRemote,代码行数:69,代码来源:BackgroundSubtractProcessor.cs

示例9: TestSub

        public void TestSub()
        {
            Image<Bgr, Byte> img = new Image<Bgr, Byte>(101, 133);
             Assert.IsTrue(img.Not().Equals(255 - img));

             Image<Bgr, Byte> img2 = img - 10;
        }
开发者ID:samuto,项目名称:UnityOpenCV,代码行数:7,代码来源:AutoTestImage.cs


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