/// <summary> /// Processes the image. /// </summary> /// <param name="factory">The current instance of the <see cref="T:ImageProcessor.ImageFactory" /> class containing /// the image to process.</param> /// <returns> /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory" /> class. /// </returns> public Image ProcessImage(ImageFactory factory) { Bitmap newImage = null; Bitmap image = (Bitmap)factory.Image; try { newImage = new Bitmap(image); GaussianLayer gaussianLayer = this.DynamicParameter; Convolution convolution = new Convolution(gaussianLayer.Sigma) { Threshold = gaussianLayer.Threshold }; double[,] kernel = convolution.CreateGuassianSharpenFilter(gaussianLayer.Size); newImage = convolution.ProcessKernel(newImage, kernel); image.Dispose(); image = newImage; } catch (Exception ex) { if (newImage != null) { newImage.Dispose(); } throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex); } return(image); }
/// <summary> /// Processes the image. /// </summary> /// <param name="factory">The the current instance of the <see cref="T:ImageProcessor.ImageFactory" /> class containing /// the image to process.</param> /// <returns> /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory" /> class. /// </returns> public Image ProcessImage(ImageFactory factory) { Bitmap newImage = null; Bitmap image = (Bitmap)factory.Image; try { newImage = new Bitmap(image); GaussianLayer gaussianLayer = (GaussianLayer)this.DynamicParameter; Convolution convolution = new Convolution(gaussianLayer.Sigma) { Threshold = gaussianLayer.Threshold }; double[,] kernel = convolution.CreateGuassianBlurFilter(gaussianLayer.Size); newImage = convolution.ProcessKernel(newImage, kernel); image.Dispose(); image = newImage; } catch { if (newImage != null) { newImage.Dispose(); } } return(image); }
/// <summary> /// Uses a Gaussian kernel to sharpen the current image. /// <remarks> /// <para> /// The sigma and threshold values applied to the kernel are /// 1.4 and 0 respectively. /// </para> /// </remarks> /// </summary> /// <param name="size"> /// The size to set the Gaussian kernel to. /// </param> /// <returns> /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class. /// </returns> public ImageFactory GaussianSharpen(int size) { if (this.ShouldProcess && size > 0) { GaussianLayer layer = new GaussianLayer(size); return(this.GaussianSharpen(layer)); } return(this); }
/// <summary> /// Uses a Gaussian kernel to sharpen the current image. /// </summary> /// <param name="gaussianLayer"> /// The <see cref="T:ImageProcessor.Imaging.GaussianLayer"/> for applying sharpening and /// blurring methods to an image. /// </param> /// <returns> /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class. /// </returns> public ImageFactory GaussianSharpen(GaussianLayer gaussianLayer) { if (this.ShouldProcess) { GaussianSharpen gaussianSharpen = new GaussianSharpen { DynamicParameter = gaussianLayer }; this.CurrentImageFormat.ApplyProcessor(gaussianSharpen.ProcessImage, this); } return(this); }
/// <summary> /// Uses a Gaussian kernel to blur the current image. /// </summary> /// <param name="gaussianLayer"> /// The <see cref="T:ImageProcessor.Imaging.GaussianLayer"/> for applying sharpening and /// blurring methods to an image. /// </param> /// <returns> /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class. /// </returns> public ImageFactory GaussianBlur(GaussianLayer gaussianLayer) { if (this.ShouldProcess) { GaussianBlur gaussianBlur = new GaussianBlur { DynamicParameter = gaussianLayer }; this.ApplyProcessor(gaussianBlur.ProcessImage); } return(this); }
private Bitmap changeBlur(Image image, int blur) // Изменение размытия { if (blur > 0 & blur <= 100) { var factory = new ImageFactory(preserveExifData: true); factory.Load(bitmap); GaussianLayer layer = new GaussianLayer(blur / 4); GaussianBlur blur1 = new GaussianBlur { DynamicParameter = layer }; return((Bitmap)blur1.ProcessImage(factory)); } return((Bitmap)image); }
/// <summary> /// Processes the image. /// </summary> /// <param name="factory">The current instance of the <see cref="T:ImageProcessor.ImageFactory" /> class containing /// the image to process.</param> /// <returns> /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory" /> class. /// </returns> public Image ProcessImage(ImageFactory factory) { Bitmap image = (Bitmap)factory.Image; try { GaussianLayer gaussianLayer = this.DynamicParameter; Convolution convolution = new Convolution(gaussianLayer.Sigma) { Threshold = gaussianLayer.Threshold }; double[,] kernel = convolution.CreateGuassianSharpenFilter(gaussianLayer.Size); return(convolution.ProcessKernel(image, kernel, factory.FixGamma)); } catch (Exception ex) { throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex); } }