Exemple #1
0
        // grad(i) = diliation(i)-erosion(i)
        public override Bitmap ProcessImage(Bitmap sourceImage, BackgroundWorker worker)
        {
            Bitmap resultImage = new Bitmap(sourceImage.Width, sourceImage.Height);
            Bitmap dil         = diliation.ProcessImage(sourceImage, worker);
            Bitmap eros        = erosion.ProcessImage(sourceImage, worker);

            for (int i = 0; i < sourceImage.Width; i++)
            {
                this.ReportProgress(i, sourceImage.Width, worker);
                if (worker.CancellationPending)
                {
                    return(null);
                }
                for (int j = 0; j < sourceImage.Height; j++)
                {
                    Color dilPixel  = dil.GetPixel(i, j);
                    Color erosPixel = eros.GetPixel(i, j);
                    int   r         = this.Clamp(dilPixel.R - erosPixel.R, 0, 255);
                    int   g         = this.Clamp(dilPixel.G - erosPixel.G, 0, 255);
                    int   b         = this.Clamp(dilPixel.B - erosPixel.B, 0, 255);
                    resultImage.SetPixel(i, j, Color.FromArgb(r, g, b));
                }
            }
            return(resultImage);
        }
Exemple #2
0
 public override Bitmap ProcessImage(Bitmap sourceImage, BackgroundWorker worker)
 {
     return(diliation.ProcessImage(erosion.ProcessImage(sourceImage, worker), worker));
 }