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


C# Bgr类代码示例

本文整理汇总了C#中Bgr的典型用法代码示例。如果您正苦于以下问题:C# Bgr类的具体用法?C# Bgr怎么用?C# Bgr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ProcessImage

    public virtual void ProcessImage(Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte> image) {
      Emgu.CV.Image<Gray, byte> gray = image.Convert<Gray, byte>();
      gray._ThresholdBinary(new Gray(_threshold), new Gray(255.0));
      gray._Not();

      Parsley.Core.EllipseDetector ed = new Parsley.Core.EllipseDetector();
      ed.MinimumContourCount = _min_contour_count;

      List < Parsley.Core.DetectedEllipse > ellipses = 
        new List<Parsley.Core.DetectedEllipse>(ed.DetectEllipses(gray));

      List < Parsley.Core.DetectedEllipse > finals = 
        new List<Parsley.Core.DetectedEllipse>(
          ellipses.Where(e => { return e.Rating < _distance_threshold; })
        );

      finals.Sort(
        (a, b) => {
          double dista = a.Ellipse.MCvBox2D.center.X * a.Ellipse.MCvBox2D.center.X + a.Ellipse.MCvBox2D.center.Y * a.Ellipse.MCvBox2D.center.Y;
          double distb = b.Ellipse.MCvBox2D.center.X * b.Ellipse.MCvBox2D.center.X + b.Ellipse.MCvBox2D.center.Y * b.Ellipse.MCvBox2D.center.Y;
          return dista.CompareTo(distb);
        }
      );

      Bgr bgr = new Bgr(0, 255, 0);
      MCvFont f = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_PLAIN, 0.8, 0.8);
      int count = 1;
      foreach (Parsley.Core.DetectedEllipse e in finals) {
        image.Draw(e.Ellipse, bgr, 2);
        image.Draw(count.ToString(), ref f, new System.Drawing.Point((int)e.Ellipse.MCvBox2D.center.X, (int)e.Ellipse.MCvBox2D.center.Y), bgr);
        count++;
      }
    }
开发者ID:sivarajankumar,项目名称:dentalsmile,代码行数:33,代码来源:EllipseDetection.cs

示例2: Superpixels

        private double s = 0; // Superpixel Intervall Int

        #endregion Fields

        #region Constructors

        // =============== Konstruktor ===============
        public Superpixels(Image<Bgr, Byte> imageBgr, int superpixelCount)
        {
            // Werte setzen
            k = superpixelCount;
            n = imageBgr.Width * imageBgr.Height;
            s = Math.Sqrt((double)n / (double)k);
            area = Convert.ToInt32(2 * s * 2 * s);
            m = 12;

            // BGR to LAB Umrechnung und Vektormatrix erstellen
            imageLab = imageBgr.Convert<Lab, Byte>();
            pixels = new Pixel[imageBgr.Width, imageBgr.Height];
            for (int r = 0; r < imageLab.Height; r++)
            {
                for (int c = 0; c < imageLab.Width; c++)
                {
                    double l = (double)imageLab.Data[r, c, 0] * 100 / 255;
                    double a = (double)imageLab.Data[r, c, 1] - 128;
                    double b = (double)imageLab.Data[r, c, 2] - 128;

                    Bgr bgr = new Bgr(imageBgr.Data[r, c, 0], imageBgr.Data[r, c, 1], imageBgr.Data[r, c, 2]);

                    pixels[c, r] = new Pixel(new Vector5(l, a, b, c, r), bgr);

                    //Console.WriteLine("BGR = " + imageBgr.Data[r, c, 0] + " " + imageBgr.Data[r, c, 1] + " " + imageBgr.Data[r, c, 2]);
                    //Console.WriteLine("RGB = " + imageBgr.Data[r, c, 2] + " " + imageBgr.Data[r, c, 1] + " " + imageBgr.Data[r, c, 0]);
                    //Console.WriteLine("LAB = " + labValues[r, c].X + " " + labValues[r, c].Y + " " + labValues[r, c].Z);
                }
            }
        }
