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); }
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); }