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


C# Image.AddWeighted方法代码示例

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


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

示例1: CreateImage

        public Image<Bgr, Byte> CreateImage(int[] radii, Bitmap shipsFile)
        {
            if (radii.Count() != 8)
                throw new ArgumentException();
            ;
            var source = new Image<Bgr, Byte>(shipsFile);

            int tileHeight = source.Height / (8 * 4); // 8 ships, 4 rows per ship
            int tileWidth = source.Width / 10; // 10 angles per row

            int max_radius = radii.Max()+1;

            var target = new Image<Bgr, Byte>(2*max_radius * 10, 2*max_radius * 8 * 4, new Bgr(Color.Black));

            for (int row_idx = 0; row_idx < 8 * 4; row_idx++)
            {
                int shipIndex = row_idx / 4;
                for (int col_idx = 0; col_idx < 10; col_idx++)
                {
                   Image<Bgr, Byte> subImage = source.GetSubRect(new Rectangle(new Point(col_idx * tileWidth, row_idx * tileHeight), new Size(tileWidth, tileHeight)));

                   target.ROI = new Rectangle(new Point(col_idx * (2 * max_radius) + (max_radius - tileWidth / 2), row_idx * (2 * max_radius) + (max_radius - tileHeight / 2)), new Size(subImage.Width, subImage.Height));

                   target.AddWeighted(subImage, 0, 1, 0).Copy(target, new Image<Gray, Byte>(target.Width, target.Height, new Gray(1)));

                   target.ROI = new Rectangle(new Point(col_idx * (2 * max_radius), row_idx * (2 * max_radius)), new Size(2*max_radius, 2*max_radius));

                   target.Draw(new Rectangle(new Point(max_radius - radii[shipIndex], max_radius - radii[shipIndex]), new Size(radii[shipIndex]*2, radii[shipIndex]*2)), new Bgr(Color.White), 1);

                   target.ROI = Rectangle.Empty;

                }

            }

            return target;
        }
开发者ID:HGuillen217,项目名称:ProxSquares,代码行数:37,代码来源:Program.cs

示例2: runningCamera

        private void runningCamera(object sender, EventArgs e)
        {
            imageFrameT = captureT.QueryFrame();
            
            if (imageFrameT != null)
            {
                
                if(facePosition != null){
                    if (showedStatus.Equals("..."))
                    {
                        Size dialogSize = new Size(300, 100);
                        Rectangle drawArea = new Rectangle(facePosition, dialogSize);
                        initialImage = imageFrameT.Copy();
                        Image<Bgr, Byte> opacityOverlay = new Image<Bgr, byte>(drawArea.Width, drawArea.Height, new Bgr(Color.Black));
                        initialImage.ROI = drawArea;
                        opacityOverlay.CopyTo(initialImage);
                        initialImage.ROI = System.Drawing.Rectangle.Empty;
                        double alpha = 0.8;
                        double beta = 1 - alpha;
                        double gamma = 0;
                        initialImage.Draw(drawArea, new Bgr(Color.LawnGreen), 2);
                        initialImage = imageFrameT.AddWeighted(initialImage, alpha, beta, gamma);

                    }
                }

                imageBox1.Image = initialImage;
            }
            
        }
开发者ID:pathom2000,项目名称:Face-Rcognition-with-Augmented-Reality,代码行数:30,代码来源:FormTrainx.cs

示例3: WearObject

        public Image<Bgra, byte> WearObject(Image<Bgra, byte> inputBgra, AccessoryOverlay accessory)
        {
            var bgraBlack = new Bgra(0, 0, 0, 0);

            if (accessory.FinalRectangle == Rectangle.Empty)
            {
                return inputBgra;
            }

            ConformRoi(accessory, inputBgra);

            var overlayRect = accessory.FinalRectangle;
            var resizeOverlayBgra = accessory.Overlay.Resize(overlayRect.Width, overlayRect.Height, Inter.Linear);

            var overlayTargetBgra = new Image<Bgra, byte>(inputBgra.Width, inputBgra.Height, bgraBlack);
            Log.Info(m => m("Overlay rect {0}", overlayRect));
            overlayTargetBgra.ROI = overlayRect;
            resizeOverlayBgra.CopyTo(overlayTargetBgra);
            overlayTargetBgra.ROI = Rectangle.Empty;

            const bool useMask = true;
            if (useMask)
            {
                var overlayMask = new Image<Gray, Byte>(inputBgra.Width, inputBgra.Height);
                CvInvoke.CvtColor(overlayTargetBgra, overlayMask, ColorConversion.Bgr2Gray);
                overlayMask = overlayMask.ThresholdBinary(new Gray(1), new Gray(1));
                inputBgra.SetValue(bgraBlack, overlayMask);
            }

            var outputBgra = inputBgra.AddWeighted(overlayTargetBgra, 1, 1, 1);

            inputBgra.ROI = Rectangle.Empty;
            outputBgra.ROI = Rectangle.Empty;

            return outputBgra;
        }
