示例#1
0
        public static int[] FieldcodeRunlengthsEn2(IntField image, SymbolCodec runlengthCodec, Compressor compr)
        {
            compr.AddImageGrayscale(image, 0, 3, "xformed");
            List <int> data = new List <int>();

            for (int i = 1; i <= 3; i++)
            {
                IntField temp = image.Clone();
                temp.Map(x => x == i ? 1 : 0);
                data.AddRange(temp.Data);
                compr.AddImageGrayscale(temp, 0, 1, "field" + i);
            }
            var runs = runlengthCodec.Encode(data.ToArray());

            compr.SetCounter("runs", runs.Length);
            return(runs);
        }
示例#2
0
        public static List <int[]> FieldcodeRunlengthsEn(IntField image, SymbolCodec runlengthCodec, Compressor compr)
        {
            compr.AddImageGrayscale(image, 0, 3, "xformed");
            var fields = new List <int[]>();

            for (int i = 1; i <= 3; i++)
            {
                IntField temp = image.Clone();
                temp.Map(x => x == i ? 1 : 0);
                var field = runlengthCodec.Encode(temp.Data);
                CodecUtil.Shift(field, 1);
                compr.SetCounter("symbols|field-" + i, field.Length);
                fields.Add(field);
                compr.AddImageGrayscale(temp, 0, 1, "field" + i);
            }
            return(fields);
        }
示例#3
0
        public static IntField FieldcodeRunlengthsDe2(int[] runs, int width, int height, SymbolCodec runlengthCodec, Compressor compr)
        {
            IntField image = new IntField(width, height);
            var      data  = runlengthCodec.Decode(runs);

            for (int i = 1; i <= 3; i++)
            {
                int offs = width * height * (i - 1);
                for (int p = 0; p < width * height; p++)
                {
                    if (data[offs + p] == 1)
                    {
                        image.Data[p] = i;
                    }
                }

                // Visualise
                IntField img = new IntField(width, height);
                Array.Copy(data, offs, img.Data, 0, width * height);
                compr.AddImageGrayscale(img, 0, 1, "field" + i);
            }
            compr.AddImageGrayscale(image, 0, 3, "xformed");
            return(image);
        }
示例#4
0
        public static IntField FieldcodeRunlengthsDe(List <int[]> fields, int width, int height, SymbolCodec runlengthCodec, Compressor compr)
        {
            IntField image = new IntField(width, height);

            for (int i = 1; i <= 3; i++)
            {
                CodecUtil.Shift(fields[i - 1], -1);
                var f = runlengthCodec.Decode(fields[i - 1]);

                for (int p = 0; p < width * height; p++)
                {
                    if (f[p] == 1)
                    {
                        image.Data[p] = i;
                    }
                }

                // Visualise
                IntField img = new IntField(width, height);
                img.Data = f;
                compr.AddImageGrayscale(img, 0, 1, "field" + i);
            }
            compr.AddImageGrayscale(image, 0, 3, "xformed");
            return(image);
        }
示例#5
0
文件: I4cDelta.cs 项目: rstarkov/i4c
 public override void Configure(params RVariant[] args)
 {
     base.Configure(args);
     Seer = new FixedSizeForeseer((int)Config[0], (int)Config[1], (int)Config[2], new HorzVertForeseer());
     RLE  = new RunLength01LongShortCodec((int)Config[3], (int)Config[4]);
 }