public async Task <Image <Gray, float> > FillHoles(ColorInterpolatorBase colorInterpolator, bool markBoundary) { Image <Gray, float> result = null; await Task.Run(() => { result = new Image <Gray, float>(m_normalizedImageMatrix.Cols, m_normalizedImageMatrix.Rows); using (Matrix <float> filledImageMatrix = new Matrix <float>(m_normalizedImageMatrix.Rows, m_normalizedImageMatrix.Cols)) { m_normalizedImageMatrix.CopyTo(filledImageMatrix); m_missingPixelsService.TryFillHoles(filledImageMatrix, m_boundarySearher, colorInterpolator); ImageColorsService.ScaleColorsUp(filledImageMatrix); if (markBoundary) { m_boundarySearher.TryMarkBoundaryPixels(filledImageMatrix); } filledImageMatrix.CopyTo(result); } }); return(result); }
public void TryFillHoles(Matrix <float> normalizedImageMatrix, IBoundarySearcher boundarySearcher, ColorInterpolatorBase colorInterpolator) { m_missingPixels.All(missingPixel => { normalizedImageMatrix[missingPixel.Row, missingPixel.Column] = ImageColorsService.InterpolateColor(missingPixel, boundarySearcher.BoundaryPixels, colorInterpolator); return(true); }); }
/// <summary> /// Interpolates color value for a missing pixel <paramref name="x"/> using the set of boundary pixels <paramref name="y"/>, /// according to the <paramref name="colorInterpolator"/> algorithm. /// </summary> /// <param name="missingPixel">Pixel that missing color in the image.</param> /// <param name="boundaryPixels">Set of boundary pixels.</param> /// <param name="colorInterpolator">Color interpolation algorithm.</param> /// <returns></returns> public static float InterpolateColor(Pixel missingPixel, ICollection <Pixel> boundaryPixels, ColorInterpolatorBase colorInterpolator) { return(colorInterpolator.InterpolateColor(missingPixel, boundaryPixels)); }