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...?
<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);
ImgGray = ImgInput.Convert<Gray, byte>();
pictureBox1.Image = ImgGray.Bitmap;
ImgBinariz = new Image<Gray, byte>(ImgGray.Width, ImgGray.Height, new Gray(0));
CvInvoke.Threshold(ImgGray, ImgBinariz, 50, 255, ThresholdType.Otsu);
pictureBox1.Image = ImgBinariz.Erode(5).Bitmap;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}