Finding largest blob in image
<p>I am having some issues extracting a blob from an image using EmguCV.  Everything I see online uses the Contours object, but I guess that was removed from EmguCV3.0?  I get an exception every time I try to use it.  I haven't found many recent/relevant SO topics that aren't out of date.</p>

<p>Basically, I have a picture of a leaf.  The background might be white, green, black, etc.  I want to essentially remove the background so that I can perform operations on the leaf without interference with the background.  I'm just not sure where I'm going wrong here:</p>

<p><a href="https://i.stack.imgur.com/rXoxE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rXoxE.jpg" alt="enter image description here"></a></p>

<pre><code>        Image&lt;Bgr, Byte&gt; Original = Core.CurrentLeaf.GetImageBGR;
        Image&lt;Gray, Byte&gt; imgBinary = Original.Convert&lt;Gray, Byte&gt;();
        imgBinary.PyrDown().PyrUp(); // Smoothen a little bit
        imgBinary = imgBinary.ThresholdBinaryInv(new Gray(100), new Gray(255)); // Apply inverse suppression

        // Now, copy pixels from original image that are black in the mask, to a new Mat.  Then scan?
        Image&lt;Gray, Byte&gt; imgMask;
        imgMask = imgBinary.Copy(imgBinary);
        CvInvoke.cvCopy(Original, imgMask, imgBinary);

        VectorOfVectorOfPoint contoursDetected = new VectorOfVectorOfPoint();
        CvInvoke.FindContours(imgBinary, contoursDetected, null, Emgu.CV.CvEnum.RetrType.List, Emgu.CV.CvEnum.ChainApproxMethod.ChainApproxSimple);

        var contoursArray = new List&lt;VectorOfPoint&gt;();
        int count = contoursDetected.Size;
        for (int i = 0; i &lt; count; i++)
        {
            using (VectorOfPoint currContour = contoursDetected[i])
            {
                contoursArray.Add(currContour);
            }
        }
</code></pre>

<p>With this, I get a black image with a tiny bit of white lines.  I've racked my brain back and forth and haven't been able to come up with something.  Any pointers would be much appreciated!</p>