Exemple #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);
        }
Exemple #2
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);
        }