How to extract identified inner and outer contours using EmguCV?

Viewed 877

I'm doing a project to process brain injuries using Image Processing. In order to improve its accuracy, I need to extract only the brain matter from the skull.

Using EmguCV I was able to identify the inner and outer contours (Blue and Dark blue). Is there anyway to extract these identified contours into another image?

Image<Gray, byte> grayImage = new Image<Gray, byte>(bitmap);
Image<Bgr, byte> color = new Image<Bgr, byte>(bitmap);

grayImage = grayImage.ThresholdBinary(new Gray(220), new Gray(255));

using (MemStorage storage = new MemStorage())
{
    for (Contour<Point> contours = grayImage.FindContours(
        Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_TREE, storage); contours != null; contours = contours.HNext)
    {
        Contour<Point> currentContour = contours.ApproxPoly(contours.Perimeter * 0.015, storage);
        if (currentContour.BoundingRectangle.Width > 20)
        {
            CvInvoke.cvDrawContours(color, contours, new MCvScalar(100), new MCvScalar(255), -1, 2, Emgu.CV.CvEnum.LINE_TYPE.EIGHT_CONNECTED, new Point(0, 0));
        }
    }
}

EmguCV 2.2.2

Identified Contours

Expected output:

Expected Output

0 Answers
Related