/// <summary> /// Constructor of the <see cref="Sampler"/> object. Don't use this constructor, use <see cref="Context.CreateSampler(ImageAddressing, ImageFiltering, bool)"/> method instead. /// </summary> public Sampler(IntPtr handle, Context context, ImageAddressing addr, ImageFiltering filt, bool norm) { Handle = handle; Context = context; AddressingMode = addr; FilteringMode = filt; NormalizedCoordinates = norm; }
public static void ApplyPrewittFilterAndSave( string sourceFilePath, byte[,] sourceImage) { byte[,] resultImage = ImageFiltering.ApplyPrewittFilter(sourceImage, true); string newFilePath = ProbA1.NewFilePath(sourceFilePath, "PrewittFilter"); Utility.SaveGrayscaleImage(resultImage, newFilePath); Console.WriteLine($"Prewitt filter applied and saved to \'{newFilePath}\'"); }
public static void ApplyAveragingFilterAndSave( string sourceFilePath, byte[,] sourceImage, int filterSize) { byte[,] resultImage = ImageFiltering.ApplyAveragingFilter(sourceImage, filterSize); string newFilePath = ProbA1.NewFilePath(sourceFilePath, $"AveragingFilter{filterSize}"); Utility.SaveGrayscaleImage(resultImage, newFilePath); Console.WriteLine($"Averaging filter (size: {filterSize}) " + $"applied and saved to \'{newFilePath}\'"); }
public static void ApplySharpeningFilterAndSave( string sourceFilePath, byte[,] sourceImage, int filterSize, double k) { byte[,] resultImage = ImageFiltering.ApplySharpeningFilter(sourceImage, filterSize, k); string newFilePath = ProbA1.NewFilePath( sourceFilePath, $"SharpeningFilter{filterSize}-{k}"); Utility.SaveGrayscaleImage(resultImage, newFilePath); Console.WriteLine($"Sharpening filter applied and saved to \'{newFilePath}\'"); }
/// <summary> /// Creates a <see cref="Sampler"/> object. /// </summary> /// <param name="addressingMode">Specifies how out-of-range image coordinates are handled when reading from an image.</param> /// <param name="filteringMode">Specifies the type of filter that must be applied when reading an image.</param> /// <param name="normalizedCoordinates">Determines if the image coordinates specified are normalized or not.</param> /// <returns>A new sampler.</returns> public Sampler CreateSampler(ImageAddressing addressingMode, ImageFiltering filteringMode, bool normalizedCoordinates) { IntPtr samplerHandle = clCreateSampler(Handle, normalizedCoordinates, addressingMode, filteringMode, out error); if (error != ErrorCode.Success) { return(null); } return(new Sampler(samplerHandle, this, addressingMode, filteringMode, normalizedCoordinates)); }
public static void DetectEdgesAndSave( string sourceFilePath, byte[,] sourceImage, int filterSize, double standardDeviation) { byte[,] resultImage = ImageFiltering.DetectEdges( sourceImage, filterSize, standardDeviation); string newFilePath = ProbA1.NewFilePath( sourceFilePath, $"DetectEdges{filterSize}-{standardDeviation}"); Utility.SaveGrayscaleImage(resultImage, newFilePath); Console.WriteLine($"Edge detection done and file saved to \'{newFilePath}\'"); }
public static void ApplyGaussianFilterAndSave( string sourceFilePath, byte[,] sourceImage, int filterSize, double standardDeviation) { byte[,] resultImage = ImageFiltering.ApplyGaussianFilter( sourceImage, filterSize, standardDeviation); string newFilePath = ProbA1.NewFilePath( sourceFilePath, $"GaussianFilter{filterSize}-{standardDeviation}"); Utility.SaveGrayscaleImage(resultImage, newFilePath); Console.WriteLine($"Gaussian filter (size: {filterSize}, " + $"standard deviation: {standardDeviation}) " + $"applied and saved to \'{newFilePath}\'"); }
public static byte[,] ApplyBilateralFilterAndSave( string sourceFilePath, byte[,] sourceImage, int filterSize, double sigma1, double sigma2, int times) { byte[,] resultImage = ImageFiltering.ApplyBilateralFilter( sourceImage, filterSize, sigma1, sigma2); string newFilePath = ProbA2.NewFilePath( sourceFilePath, $"BilateralFilter{filterSize}-{sigma1}-{sigma2}-{times}"); Utility.SaveGrayscaleImage(resultImage, newFilePath); Console.WriteLine($"Bilateral filter (size: {filterSize}) " + $"applied and saved to \'{newFilePath}\'"); return(resultImage); }
private extern static IntPtr clCreateSampler( IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool normalized_coords, ImageAddressing addressing_mode, ImageFiltering filter_mode, out ErrorCode errcode_ret);