示例#1
0
        public override bool EnterParameters()
        {
            ProcessingAlgorithm algorithm;

            switch (Program.paramState.algorithmOption)
            {
            case "1":
                algorithm = new MeanFilterImplementation();
                algorithm.PreProcessingEvent.Subscribe(new MeanPreProcessingCommand());
                algorithm.PostProcessingEvent.Subscribe(new MeanPostProcessingCommand());
                algorithm.ProcessingStepEvent.Subscribe(new MeanProcessingStepCommand());
                break;

            case "2":
                algorithm = new Binarization();
                algorithm.PreProcessingEvent.Subscribe(new BinarizationPreProccesingCommand());
                algorithm.PostProcessingEvent.Subscribe(new BinarizationPostProccesingCommand());
                algorithm.ProcessingStepEvent.Subscribe(new BinarizationProccessingStepCommand());
                break;

            case "3":
                algorithm = new Inverse();
                algorithm.PreProcessingEvent.Subscribe(new InversePreProcessingCommand());
                algorithm.PostProcessingEvent.Subscribe(new InversePostProcessingCommand());
                break;

            default:
                return(false);
            }
            var parameters = new Dictionary <String, String>();

            foreach (var parameter in algorithm.ExpectedParameters)
            {
                Console.Write($"{parameter} = ");
                var value = Console.ReadLine();
                parameters.Add(parameter, value);
            }
            Program.builder.WriteImage(algorithm.Process(Program.image, parameters), "result.png");
            Program.SetMachineState(Program.unloadedState);
            return(true);
        }