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


C# Image.ThresholdToZero方法代码示例

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


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

示例1: ConvertImageButton_Click

        private void ConvertImageButton_Click(object sender, RoutedEventArgs e)
        {
            if (bmp != null)
            {
                img = new Image<Bgr, byte>(bmp);

                // Split the image into the 3 channels (R, G, B)
                Image<Gray, Byte>[] splitImg = img.Split();

                // We want the blue channel as this make the text closer to white
                singleChannelImage = splitImg[2];

                // Now we are going to run a binary threshold to try and remove the background
                // The threshold is set high at the moment to remove as much guff as possible
                try
                {
                    int thresholdString = int.Parse(ThresholdValue.Text);
                    Gray grayThreshold = new Gray(thresholdString);

                    processedImage = singleChannelImage.ThresholdToZero(grayThreshold).Not();

                    // Load the bitmap into a BitmapSource for the image controll to display it
                    BitmapSource bmpSource = Utils.BitmapToBitmapSource(processedImage.ToBitmap());

                    // Update the image display to show the processed image
                    DisplayImage.Source = bmpSource;

                }
                catch (Exception exception)
                {
                    if (exception is FormatException || exception is ArgumentNullException)
                    {
                        MessageBox.Show("Error: Exception caught: " + exception.Message);
                    }
                }
            }
            else
            {
                MessageBox.Show("Error: Image has not been loaded", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
开发者ID:codersparks,项目名称:OpenCV_Tesseract_Test,代码行数:41,代码来源:MainWindow.xaml.cs

示例2: Prepare

 /// <summary>
 /// Prepare Image Method
 /// </summary>
 /// <param name="image">Image to prepare</param>
 /// <returns>Prepared Image</returns>
 public Image<Gray, byte> Prepare(Image<Gray, byte> image)
 {
     image = image.ThresholdToZero(new Gray(GrayThreshold));
     image._EqualizeHist();
     return image;
 }
开发者ID:djjosse,项目名称:Foosbot,代码行数:11,代码来源:ImagePreProcessor.cs

示例3: 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

示例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: 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

示例6: start

        public int start(Communicator comm)
        {
            int Vote = 0;

            try
            {
                Vote = LoadAndProcessImage(".\\Humerus\\1.bmp",comm);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

            }

            ibImage.SizeMode = PictureBoxSizeMode.Zoom;
            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);

            return Vote;
        }
开发者ID:RBChavez,项目名称:HumerusAnalysisParallelComputing,代码行数:23,代码来源: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: Bt_Find_Click

        private void Bt_Find_Click(object sender, EventArgs e)
        {
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            PB.Visible = true;
            bool Broken = false;
            PB.Value += 10;
            if (txtImageFile.Text != "")
            {
                try
                {
                    PB.Value += 20;
                    Bt_Find.Enabled = false;
                    Broken = LoadAndProcessImage(txtImageFile.Text);
                    Bt_Find.Enabled = true;
                    PB.Value += 20;
                }
                catch (Exception ex)
                {
                    Bt_Find.Enabled = true;
                    MessageBox.Show(ex.Message);
                    PB.Value = 0;
                    PB.Visible = false;

                }
                PB.Value += 10;
                if (Broken)
                {
                    Lb_Broken.ForeColor = Color.Red;
                    Lb_Broken.Text = "Broken";
                }
                else
                {
                    Lb_Broken.ForeColor = Color.Blue;
                    Lb_Broken.Text = "non Broken";
                }

                ibImage.SizeMode = PictureBoxSizeMode.Zoom;
                ibImage.Image = imgOriginal;
                imageBox1.SizeMode = PictureBoxSizeMode.Zoom;
                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);
                imageBox1.Image = imgGray;
                Lb_Progress.Text = "Succeed!";
                PB.Value = 0;
                PB.Visible = false;
            }
            else
            {
                MessageBox.Show("Image file name is empty!");
                PB.Value = 0;
                PB.Visible = false;
            }
            stopwatch.Stop();
            Lb_Time.Text = stopwatch.ElapsedMilliseconds.ToString() + "  milliseconds";
        }
开发者ID:RBChavez,项目名称:HumerusAnalysis,代码行数:58,代码来源:Form1.cs

示例9: 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

示例10: TestMoment

 public void TestMoment()
 {
    Image<Gray, byte> image = new Image<Gray, byte>(100, 200);
    image.SetRandUniform(new MCvScalar(), new MCvScalar(255));
    image.ThresholdToZero(new Gray(120));
    MCvMoments moment = image.GetMoments(true);
    double[] huMoment = moment.GetHuMoment();
 }
开发者ID:neutmute,项目名称:emgucv,代码行数:8,代码来源:AutoTestImage.cs

示例11: Prepare

 /// <summary>
 /// Prepare image for motion detection of WHITE ball
 /// </summary>
 /// <param name="image">Current image to prepare</param>
 /// <returns>Prepared Image</returns>
 public Image<Gray, byte> Prepare(Image<Gray, byte> image)
 {
     image = image.ThresholdToZero(new Gray(GrayThreshold));
     image._Dilate(1);
     return image;
 }
开发者ID:djjosse,项目名称:Foosbot,代码行数:11,代码来源:MotionDetector.cs


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