/// <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.CreateGuassianBlurFilter(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 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.CreateGuassianBlurFilter(gaussianLayer.Size); return convolution.ProcessKernel(image, kernel, factory.FixGamma); } catch (Exception ex) { throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex); } }
/// <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; }