开发者ID:Thomas214,项目名称:MA-Code,代码行数:37,代码来源:Superpixels.cs

示例3: Rotate

 // rotation, theta is in degree
 public void Rotate(double theta,Bgr color)
 {
     Mat Tmat = new Mat();
     // CvInvoke considers rotation differently to Emgu CV image wrapper, theta is actually -theta
     CvInvoke.GetRotationMatrix2D(new PointF(matImage.Width / 2, matImage.Height / 2), -theta, 1,Tmat);
     CvInvoke.WarpAffine(matImage, destImage, Tmat, new Size(matImage.Width, matImage.Height),borderValue:new MCvScalar(color.Blue,color.Green,color.Red));
 }
开发者ID:gw-sd-2016,项目名称:TornRepair,代码行数:8,代码来源:MatImage.cs

示例4: Convert

 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (!String.IsNullOrWhiteSpace(parameter.ToString()))
     {
         var brush = (SolidColorBrush)value;
         var color = new Bgr(brush.Color.B,brush.Color.G,brush.Color.R);
         buffer.SetValue(color);
         var data = buffer.Convert<Hsv,byte>().Data;
         string param = parameter.ToString();
         switch(param){
             case "h":
             case "H":
                 return data[0, 0, 0];
             case "s":
             case "S":
                 return data[0, 0, 1];
             case "v":
             case "V":
                 return data[0, 0, 2];
             default:
                 break;
         }
     }
     throw new ArgumentException("Wrong Parameter. It can be only one from H,h,S,s,V,v.");
 }
开发者ID:DormantDreams,项目名称:video-game-level-scanner,代码行数:25,代码来源:SolidColorBrushToHsvConverter.cs

示例5: Main

        static void Main(string[] args)
        {
            //select color
            Bgr<byte>[,] image = new Bgr<byte>[480, 640];
            Hsv<byte> color = UI.PickColor(Bgr<byte>.Red).ToHsv();

            //select mask
            Gray<byte>[,] mask = image.GetMask();
            if (mask.AsEnumerable().Sum(x => x.Intensity) == 0) //if the mask is empty
                mask.SetValue<Gray<byte>>(Byte.MaxValue);

            //increase saturation incrementally
            for (int s = 0; s <= Byte.MaxValue; s++)
            {
                color.S = (byte)s;
                image.SetValue<Bgr<byte>>(color.ToBgr(), mask);

                image.Show(scaleForm: true);
                ((double)s / Byte.MaxValue).Progress(message: "Changing saturation");

                Thread.Sleep(50);
            }

            //save last image
            string fileName = UI.SaveImage();
            if (fileName != null) image.Save(fileName);

            //close all
            UI.CloseAll();
        }
开发者ID:gitter-badger,项目名称:dot-imaging,代码行数:30,代码来源:Program.cs

