Esempio n. 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="rOriginal"></param>
        /// <returns></returns>
        public override Raster ProcessWithoutWorker(Raster rOriginal)
        {
            int width = rOriginal.Width;
            int height = rOriginal.Height;
            Raster raster = new Raster(width, height);
            CorrectionFunction func;
            float r, g, b;
            //definition of used function
            //delegates is defined as a named methods.
            switch (mode)
            {
                case IntensityCorrectionMode.LightImage:
                    {
                        func = new CorrectionFunction(LightImageCorrection);
                        //INFORMATION: or use anonymous delegate
                        //func = delegate(float value) {return (float)Math.Pow(value, 2.5f);}
                        break;
                    }
                case IntensityCorrectionMode.DarkImage:
                    {
                        func = new CorrectionFunction(DarkImageCorrection);

                        break;
                    }
                case IntensityCorrectionMode.SoftImage:
                    {
                        func = new CorrectionFunction(SoftImageCorrection);
                        break;
                    }
                default:
                    {
                        func = new CorrectionFunction(SoftImageCorrection);
                        break;
                    }
            }

            //processing
            for (int j = 0; j < height; j++)
            {
                for (int i = 0; i < width; i++)
                {
                    r = func(rOriginal[i, j].R / 255.0f);
                    g = func(rOriginal[i, j].G / 255.0f);
                    b = func(rOriginal[i, j].B / 255.0f);
                    raster[i, j] = new VectorRgb(r, g, b);
                }
            }
            return raster;
        }
Esempio n. 2
0
 private Color ChangeCorrection(Color pixel, CorrectionFunction fn)
 {
     return(Color.FromArgb(fn(pixel.R), fn(pixel.G), fn(pixel.B)));
 }
Esempio n. 3
0
        public override Raster ProcessRaster(Raster rOriginal, System.ComponentModel.BackgroundWorker worker)
        {
            worker.WorkerReportsProgress = true;
            int width = rOriginal.Width;
            int height = rOriginal.Height;
            Raster raster = new Raster(width, height);
            CorrectionFunction func;
            float r, g, b;
            DateTime startTime = DateTime.Now;
            //definition of used function
            //delegates is defined as a named methods.
            switch (mode)
            {
                case IntensityCorrectionMode.LightImage:
                    {
                        func = new CorrectionFunction(LightImageCorrection);
                        //INFORMATION: or use anonymous delegate
                        //func = delegate(float value) {return (float)Math.Pow(value, 2.5f);}
                        break;
                    }
                case IntensityCorrectionMode.DarkImage:
                    {
                        func = new CorrectionFunction(DarkImageCorrection);

                        break;
                    }
                case IntensityCorrectionMode.SoftImage:
                    {
                        func = new CorrectionFunction(SoftImageCorrection);
                        break;
                    }
                default:
                    {
                        func = new CorrectionFunction(SoftImageCorrection);
                        break;
                    }
            }

            //processing
            for (int j = 0; j < height; j++)
            {
                for (int i = 0; i < width; i++)
                {
                    r = func(rOriginal[i, j].R / 255.0f);
                    g = func(rOriginal[i, j].G / 255.0f);
                    b = func(rOriginal[i, j].B / 255.0f);
                    raster[i, j] = new VectorRgb(r, g, b);
                }
                worker.ReportProgress((int)(100f * j / height), DateTime.Now - startTime);
            }
            return raster;
        }