public void CreateMask(ApplicationArguments arguments) { if (arguments == null) { throw new ArgumentNullException(nameof(arguments)); } try { var imageFormat = ImageFormat.Png; if (!string.IsNullOrEmpty(arguments.FileType)) { imageFormat = ImageFileTypeHelper.FromString(arguments.FileType).ToImageFormat(); } _outputWriter.SetOutputMethod(OnOutput); _outputWriter.LoadingFile(arguments.LdrCalibrationFilePath); var ldrCalibrationMeasurements = _measurementsLoader.GetFromCsvFile(arguments.LdrCalibrationFilePath); _outputWriter.ConstructionLdPolynomialCurveFit(); var maskIntensityInterpolator = _maskIntensityInterpolatorFactory.Create(ldrCalibrationMeasurements); _outputWriter.LoadingFile(arguments.LcdMeasurementsFilePathHigh); var measurementsHigh = _measurementGridLoader.GetFromCsvFile( arguments.LcdMeasurementsFilePathHigh, arguments.MeasurementsNrOfRows, arguments.MeasurementsNrOfColumns); _outputWriter.LoadingFile(arguments.LcdMeasurementsFilePathLow); var measurementsLow = _measurementGridLoader.GetFromCsvFile( arguments.LcdMeasurementsFilePathLow, arguments.MeasurementsNrOfRows, arguments.MeasurementsNrOfColumns); _outputWriter.ConstructingGridOfLowHighMeasurements(); var minMaxResistanceGrid = _measurementGridProcessor.CreateMinMaxMeasurementGrid(arguments.Low, arguments.High, measurementsLow, measurementsHigh); _outputWriter.CreatingGridOfLocalMaskIntensities(); var localMaskIntensityGrid = _measurementGridProcessor.CreateLocalMaskIntensityGrid(maskIntensityInterpolator, minMaxResistanceGrid, arguments.DesiredResistance); _outputWriter.ConvertingLocalMaskIntensitiesToBitmap(); using (var bitmap = _measurementGridProcessor.CreateBitMap(localMaskIntensityGrid)) { _outputWriter.ResizingBitmap(bitmap, arguments.LcdWidth, arguments.LcdHeight); using (var mask = _bitmapProcessor.Resize(bitmap, arguments.LcdWidth, arguments.LcdHeight)) { _bitmapProcessor.Save(mask, arguments.MaskFilePath, imageFormat); _outputWriter.MaskSavedTo(arguments.MaskFilePath); } } if (arguments.OriginalExposureTime > 0) { var exposureTime = _exposureTimeCalculator.CalculateExposure(arguments.High, localMaskIntensityGrid, arguments.OriginalExposureTime); _outputWriter.NewAdvisedExposureTime(exposureTime); OnExposureTimeCalculated(exposureTime); } } catch (Exception exception) { CreateErrorReport(exception, arguments); throw; } }