예제 #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
                };
            });
        }
예제 #2
0
        List<IFilter> PrepareFilters()
        {
            var debayer = new AverageBGGRDemosaic();

            var white = new WhiteBalanceFilter();
            white.WhiteColor = exif.WhiteColor.ToVector3();

            var gamma = new GammaFilter();
            var light = new LightFilter();

            var satur = new SaturationFilter(3f);
            var colorMatrix = new ColorMatrixFilter
            {
                Matrix = new[,]
                    {
                        {1.87f, -0.81f, -0.06f},
                        {-0.16f, 1.55f, -0.39f},
                        {0.05f, -0.47f, 1.42f}
                    }.ToMatrix4x4()
            };
            var compressor = new VectorBGRACompressorFilter();

            var filters = new List<IFilter>
            {
                    debayer,
                    white,
                    gamma,
                    //new RGB2YUVFilter(),
                    light,
                    satur,
                    //new YUV2RGBFilter(),
                    //colorMatrix,
                    compressor
            };
            return filters;
        }