Exemple #1
0
        internal static async Task <RgbImageFile> OpenFile(string p)
        {
            return(await Task.Run(() =>
            {
                Stream stream = new FileStream(p, FileMode.Open, FileAccess.Read);
                var rawimage = new PanasonicRW2Decoder().Decode(stream);
                var debayer = new AverageBGGRDebayer();

                var white = new WhiteBalanceFilter();
                white.WhiteColor = rawimage.Exif.WhiteColor.ToVector3();

                var gamma = new GammaFilter();

                var light = new LightFilter();
                var saturation = new SaturationFilter {
                    Saturation = 1.5f
                };

                var colorMatrix = new ColorMatrixFilter
                {
                    Matrix = new[, ]
                    {
                        { 1.87f, -0.81f, -0.06f },
                        { -0.06f, 1.35f, -0.29f },
                        { 0.05f, -0.37f, 1.32f }
                    }.ToMatrix4x4()
                };

                var compressor = new VectorCompressorFilter();
                var pipeline = new FiltersPipeline(new IFilter[]
                {
                    debayer,
                    white,
                    gamma,
                    light,
                    //saturation,
                    colorMatrix,
                    compressor
                });
                pipeline.AutoAdjust(rawimage.Raw, white);

                pipeline.AutoAdjust(rawimage.Raw, light);

                return new RgbImageFile
                {
                    Pixels = pipeline.RawMapToRGB(rawimage.Raw),
                    Exif = rawimage.Exif
                };
            }));
        }
Exemple #2
0
        public void FullProcessWithAutoAdjustTest()
        {
            var       stopwatch = Stopwatch.StartNew();
            const int maxIter   = 5;

            for (var iter = 0; iter < maxIter; iter++)
            {
                Stream stream = new FileStream(@"..\..\..\PanasonicRW2.Tests\P1350577.RW2", FileMode.Open,
                                               FileAccess.Read);
                var rawimage = new PanasonicRW2Decoder().Decode(stream);
                var debayer  = new AverageBGGRDebayer();

                var white = new WhiteBalanceFilter();
                //white.AutoAdjust(color16Image);
                var gamma = new GammaFilter();


                var light = new LightFilter();
                //light.AutoAdjust(color16Image);

                var compressor = new VectorCompressorFilter();
                var pipeline   = new FiltersPipeline(new IFilter[]
                {
                    debayer,
                    white,
                    gamma,
                    light,
                    compressor
                });
                pipeline.AutoAdjust(rawimage.Raw, white);
                pipeline.AutoAdjust(rawimage.Raw, light);

                pipeline.RawMapToRGB(rawimage.Raw);
            }
            stopwatch.Stop();
            Console.WriteLine("FullProcessWithAutoAdjust: " + stopwatch.ElapsedMilliseconds / maxIter + "ms");

            //Before Curve - Release 3756ms
            //After Curve - Release 1900ms
            //2015 Vector3 - Release 1305ms
        }
        public void FullProcessP1460461Test()
        {
            var       stopwatch = Stopwatch.StartNew();
            const int maxIter   = 1;

            for (var iter = 0; iter < maxIter; iter++)
            {
                var stream = new FileStream(@"..\..\..\PanasonicRW2.Tests\P1460461.RW2", FileMode.Open,
                                            FileAccess.Read);
                var decoder = new PanasonicRW2Decoder();
                var exif    = decoder.DecodeExif(stream);
                var raw     = decoder.DecodeMap(stream, exif);
                var debayer = new AverageBGGRDemosaic();

                var white = new WhiteBalanceFilter();
                //white.AutoAdjust(color16Image);
                var gamma = new GammaFilter();


                var light = new LightFilter();
                //light.AutoAdjust(color16Image);

                var compressor = new VectorBGRACompressorFilter();
                var pipeline   = new FiltersPipeline(new IFilter[]
                {
                    debayer,
                    white,
                    gamma,
                    light,
                    compressor
                });
                pipeline.ProcessFilters(raw);
            }
            stopwatch.Stop();
            Console.WriteLine("FullProcess: " + stopwatch.ElapsedMilliseconds / maxIter + "ms");

            //Before Curve - Release 3756ms
            //After Curve - Release 1900ms
        }
Exemple #4
0
        public IColorMap Invoke()
        {
            IColorMap image = raw;
            IColorMap newimage;

            foreach (List <Stage> stagesGroup in stages.Split(s => s.AutoAdjuster != null, LinqExtensions.SplitPlace.Last))
            {
                var last = stagesGroup.Last();
                if (last.AutoAdjuster != null)
                {
                    if (stagesGroup.Count > 1)
                    {
                        newimage = FiltersPipeline.ProcessFilters(image, stagesGroup.Take(stagesGroup.Count - 1).Select(s => s.Filter));
                        image.Dispose();
                        image = newimage;
                    }
                    IColorMap imagetoadjust = image;
                    last.AutoAdjuster.AutoAdjust(last.Filter, imagetoadjust);
                    if (image != imagetoadjust)
                    {
                        imagetoadjust.Dispose();
                    }
                    last.AutoAdjuster = null;

                    newimage = FiltersPipeline.ProcessFilters(image, last.Filter);
                    image.Dispose();
                    image = newimage;
                }
                else
                {
                    newimage = FiltersPipeline.ProcessFilters(image, stagesGroup.Select(s => s.Filter));
                    image.Dispose();
                    image = newimage;
                }
            }
            return(image);
        }