private string BinarizeImage(string sourcepath, int imageWidth, int imageHeight, string destinationPath, string name) { string binaryImage; if (!Directory.Exists(destinationPath)) { Directory.CreateDirectory(destinationPath); } string _destinationPath = Path.Combine(destinationPath, $"{name}.jpg"); string _sourcePath = Path.Combine(sourcepath, $"{name}.jpg"); if (File.Exists(_destinationPath)) { File.Delete(_destinationPath); } ImageBinarizer imageBinarizer = new ImageBinarizer(new BinarizerParams { RedThreshold = 200, GreenThreshold = 200, BlueThreshold = 200, ImageWidth = imageWidth, ImageHeight = imageHeight, InputImagePath = sourcepath, OutputImagePath = _destinationPath }); imageBinarizer.Run(); binaryImage = imageBinarizer.GetStringBinary(); return(_destinationPath); }
public void BinarizeImageTest(String sourcePath, String destinationPath) { ImageBinarizer imageBinarizer = new ImageBinarizer(new BinarizerParams { RedThreshold = 200, GreenThreshold = 200, BlueThreshold = 200, ImageWidth = 100, ImageHeight = 100, InputImagePath = sourcePath, OutputImagePath = destinationPath }); imageBinarizer.Run(); }
/// <summary> /// Binarize image to binarizedImage. /// </summary> /// <param name="mnistImage"></param> /// <param name="imageSize"></param> /// <param name="testName"></param> /// <returns></returns> private static string BinarizeImage(string mnistImage, int imageSize, string testName) { string binaryImage = $"{testName}.txt"; if (File.Exists(binaryImage)) { File.Delete(binaryImage); } ImageBinarizer imageBinarizer = new ImageBinarizer(new BinarizerParams { RedThreshold = 200, GreenThreshold = 200, BlueThreshold = 200, ImageWidth = imageSize, ImageHeight = imageSize, InputImagePath = mnistImage, OutputImagePath = binaryImage }); imageBinarizer.Run(); return(binaryImage); }
/// <summary> /// Binarize image to create an binarized image and return the path to that binarized image. /// </summary> /// <param name="mnistImage"> Path to the source mnist image</param> /// <param name="imageSize">Size of the image (image has same width and height)</param> /// <returns>Path to the output binarized image</returns> private static string BinarizeImage(string mnistImage, int imageSize) { var binaryImage = $@"Output\{GetFileName(mnistImage)}.txt"; Directory.CreateDirectory($"Output"); if (File.Exists(binaryImage)) { File.Delete(binaryImage); } ImageBinarizer imageBinarizer = new ImageBinarizer(new BinarizerParams { RedThreshold = 200, GreenThreshold = 200, BlueThreshold = 200, ImageWidth = imageSize, ImageHeight = imageSize, InputImagePath = mnistImage, OutputImagePath = binaryImage }); imageBinarizer.Run(); return(binaryImage); }