I want to use watershed function provided by emgucv.I used the following code but all I get is a white picture.Please help me and correct this code.Thanks.
Image im;
Bitmap bm;
Bitmap bmF;
private void button1_Click(object sender, EventArgs e)//setting the background image
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
im = Image.FromFile(openFileDialog1.FileName);
bm = new Bitmap(im);
}
panel1.BackgroundImage = im;
panel1.Width = im.Width;
panel1.Height = im.Height;
panel1.Visible = true;
}
private void button2_Click(object sender, EventArgs e)
{
watershed(bm);
}
private void watershed(Bitmap bm)
{
Image<Bgr, Byte> imWa = new Image<Bgr, byte>(bm);
Image<Gray, Int32> imgr = new Image<Gray, int>(imWa.Width, imWa.Height);
Rectangle rec = imWa.ROI;
imgr.Draw(new CircleF(new PointF(rec.Left + rec.Width / 2.0f, rec.Top + rec.Height / 2.0f), (float)(Math.Min(imWa.Width, imWa.Height) / 4.0f)), new Gray(255), 0);
CvInvoke.cvWatershed(imWa, imgr);
bmF=new Bitmap(bm.Width,bm.Height);
bmF= imgr.ToBitmap();
panel1.BackgroundImage = (Image)bmF;
panel1.Invalidate();
}