示例6: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            if (openImageFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Bgr drawColor = new Bgr(Color.Blue);
                try
                {
                    Image<Bgr, Byte> image = new Image<Bgr, byte>(openImageFileDialog.FileName);
                    original.Image = image.ToBitmap();
                    original.SizeMode = PictureBoxSizeMode.Zoom;
                    using (Image<Gray, byte> gray = image.Convert<Gray, Byte>())
                    {
                        _ocr.Recognize(gray);
                        Tesseract.Charactor[] charactors = _ocr.GetCharactors();
                        foreach (Tesseract.Charactor c in charactors)
                        {
                            image.Draw(c.Region, drawColor, 1);
                        }

                        processed.Image = image.ToBitmap();
                        processed.SizeMode = PictureBoxSizeMode.Zoom;
                        //String text = String.Concat( Array.ConvertAll(charactors, delegate(Tesseract.Charactor t) { return t.Text; }) );
                        String text = _ocr.GetText();
                        ocrTextBox.Text = text;
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }

        }
开发者ID:mehulsbhatt,项目名称:ocrrefinement,代码行数:33,代码来源:Form1.cs

示例7: VShape

        public VShape(Point[] shape, Bgr newID)
        {
            _shape = shape;
            _isSquare = false;
            _isTriangle = false;

            health = 10;
            ID = newID;


            int len = _shape.Length;
            sides = new double[len];

            for (int i = 0; i < len - 1; i++)
            {
                sides[i] = Distance(_shape[i], _shape[i + 1]);
            }
            sides[len - 1] = Distance(_shape[len - 1], _shape[0]);

            scale = Math.Round(FindScale(), 2);

            if (IsRegular() && IsEquilateral())
            {
                if (_shape.Length == 3)
                    _isTriangle = true;
                else if (_shape.Length == 4)
                    _isSquare = true;
            }
        }
开发者ID:UR3-Victoria,项目名称:Armscode,代码行数:29,代码来源:VShape.cs

示例8: DrawContours

        public static Image<Bgr, Byte> DrawContours(Image<Gray, Byte> image)
        {
            double something = 30;
            List<VectorOfPoint> convertedContours = GetContours(image, ChainApproxMethod.ChainApproxSimple, RetrType.List, 0.001, something);

            Image<Bgr, Byte> result = new Image<Bgr, Byte>(image.Width, image.Height, new Bgr(0, 0, 0));

            int counter = 1;
            Random randomGen = new Random();
            KnownColor[] names = (KnownColor[])Enum.GetValues(typeof(KnownColor));

            foreach (VectorOfPoint points in convertedContours)
            {
                KnownColor randomColorName = names[randomGen.Next(names.Length)];
                Color randomColor = Color.FromKnownColor(randomColorName);
                Bgr color = new Bgr(randomColor);

                var temp = points.ToArray();
                result.Draw(temp, color, 2);

                counter++;
            }

            return result;
        }
开发者ID:BrettHewitt,项目名称:MWA,代码行数:25,代码来源:ImageExtension.cs

示例9: ClassifyColor

 private CardColor ClassifyColor(Bgr avgBgr, Hsv avgHsv)
 {
     if (avgHsv.Satuation < 30)
     {
         return CardColor.White;
     }
     else if (avgHsv.Satuation < 45)
     {
         return CardColor.Other;
     }
     else if (avgBgr.Red > avgBgr.Blue && avgBgr.Red > avgBgr.Green)
     {
         return CardColor.Red;
     }
     else if (avgBgr.Green > avgBgr.Blue && avgBgr.Green > avgBgr.Red)
     {
         return CardColor.Green;
     }
     else if (avgBgr.Green < avgBgr.Blue && avgBgr.Green < avgBgr.Red)
     {
         return CardColor.Purple;
     }
     else
     {
         return CardColor.White;
     }
 }
开发者ID:LoyVanBeek,项目名称:SetVision,代码行数:27,代码来源:ShapeContour.cs

示例10: Filter

 public Filter()
 {
     _name = "";
     _minCount = int.MaxValue;
     _minBgr = new Bgr(0, 0, 0);
     _maxBgr = new Bgr(255, 255, 255);
 }
开发者ID:JonasVanGool,项目名称:ColorSortingMachine,代码行数:7,代码来源:Filter.cs

示例11: ClassifyTest

 public void ClassifyTest()
 {
     BgrClassifier target = new BgrClassifier();
     Bgr value = new Bgr(145, 110, 197); //Purple
     CardColor actual = target.Classify(value);
     Assert.AreEqual(CardColor.Purple, actual);
 }
开发者ID:LoyVanBeek,项目名称:SetVision,代码行数:7,代码来源:BgrClassifierTest.cs

示例12: ProcessHoughTest

        private HoughResult ProcessHoughTest(Image<Bgr, byte> image)
        {
            const int leftMargin = 0;
            const int upMargin = 300;
            const int downMargin = 200;
            var size = image.Size;

            image.ROI = new Rectangle(leftMargin, upMargin, size.Width - leftMargin * 2,
                size.Height - upMargin - downMargin);

            HoughLines.PreprocessImage(image);

            var result = HoughLines.Compute(image);
            lineCache_.AddResult(result);
            result = lineCache_.GetCachedResult();

            result.MoveRoiResult(leftMargin, upMargin);
            image.ROI = Rectangle.Empty;
            var red = new Bgr(Color.Red);
            foreach (var line in result.SolidLines)
            {
                image.Draw(line, red, 3);
            }
            return result;
        }
开发者ID:zyh329,项目名称:adas,代码行数:25,代码来源:VideoForm.cs

示例13: Main

        static void Main(string[] args)
        {
            UI.OpenImage();

            Bgr<byte>[,] image = new Bgr<byte>[480, 640];
            Hsv<byte> color = UI.PickColor(Bgr<byte>.Red).ToHsv();

            for (int s = 0; s <= Byte.MaxValue; s++)
            {
                color.S = (byte)s;
                image.SetValue<Bgr<byte>>(color.ToBgr());

                image.Show(scaleForm: true);
                ((double)s / Byte.MaxValue).Progress(message: "Changing saturation");

                Thread.Sleep(50);
            }

            //save last image
            string fileName = UI.SaveImage();
            if (fileName != null) image.Save(fileName);

            //close all
            UI.CloseAll();
        }
开发者ID:bestwpw,项目名称:dot-imaging,代码行数:25,代码来源:Program.cs

示例14: rotatePhotos

        private void rotatePhotos(object parameters)
        {
            object[] paramsArray = (object[])parameters;
            List<string> fileNames = (List<string>)paramsArray[0];
            PointF rotationCenter = (PointF)paramsArray[1];
            Bitmap referencePic = new Bitmap(fileNames.First());
            Image<Bgr, Byte> referenceImage = new Image<Bgr, Byte>(referencePic);

            byte[] timeTakenRaw = referencePic.GetPropertyItem(36867).Value;
            string timeTaken = System.Text.Encoding.ASCII.GetString(timeTakenRaw, 0, timeTakenRaw.Length - 1);
            DateTime referenceTime = DateTime.ParseExact(timeTaken, "yyyy:MM:d H:m:s", System.Globalization.CultureInfo.InvariantCulture);

            referencePic.Dispose();

            Bgr background = new Bgr(0, 0, 0);

            foreach (string filename in fileNames)
            {
                Bitmap currentPic = new Bitmap(filename);
                timeTakenRaw = currentPic.GetPropertyItem(36867).Value;
                timeTaken = System.Text.Encoding.ASCII.GetString(timeTakenRaw, 0, timeTakenRaw.Length - 1);
                DateTime date = DateTime.ParseExact(timeTaken, "yyyy:MM:d H:m:s", System.Globalization.CultureInfo.InvariantCulture);
                double secondsShift = (date - referenceTime).TotalSeconds;
                double rotationAngle = secondsShift / stellarDay * 360;
                RotationMatrix2D<double> rotationMatrix = new RotationMatrix2D<double>(rotationCenter, -rotationAngle, 1);

                using (Image<Bgr, Byte> rotatedImage = new Image<Bgr, Byte>(currentPic))
                {
                    referenceImage = referenceImage.Max(rotatedImage.WarpAffine<double>(rotationMatrix, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC, Emgu.CV.CvEnum.WARP.CV_WARP_FILL_OUTLIERS, background));
                }
                pictureProcessed(this, new PictureProcessedEventArgs(referenceImage));
                currentPic.Dispose();
            }
            pictureProcessingComplete(this, new EventArgs());
        }
开发者ID:jorik041,项目名称:StarStacker,代码行数:35,代码来源:ThreadWorker.cs

示例15: ImageFinder

 public ImageFinder()
 {
     rectangles = new List<Rectangle>();
     stopwatch = new Stopwatch();
     Threshold = 0.85;
     fillColor = new Bgr(Color.Magenta);
 }
开发者ID:AlbinoDrought,项目名称:LoveBoot,代码行数:7,代码来源:ImageFinder.cs


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