public static IEnumerable <AvailableImage> ReadAvailableImages(string sourceDir, int targetBlockSize) { foreach (var imageFile in Directory.EnumerateFiles(sourceDir, "*.jpg", SearchOption.AllDirectories)) { Console.WriteLine("Reading " + imageFile); AvailableImage availableImage = null; try { availableImage = new AvailableImage(targetBlockSize, MakeGrayscale3(new Bitmap(imageFile))); } catch (Exception e) { Console.WriteLine(e); } if (availableImage != null) { yield return(availableImage); } } }
public TargetPixelGenerator(AvailableImage availableImage, SourcePixelBlock sourcePixelBlock) { _availableImage = availableImage; _sourcePixelBlock = sourcePixelBlock; }
public int CompareColors(AvailableImage a) { return(Math.Abs(a.AverageColor.R - _originalAverageColor.R) + Math.Abs(a.AverageColor.G - _originalAverageColor.G) + Math.Abs(a.AverageColor.B - _originalAverageColor.B)); }