开发者ID:rflechner,项目名称:PiCamCV,代码行数:36,代码来源:FaceDetectionControl.cs

示例4: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            Stopwatch stopwatch = new Stopwatch();
            using (new MPI.Environment(ref args))
            {
                Intracommunicator comm = Communicator.world;

                try
                {
                    stopwatch.Start();

                    imgOriginal = new Image<Bgr, Byte>(".\\Humerus\\1.bmp");
                    imgGray = imgOriginal.Convert<Gray, Byte>();
                    imgGray = imgGray.AddWeighted(imgGray, 1.0, 0.0, 0.0);
                    imgGray = imgGray.ThresholdToZero(new Gray(100));
                    imgGray = imgGray.SmoothGaussian(9);
                    imgGray = imgGray.Canny(0, 80);
                    Lb_Rank.Text = comm.Rank.ToString();

                    heigh = imgGray.Height;
                    width = imgGray.Width;
                    bitmap = new Bitmap(imgGray.ToBitmap());
                    Bitmap New_Bitmap = new Bitmap(width, heigh / comm.Size);
                    count_pixel = 0;
                    int a = 0;
                    int b = 0;
                    int m = 0;
                    for (int i = (heigh / comm.Size) * comm.Rank; i < (heigh / comm.Size) * (comm.Rank+1); i++) // row, y
                    //for (int i = (heigh /2) * 1; i < (heigh / 2) * (1 + 1); i++) // row, y
                    {
                        for (int j = 0; j < width; j++)  // collumn, x
                        {
                            Console.Write("(" + i.ToString() + "," + j + "),");
                            a = (j + Start_Pixel_x);
                            b = (i + Start_Pixel_y);
                            Color pixel = bitmap.GetPixel(a, b);
                            if (pixel.R == 255 && pixel.G == 255 && pixel.B == 255) //RGB is white then count
                            {
                                count_pixel++;
                                bitmap.SetPixel(a, b, Vector_Color);    // color new vector with Red
                                New_Bitmap.SetPixel(j,m, Color.Red);
                                Find_Boundary_List(a, b, New_Bitmap, comm,m); // find boundary area
                            }
                        }
                        m++;

                    }

                    picTemp.Image = New_Bitmap;
                    Lb_Parallel_Line.Text = count_line_parallel.ToString();
                    if (count_line_parallel == 2)
                    {
                        Lb_Broken.ForeColor = Color.Blue;
                        Lb_Broken.Text = "Non Broken";
                    }
                    else
                    {
                        Lb_Broken.ForeColor = Color.Red;
                        Lb_Broken.Text = "Broken";
                    }

                    //////////////////////////////////////////////
                    stopwatch.Stop();
                    Lb_Time.Text = stopwatch.ElapsedMilliseconds.ToString();
                    Console.WriteLine("End rank " + comm.Rank.ToString() + " From1_load" + DateTime.Now +
                        " take time " + stopwatch.ElapsedMilliseconds.ToString() + "  milliseconds\n");
                    //Console.WriteLine("End rank 1"  + " From1_load" + DateTime.Now +
                    //    " take time " + stopwatch.ElapsedMilliseconds.ToString() + "  milliseconds\n");

                }
                catch (Exception ex)
                { MessageBox.Show(ex.Message.ToString()); }
            }
        }
开发者ID:RBChavez,项目名称:HumerusAnalysisParallelComputing,代码行数:74,代码来源:Form1.cs

