Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Im want to find deficit on the bottle,using C#-EmguCV ,need to know the steps of image-prepossessing && select the deficit to calculation its area ..

My Input image:
1.jpg - Google Drive[^]

The needed Result
Output image showing where is the defect done by Matlab After image-prepossessing
2.jpg - Google Drive[^]

What I have tried:

As the below code i trying first to :
1-Convert image BGR-to-GRAY
2-Binarization thresholding (Making the background black)
3-Erode -->For Now the Result as image: 3.PNG - Google Drive[^]
AS you see the defected still in the image ,and this wrong because i cant using Masking on the image ..

I dont know the steps/Or what i do after Erode how can i put circle around the deficit
4-After that Masking...?



C#
<pre>  Image<Bgr, byte> ImgInput;
        Image<Gray, byte> ImgGray;
        Image<Gray, byte> ImgBinariz;


        public Home()
        {
            InitializeComponent();
        }


        private void openToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog ofd = new OpenFileDialog();

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    ImgInput = new Image<Bgr, byte>(ofd.FileName);// 3 dimension
                    ImgGray = ImgInput.Convert<Gray, byte>();//Convert BGR-GRAY
                    pictureBox1.Image = ImgGray.Bitmap;

                    //Binarization  thresholding
                    ImgBinariz = new Image<Gray, byte>(ImgGray.Width, ImgGray.Height, new Gray(0));//binay imge with black background
                    // pictureBox1.Image = ImgBinariz.Bitmap; //Make all the image black
                    CvInvoke.Threshold(ImgGray, ImgBinariz, 50, 255, ThresholdType.Otsu);

                     pictureBox1.Image = ImgBinariz.Erode(5).Bitmap;
                    //pictureBox1.Image = ImgBinariz.Bitmap;

                }

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900