In C#, how do I generate a binary mask which has no gray values/noise in the image?
Right now I am able to generate a fairly simple output which looks very close to what I want but has noise around the edges both inside and outside of the white blob (You need to zoom all the way in to see the noise). I am planning to use the image later for image processing but cannot have anything other than black and white values in the image.
Code:
    public CropedImage(List<Node> nodes)
    {
        InitializeComponent();
        //List<PointF> listpoints = new List<PointF>();
        nodes.ToArray();
        PointF[] points = new PointF[nodes.Count];
        for(int i = 0; i < nodes.Count; ++i)
        {
            points[i].X = nodes[i].X;
            points[i].Y = nodes[i].Y;
        }
        Image SourceImage = ImageOperations.GetImage(MainForm.imageMatrix, pictureBox1);
        using (Graphics g = Graphics.FromImage(SourceImage))
        {
            Color black = ColorTranslator.FromHtml("#000000");
            Color white = ColorTranslator.FromHtml("#FFFFFF");
            using (Brush b = new SolidBrush(black))
            {
                Rectangle rect = new Rectangle();
                g.FillRectangle(b, 0, 0, MainForm.WIDTH, MainForm.HEIGHT);
            }
            using (Brush b2 = new SolidBrush(white))
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.FillClosedCurve(b2, points, 0);
            }
        }
    }