Exemple #1
0
        private byte[,] CodeFilter(byte[,] bytes, CodeFilterItemViewModel filter)
        {
            if (filter.FilterArgs == null)
            {
                return(bytes);
            }
            int[] args = filter.FilterArgs.Split(',').Select(m => m.CastTo <int>()).ToArray();
            switch (filter.FilterName)
            {
            case "Binaryzation":
                _code += $".Binaryzation({args[0]})";
                return(bytes.Binaryzation((byte)args[0]));

            case "DeepFore":
                _code += $".DeepFore({args[0]})";
                return(bytes.DeepFore((byte)args[0]));

            case "ClearNoiseRound":
                _code += $".ClearNoiseRound({args[0]}, {args[1]})";
                return(bytes.ClearNoiseRound((byte)args[0], args[1]));

            case "ClearNoiseArea":
                _code += $".ClearNoiseArea({args[0]}, {args[1]})";
                return(bytes.ClearNoiseArea((byte)args[0], args[1]));

            case "ClearBorder":
                _code += $".ClearBorder({args[0]})";
                return(bytes.ClearBorder(args[0]));

            case "AddBorder":
                _code += $".AddBorder({args[0]}, {args[1]})";
                return(bytes.AddBorder(args[0], (byte)args[1]));

            case "ClearGray":
                _code += $".ClearGray({args[0]},{args[1]})";
                return(bytes.ClearGray((byte)args[0], (byte)args[1]));

            case "ToValid":
                _code += $".ToValid({args[0]})";
                return(bytes.ToValid((byte)args[0]));
            }
            return(bytes);
        }