Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }