public MainForm() { InitializeComponent(); m_stopwatch = new Stopwatch(); FormClosing += (sender, e) => m_holeFiller?.Dispose(); originalImage.LoadCompleted += async(sender, e) => { LoggingTask logger = null; m_holeFiller?.Dispose(); logger = LoggingTask.Start(LoggingTaskType.FindHolesAndBoundaries, "Finding holes and their boundaries"); m_holeFiller = HoleFiller.Current.Initialize(new MissingPixelsService(), new BoundarySearcher(), originalImage.ImageLocation); logger.Finish(); logger = LoggingTask.Start(LoggingTaskType.MarkBoundary, "Marking holes boundaries"); using (Image <Gray, float> imageWithMarkedBoundaries = await m_holeFiller.MarkBoundaries()) { logger.Finish(); if (imageWithMarkedBoundaries != null) { boundariesImage.Image = imageWithMarkedBoundaries; ActOnPostImageLoaded(); } } }; }
private async void fillHolesButton_Click(object sender, EventArgs e) { string functionBody = string.Empty; int z = 0; float epsilon = 0f; int boundaryPixelsSampleSize = 0; bool markBoundary = false; ColorInterpolatorBase colorInterpolator = null; LoggingTask logger = null; ActOnPreFillingHoles(); functionBody = ExtractWeightingFunctionProperties(out z, out epsilon, out boundaryPixelsSampleSize); ExtractVisualizationProperties(out markBoundary); colorInterpolator = new NaiveColorInterpolator( weightingFunction: new WeightingFunction(m_holeFiller.ImageRegion, functionBody, z, epsilon)); logger = LoggingTask.Start(LoggingTaskType.FillHoles, "Naively filling holes"); using (Image <Gray, float> imageWithFilledHoles = await m_holeFiller.FillHoles(colorInterpolator, markBoundary)) { logger.Finish(); if (imageWithFilledHoles != null) { ActOnPostNaiveFillingHoles(imageWithFilledHoles); } } colorInterpolator = new ApproximateColorInterpolator( weightingFunction: new WeightingFunction(m_holeFiller.ImageRegion, functionBody, z, epsilon), boundaryPixelsSampleSize: boundaryPixelsSampleSize); logger = LoggingTask.Start(LoggingTaskType.FillHoles, "Approximately filling holes"); using (Image <Gray, float> imageWithFilledHoles = await m_holeFiller.FillHoles(colorInterpolator, markBoundary)) { logger.Finish(); if (imageWithFilledHoles != null) { ActOnPostApproximateFillingHoles(imageWithFilledHoles); } } }