示例5: StartDye

        public void StartDye(int X, int Y, int Heigh, int Width, Image<Gray, Byte> ImgGray, Communicator comm)
        {
            // Console.WriteLine("start StartDye");
            heigh = Heigh;
            width = Width;
            Start_Pixel_x = X;
            Start_Pixel_y = Y;
            imgGray = ImgGray;

            if (width <= 24) //elliminate noise 67,24
            { Flag = false; }
            else
            {
            //ArrayList Set_Pixel_In_Row = new ArrayList(); // Array for college
            imgGray = imgGray.AddWeighted(imgGray, 1.0, 0.0, 0.0);
            imgGray = imgGray.ThresholdToZero(new Gray(100));
            imgGray = imgGray.SmoothGaussian(9);
            imgGray = imgGray.Canny(0, 80);
            bitmap = new Bitmap(imgGray.ToBitmap());
            count_line_parallel = 0;
            //Initial_Dye_Pixel(comm);
            Flag = true;
            }
            //Console.WriteLine("end StartDye");
        }
开发者ID:RBChavez,项目名称:HumerusAnalysisParallelComputing,代码行数:25,代码来源:Form1.cs

示例6: LoadAndProcessImage

        public int LoadAndProcessImage(string FileName, Communicator comm)
        {
            int Vote = 0;
            imgOriginal = new Image<Bgr, Byte>(FileName);
            imgGray = imgOriginal.Convert<Gray, Byte>();
            //BitAnalysis.StartDye(0, 0, imgGray.Height, imgGray.Width, imgGray);

            hcHumerus = new HaarCascade(".\\haarHumerus_03112013_4.8_18.xml");
            ibImage.Image = imgBlank;

            acHumerus = hcHumerus.Detect(imgGray,
                        4.8,
                        18,
                        HAAR_DETECTION_TYPE.SCALE_IMAGE,
                        Size.Empty,
                        Size.Empty);
            acHumerus1 = hcHumerus.Detect(imgGray,
                                        4.8,
                                        18,
                                        HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                                        Size.Empty,
                                        Size.Empty);

            int count1 = 0, count2 = 0;
            foreach (MCvAvgComp acHum in acHumerus)
            {
                StartDye(acHum.rect.X, acHum.rect.Y, acHum.rect.Width, acHum.rect.Height, imgGray,comm);
                if (Flag)  // to get coordination x,y, and with, high
                {
                    imgOriginal.Draw(acHum.rect, new Bgr(Color.Blue), 2);
                    count1++;
                    Vote = 1;
                }
                imgGray.Draw(acHum.rect, new Gray(0.0), 1);
            }
            if (count1 ==0)
            {
                foreach (MCvAvgComp acHum1 in acHumerus1)
                {
                    StartDye(acHum1.rect.X, acHum1.rect.Y, acHum1.rect.Width, acHum1.rect.Height, imgGray,comm);
                    if (Flag)  // to get coordination x,y, and with, high
                    {
                        imgOriginal.Draw(acHum1.rect, new Bgr(Color.Red), 2);
                        count2++;
                        Vote = 1;
                    }
                    imgGray.Draw(acHum1.rect, new Gray(0.0), 1);
                }
            }
            if (count1 == 0 &&  count2 == 0 )
            {
                imgGray = imgGray.AddWeighted(imgGray, 1.0, 0.0, 0.0);
                imgGray = imgGray.ThresholdToZero(new Gray(100));
                imgGray = imgGray.SmoothGaussian(9);
                imgGray = imgGray.Canny(0, 80);

                hcHumerus = new HaarCascade(".\\HaarHumerus_03172013_2.8_3.xml");

                acHumerus = hcHumerus.Detect(imgGray,
                   2.8,
                   3,
                    HAAR_DETECTION_TYPE.SCALE_IMAGE,
                    Size.Empty,
                    Size.Empty);
                acHumerus1 = hcHumerus.Detect(imgGray,
                    2.8,
                    3,
                    HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                    Size.Empty,
                    Size.Empty);
                foreach (MCvAvgComp acHum in acHumerus)
                {
                    StartDye(acHum.rect.X, acHum.rect.Y, acHum.rect.Width, acHum.rect.Height, imgGray,comm);
                    if (Flag)  // to get coordination x,y, and with, high
                    {
                        imgOriginal.Draw(acHum.rect, new Bgr(Color.Orange), 2);
                        Vote = 1;
                    }
                    imgGray.Draw(acHum.rect, new Gray(0.0), 1);
                }
                foreach (MCvAvgComp acHum1 in acHumerus1)
                {
                    StartDye(acHum1.rect.X, acHum1.rect.Y, acHum1.rect.Width, acHum1.rect.Height, imgGray,comm);
                    if (Flag)  // to get coordination x,y, and with, high
                    {
                        imgOriginal.Draw(acHum1.rect, new Bgr(Color.Green), 2);
                        Vote = 1;
                    }
                    imgGray.Draw(acHum1.rect, new Gray(), 1);
                }

            }

            return Vote;
        }
