Exemplo n.º 1
0
        public override Bitmap processImage(Bitmap image, BackgroundWorker worker)
        {
            MathMorfology er = new ErosionFilter(mask), dil = new DilationFilter(mask);

            er.setAllCols(3 * image.Width);
            Bitmap res = er.processImage(image, worker);

            dil.setAllCols(3 * image.Width);
            dil.setProcessedCols(image.Width);
            Bitmap res1 = dil.processImage(image, worker);

            ProcessedCols = 2 * image.Width;
            allCols       = 3 * image.Width;
            for (int i = 0; i < res.Width; i++)
            {
                worker.ReportProgress((int)((float)(i + ProcessedCols) * 100 / allCols));
                if (worker.CancellationPending)
                {
                    return(null);
                }
                for (int j = 0; j < res.Height; j++)
                {
                    int R = res1.GetPixel(i, j).R - res.GetPixel(i, j).R;
                    int G = res1.GetPixel(i, j).G - res.GetPixel(i, j).G;
                    int B = res1.GetPixel(i, j).B - res.GetPixel(i, j).B;
                    res.SetPixel(i, j, Color.FromArgb(Clamb(R, 0, 255), Clamb(G, 0, 255), Clamb(B, 0, 255)));
                }
            }
            return(res);
        }
Exemplo n.º 2
0
        public override Bitmap processImage(Bitmap image, BackgroundWorker worker)
        {
            MathMorfology er = new ErosionFilter(mask), dil = new DilationFilter(mask);

            dil.setAllCols(2 * image.Width);
            er.setAllCols(2 * image.Width);
            er.setProcessedCols(image.Width);
            Bitmap res = dil.processImage(image, worker);

            res = er.processImage(res, worker);
            return(res);
        }