/// <summary> /// Applies localized/adaptive region thresholding to image using Chow & Kaneko method. /// </summary> /// <typeparam name="T">Image type to process and return</typeparam> /// <param name="image">Image to process</param> /// <param name="horizontalRegions">Number of horizonal regions to apply</param> /// <param name="verticalRegions">Number of veritical regions to apply</param> /// <returns>New image with localized threshold applied</returns> public static T ApplyChowKanekoMethod <T>(T image, int horizontalRegions, int verticalRegions) where T : Image { Bitmap bitmap = ImageFormatting.ToBitmap(image); ApplyChowKanekoMethodDirect(ref bitmap, horizontalRegions, verticalRegions); return((T)ImageFormatting.Convert(bitmap, image.RawFormat)); }
/// <summary> /// Applies thresholding to image using Otsu's Method. /// Returned image will consist of black (0) and white (255) values only. /// </summary> /// <typeparam name="T">Image type to process and return</typeparam> /// <param name="image">Image to process</param> /// <returns>New image with threshold applied</returns> public static T ApplyOtsuMethod <T>(T image) where T : Image { Bitmap bitmap = ImageFormatting.ToBitmap(image); ApplyOtsuMethodDirect(ref bitmap); return((T)ImageFormatting.Convert(bitmap, image.RawFormat)); }
/// <summary> /// Any pixel values outside the threshold will be changed to min/max. /// </summary> /// <typeparam name="T">Image type to process and return</typeparam> /// <param name="image">Image to process</param> /// <param name="minValue">Minimum threshold value</param> /// <param name="maxValue">Maximum threshold value</param> /// <returns>New image with threshold applied</returns> public static T ApplyMinMax <T>(T image, byte minValue, byte maxValue) where T : Image { Bitmap bitmap = ImageFormatting.ToBitmap(image); ApplyMinMaxDirect(ref bitmap, minValue, maxValue); return((T)ImageFormatting.Convert(bitmap, image.RawFormat)); }
/// <summary> /// Any pixel values below threshold will be changed to 0 (black). /// Any pixel values above (or equal to) threshold will be changed to 255 (white). /// </summary> /// <typeparam name="T">Image type to process and return</typeparam> /// <param name="image">Image to process</param> /// <param name="threshold">Threshold value</param> /// <returns>New image with threshold applied</returns> public static T Apply <T>(T image, byte threshold) where T : Image { Bitmap bitmap = ImageFormatting.ToBitmap(image); ApplyDirect(ref bitmap, threshold); return((T)ImageFormatting.Convert(bitmap, image.RawFormat)); }
/// <summary> /// Stretches image contrast to specified min/max values. /// </summary> /// <typeparam name="T">Image type to process and return</typeparam> /// <param name="image">Image to process</param> /// <param name="min">Minimum contrast value</param> /// <param name="max">Maximum contrast value</param> /// <returns>Contrast-stretched image</returns> public static T Stretch <T>(T image, byte min, byte max) where T : Image { Bitmap bitmap = ImageFormatting.ToBitmap(image); StretchDirect(ref bitmap, min, max); return((T)ImageFormatting.Convert(bitmap, image.RawFormat)); }
/// <summary> /// Histogram Equalization will enhance general contrast /// by distributing grey levels wider and more evenly. /// </summary> /// <typeparam name="T">Image type to process and return</typeparam> /// <param name="image">Image to equalize</param> /// <returns>Equalized image</returns> public static T HistogramEqualization <T>(T image) where T : Image { Bitmap bitmap = ImageFormatting.ToBitmap(image); HistogramEqualizationDirect(ref bitmap); return((T)ImageFormatting.Convert(bitmap, image.RawFormat)); }
/// <summary> /// Inverts image to negative. /// </summary> /// <typeparam name="T">Image type to process and return</typeparam> /// <param name="image">Image to convert</param> /// <returns>Negative image</returns> public static T ToNegative <T>(T image) where T : Image { Bitmap bitmap = ImageFormatting.ToBitmap(image); ToNegativeDirect(ref bitmap); return((T)ImageFormatting.Convert(bitmap, image.RawFormat)); }
/// <summary> /// Applies color filter to image. /// </summary> /// <typeparam name="T">Image type to process and return</typeparam> /// <param name="image">Image to process</param> /// <param name="r">Red component to apply</param> /// <param name="g">Green component to apply</param> /// <param name="b">Blue component to apply</param> /// <returns>New image with filter applied</returns> public static T ApplyFilterRGB <T>(T image, byte r, byte g, byte b) where T : Image { Bitmap bitmap = ImageFormatting.ToBitmap(image); ApplyFilterDirectRGB(ref bitmap, r, g, b); return((T)ImageFormatting.Convert(bitmap, image.RawFormat)); }