开发者ID:RBChavez,项目名称:HumerusAnalysisParallelComputing,代码行数:95,代码来源:Form1.cs

示例7: LoadAndProcessImage

        public bool LoadAndProcessImage(string FileName)
        {
            bool Broken = false;
            imgOriginal = new Image<Bgr, Byte>(FileName);
            imgGray = imgOriginal.Convert<Gray, Byte>();
            //BitAnalysis.StartDye(0, 0, imgGray.Height, imgGray.Width, imgGray);

            hcHumerus = new HaarCascade(@"c:\haarHumerus_03112013_4.8_18.xml"); //haarHumerus_03112013_4.8_18
            ibImage.Image = imgBlank;

            acHumerus = hcHumerus.Detect(imgGray,
                        4.8,
                        18,
                        HAAR_DETECTION_TYPE.SCALE_IMAGE,
                        Size.Empty,
                        Size.Empty);
            acHumerus1 = hcHumerus.Detect(imgGray,
                                        4.8,
                                        18,
                                        HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                                        Size.Empty,
                                        Size.Empty);

            int count1 = 0, count2 = 0;
            PB.Value += 10;
            foreach (MCvAvgComp acHum in acHumerus)
            {
                if (GetCoordination(acHum))  // to get coordination x,y, and with, high
                {
                    imgOriginal.Draw(acHum.rect, new Bgr(Color.Blue), 2);
                    count1++;
                    Broken = true;
                }
                imgGray.Draw(acHum.rect, new Gray(0.0), 1);
            }
            PB.Value += 10;
            if (count1 == 0)
            {
                foreach (MCvAvgComp acHum1 in acHumerus1)
                {
                    if (GetCoordination(acHum1))  // to get coordination x,y, and with, high
                    {
                        imgOriginal.Draw(acHum1.rect, new Bgr(Color.Red), 2);
                        count2++;
                        Broken = true;
                    }
                    imgGray.Draw(acHum1.rect, new Gray(0.0), 1);
                }
            }
            if (count1 == 0  && count2 == 0 )
            {
                imgGray = imgGray.AddWeighted(imgGray, 1.0, 0.0, 0.0);
                imgGray = imgGray.ThresholdToZero(new Gray(100));
                imgGray = imgGray.SmoothGaussian(9);
                imgGray = imgGray.Canny(0, 80);

                hcHumerus = new HaarCascade(@"c:\HaarHumerus_03172013_2.8_3.xml");

                acHumerus = hcHumerus.Detect(imgGray,
                   2.8,
                   3,
                    HAAR_DETECTION_TYPE.SCALE_IMAGE,
                    Size.Empty,
                    Size.Empty);
                acHumerus1 = hcHumerus.Detect(imgGray,
                    2.8,
                    3,
                    HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                    Size.Empty,
                    Size.Empty);
                foreach (MCvAvgComp acHum in acHumerus)
                {
                    if (GetCoordination(acHum))  // to get coordination x,y, and with, high
                    {
                        imgOriginal.Draw(acHum.rect, new Bgr(Color.Orange), 2);
                        Broken = true;
                    }
                    imgGray.Draw(acHum.rect, new Gray(0.0), 1);
                }
                foreach (MCvAvgComp acHum1 in acHumerus1)
                {

                    if (GetCoordination(acHum1))  // to get coordination x,y, and with, high
                    {
                        imgOriginal.Draw(acHum1.rect, new Bgr(Color.Green), 2);
                        Broken = true;
                    }
                    imgGray.Draw(acHum1.rect, new Gray(), 1);
                }

            }
            PB.Value = +20;

            return Broken;
        }
开发者ID:RBChavez,项目名称:HumerusAnalysis,代码行数:95,代码来源:Form1.cs

示例8: StartDye

        public bool StartDye(int X, int Y, int Heigh, int Width, Image<Gray, Byte> ImgGray)
        {
            heigh = Heigh;
            width = Width;
            Start_Pixel_x = X;
            Start_Pixel_y = Y;
            imgGray = ImgGray;

            if (width <= 24) //elliminate noise 67,24
            { return false; }
            //ArrayList Set_Pixel_In_Row = new ArrayList(); // Array for college
            imgGray = imgGray.AddWeighted(imgGray, 1.0, 0.0, 0.0);
            imgGray = imgGray.ThresholdToZero(new Gray(100));
            imgGray = imgGray.SmoothGaussian(9);
            imgGray = imgGray.Canny(0, 80);
            bitmap = new Bitmap(imgGray.ToBitmap());
            Initial_Dye_Pixel(0);

            return Flag;
        }
开发者ID:RBChavez,项目名称:HumerusAnalysis,代码行数:20,代码来源:BitAnalysis_Parallism.cs

示例9: SensorAllFramesReady


//.........这里部分代码省略.........
                    Utilities.WriteDebugText(debugImg2, 10, 40, "{0:.00}m {1:0.00}m",
                        hand_x_dist, hand_y_dist);
                }

            }

            // DEMO 2: Painting
            else if (demo == 2 && skeleton != null &&
                colourImage != null && depthImage != null)
            {
                // create a player mask for player we want
                byte playerIndex = (byte)(Array.IndexOf(skeletons, skeleton) + 1);

                //double[] min, max;
                //Point[] pmin, pmax;
                //playerMasks.MinMax(out min, out max, out pmin, out pmax);

                // pick the player mask for the skeleton we're tracking
                Image<Gray, Byte> playerMask = playerMasks.Convert(delegate(Byte b)
                    { return (Byte)(b == playerIndex ? 255 : 0); });

                // register depth to Rgb using Emgu
                // compute homography if first frame
                if (depthToRGBHomography == null)
                    depthToRGBHomography = ComputeDepthToRGBHomography(
                        depthImage.Convert<Gray, byte>(), sensor);
                // do the registration warp
                Image<Gray, byte> registeredplayerMask = playerMask.WarpPerspective(
                    depthToRGBHomography, INTER.CV_INTER_CUBIC, WARP.CV_WARP_DEFAULT,
                    new Gray(0));

                // create the display image background
                // blended RGB and player mask
                displayImage = colourImage.AddWeighted(
                    registeredplayerMask.Resize(2, INTER.CV_INTER_NN).Convert<Bgr, byte>(),
                    0.7, 0.3, 0);

                // blur it out
                displayImage = displayImage.SmoothBlur(5, 5);

                // get body depth (in m)
                SkeletonPoint sposition = skeleton.Position;
                // get the left and right hand  positions (m)
                SkeletonPoint sleft = skeleton.Joints[JointType.HandLeft].Position;
                SkeletonPoint sright = skeleton.Joints[JointType.HandRight].Position;
                // head position
                SkeletonPoint shead = skeleton.Joints[JointType.Head].Position;

                // mask out depth except playermask
                Image<Gray, float> playerDepth = depthImage.Copy();
                playerDepth.SetValue(new Gray(0), playerMask.Not());

                // erase all interaction
                // - - - - - - - - - - - - -
                // raising both hands over head, when hands are close together, erases

                // get the distance between the hands
                double hand_distance = Utilities.Distance(sleft, sright);

                // if hands closer than 30cm and over head, then erase
                if (hand_distance < 0.3 && sleft.Y > shead.Y && sright.Y > shead.Y)
                {
                    paintingImage.SetZero();
                }

                // paint with hands interaction
开发者ID:nonsequitoria,项目名称:kinect_cv,代码行数:67,代码来源:MainWindow.xaml.cs


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