private void FiltroSharpen(Bitmap bmp) { IFilter Filtro = new Sharpen(); Bitmap XImage = Filtro.Apply(bmp); pictureCapchaE.Image = XImage; }
private void FiltroSharpen(Bitmap bmp) { IFilter filtro = new Sharpen(); Bitmap xImage = filtro.Apply(bmp); peCaptcha.Image = xImage; }
public string decodeBitmap(Bitmap img) { /////////图像处理 //转为灰度图 Grayscale grayscaleFilter = new Grayscale(0.299, 0.587, 0.114); Bitmap bitmapGrayscale = grayscaleFilter.Apply(img); //二值化 Threshold thresholdFilter = new Threshold(128); Bitmap bitmapThreshold = thresholdFilter.Apply(bitmapGrayscale); ////////中值滤波 Median mediafil = new Median(); Bitmap medianBit = mediafil.Apply(bitmapThreshold); //锐化 Sharpen sharpPic = new Sharpen(); Bitmap sharpOut = sharpPic.Apply(medianBit); //统计点数 HorizontalIntensityStatistics his = new HorizontalIntensityStatistics(sharpOut); Histogram histogram = his.Gray; int[] dato = histogram.Values; /////分割图像 charCut(dato); shunfengdecoder decode = new shunfengdecoder(); string backcode = decode.Decoder(sharpOut, div); return(backcode); }
public Bitmap Sharpen() { using (Bitmap bitmap = LoadBitmap()) { return(SHARPEN_FILTER.Apply(bitmap)); } }
public Bitmap GetNewFrame(Bitmap source) { var newFrame = sharpen.Apply(source); source.Dispose(); return(newFrame); }
public Bitmap ToSharpen(Bitmap Im) { AForge.Imaging.Filters.Sharpen Img = new Sharpen(); Bitmap bmImage = AForge.Imaging.Image.Clone(new Bitmap(Im), PixelFormat.Format24bppRgb); return(Img.Apply(bmImage)); }
//sharpen the image private static Bitmap Sharpen(Bitmap image) { // create filter Sharpen filter = new Sharpen(); // apply the filter return(filter.Apply(image)); }
public static Bitmap Sharpen(Bitmap Imagem) { Sharpen filter = new Sharpen(); Imagem = Imagem.Clone(new Rectangle(0, 0, Imagem.Width, Imagem.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb); Imagem = filter.Apply(Imagem); return(Imagem); }
public static Bitmap Sharpen(this Bitmap source) { try { var sharpenFilter = new Sharpen() { Kernel = new int[, ] { { -1, -1, -1 }, { -1, 9, -1 }, { -1, -1, -1 } }, Threshold = 1 }; return(sharpenFilter.Apply(source)); } catch (Exception ex) { throw new Exception($"Could not sharpen the image. Message: {ex.Message}", ex); } }
public void sharpenClickHandler(object sender, EventArgs e) { if (image != null) { Bitmap img = new Bitmap(path); Sharpen filter = new Sharpen(); img = filter.Apply(img); //ImageEView if (mov != null) { this.WorkItem.Workspaces[WorkspaceNames.TabWorkspace].Close(mov); } mov = this.WorkItem.SmartParts.AddNew <ImageEView>(); mov.panAndZoomPictureBox1.Image = img; SmartPartInfo spi = new SmartPartInfo("Sharpen", "MyOwnDescription"); this.WorkItem.Workspaces[WorkspaceNames.TabWorkspace].Show(mov, spi); } }
// ProgressDialog dlg = null; private void Sharpen() { IFilter filter = new Sharpen(); Bitmap imgOri = this.ucEditImageCtrl.OriginalImage as Bitmap; if (imgOri != null) { try { Image img = filter.Apply(imgOri); this.ucEditImageCtrl.OriginalImage = m_CurImage = img; } catch (Exception ex) { // MyLog4Net.Container.Instance.Log.Error("Sharpen error: ", ex); //XtraMessageBox.Show("锐化出错!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); this.ucEditImageCtrl.OriginalImage = imgOri; } } }
private void SharpenSmooth(object sender, DoWorkEventArgs e) { Bitmap raw_image = null; if (inRb.Checked) { raw_image = Accord.Imaging.Filters.Grayscale.CommonAlgorithms.BT709.Apply((Bitmap)input_PB.Image.Clone()); } else if (outRb.Checked) { raw_image = (Bitmap)outputImageBox.Image.Clone(); } if (sharpenRB.Checked) { var sharpen = new Sharpen(); sharpen.Threshold = (Byte)threshVal.Value; UnmanagedImage r_img = UnmanagedImage.FromManagedImage(raw_image); outputImageBox.Image.Dispose(); r_img = sharpen.Apply(r_img); outputImageBox.Image = r_img.ToManagedImage(); } else if (smoothingRB.Checked) { var Smoothing = new AdaptiveSmoothing(); Smoothing.Factor = (double)(threshVal.Value); UnmanagedImage r_img = UnmanagedImage.FromManagedImage(raw_image); outputImageBox.Image.Dispose(); r_img = Smoothing.Apply(r_img); outputImageBox.Image = r_img.ToManagedImage(); } else if (radioButton1.Checked) { var Invert = new Invert(); UnmanagedImage r_img = UnmanagedImage.FromManagedImage(raw_image); outputImageBox.Image.Dispose(); r_img = Invert.Apply(r_img); outputImageBox.Image = r_img.ToManagedImage(); } }
public static Bitmap FilterImage(Bitmap img, int filter) { Bitmap sourceImage = img; sourceImage = ImageUtil.convert(sourceImage, System.Drawing.Imaging.PixelFormat.Format32bppArgb); IFilter myFilter; Bitmap filteredImage = sourceImage; if (filter == Filters.filters["Greyscale"]) { sourceImage = Grayscale.CommonAlgorithms.RMY.Apply(sourceImage); filteredImage = sourceImage; } else if (filter == Filters.filters["Sepia"]) { myFilter = new Sepia(); filteredImage = myFilter.Apply(sourceImage); } else if (filter == Filters.filters["Invert"]) { sourceImage = ImageUtil.convert(sourceImage, System.Drawing.Imaging.PixelFormat.Format24bppRgb); myFilter = new Invert(); filteredImage = myFilter.Apply(sourceImage); } else if (filter == Filters.filters["RotateChannel"]) { myFilter = new RotateChannels(); filteredImage = myFilter.Apply(sourceImage); } else if (filter == Filters.filters["Threshold"]) { sourceImage = Grayscale.CommonAlgorithms.RMY.Apply(sourceImage); myFilter = new Threshold(); filteredImage = myFilter.Apply(sourceImage); } else if (filter == Filters.filters["FloydFilter"]) { FloydSteinbergColorDithering myReduction = new FloydSteinbergColorDithering(); filteredImage = myReduction.Apply(sourceImage); } else if (filter == Filters.filters["OrderedDithering"]) { sourceImage = Grayscale.CommonAlgorithms.RMY.Apply(sourceImage); myFilter = new OrderedDithering(); filteredImage = myFilter.Apply(sourceImage); } else if (filter == Filters.filters["Sharpen"]) { myFilter = new Sharpen(); filteredImage = myFilter.Apply(sourceImage); } else if (filter == Filters.filters["DifferenceEdgeDetector"]) { sourceImage = Grayscale.CommonAlgorithms.RMY.Apply(sourceImage); myFilter = new DifferenceEdgeDetector(); filteredImage = myFilter.Apply(sourceImage); } else if (filter == Filters.filters["HomogenityEdgeDetector"]) { sourceImage = Grayscale.CommonAlgorithms.RMY.Apply(sourceImage); myFilter = new HomogenityEdgeDetector(); filteredImage = myFilter.Apply(sourceImage); } else if (filter == Filters.filters["Sobel"]) { sourceImage = Grayscale.CommonAlgorithms.RMY.Apply(sourceImage); myFilter = new SobelEdgeDetector(); filteredImage = myFilter.Apply(sourceImage); } else if (filter == Filters.filters["Jitter"]) { myFilter = new Jitter(); //Needs Expand filteredImage = myFilter.Apply(sourceImage); } else if (filter == Filters.filters["OilPainting"]) { sourceImage = ImageUtil.convert(sourceImage, System.Drawing.Imaging.PixelFormat.Format24bppRgb); myFilter = new OilPainting(); //Needs Expand filteredImage = myFilter.Apply(sourceImage); } else if (filter == Filters.filters["TextureFiltering"]) { sourceImage = ImageUtil.convert(sourceImage, System.Drawing.Imaging.PixelFormat.Format24bppRgb); myFilter = new Texturer(new TextileTexture(), 1.0, 0.8); //Needs Expand filteredImage = myFilter.Apply(sourceImage); } else if (filter == Filters.filters["Median"]) { sourceImage = ImageUtil.convert(sourceImage, System.Drawing.Imaging.PixelFormat.Format24bppRgb); myFilter = new Median(); filteredImage = myFilter.Apply(sourceImage); } else if (filter == Filters.filters["Mean"]) { myFilter = new Mean(); filteredImage = myFilter.Apply(sourceImage); } else if (filter == Filters.filters["Blur"]) { myFilter = new GaussianBlur(); filteredImage = myFilter.Apply(sourceImage); } //Console.Write(filteredImage.PixelFormat.ToString()); //Console.Write(sourceImage.PixelFormat.ToString()); filteredImage = ImageUtil.convert(filteredImage, System.Drawing.Imaging.PixelFormat.Format32bppArgb); return(filteredImage); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { Bitmap sourceImage = null; DA.GetData(0, ref sourceImage); string filter = ""; DA.GetData(1, ref filter); sourceImage = ImageUtilities.convert(sourceImage, System.Drawing.Imaging.PixelFormat.Format32bppArgb); IFilter myFilter; Bitmap filteredImage = sourceImage; //Grayscale.CommonAlgorithms.Y.Apply switch (filter) { case "Greyscale": Console.Write("Applying: " + filter); sourceImage = Grayscale.CommonAlgorithms.RMY.Apply(sourceImage); filteredImage = sourceImage; break; case "Sepia": Console.Write("Applying: " + filter); myFilter = new Sepia(); filteredImage = myFilter.Apply(sourceImage); break; case "Invert": Console.Write("Applying: " + filter); sourceImage = ImageUtilities.convert(sourceImage, System.Drawing.Imaging.PixelFormat.Format24bppRgb); myFilter = new Invert(); filteredImage = myFilter.Apply(sourceImage); break; case "RotateChannel": Console.Write("Applying: " + filter); myFilter = new RotateChannels(); filteredImage = myFilter.Apply(sourceImage); break; case "Threshold": //Need Extended Version Console.Write("Applying: " + filter); sourceImage = Grayscale.CommonAlgorithms.RMY.Apply(sourceImage); myFilter = new Threshold(); filteredImage = myFilter.Apply(sourceImage); break; case "FloydFilter": Console.Write("Applying: " + filter); //sourceImage = Grayscale.CommonAlgorithms.RMY.Apply(sourceImage); //myFilter = new FloydSteinbergColorDithering(); FloydSteinbergColorDithering myReduction = new FloydSteinbergColorDithering(); filteredImage = myReduction.Apply(sourceImage); //filteredImage = myFilter.Apply(sourceImage); break; case "OrderedDithering": Console.Write("Applying: " + filter); sourceImage = Grayscale.CommonAlgorithms.RMY.Apply(sourceImage); myFilter = new OrderedDithering(); filteredImage = myFilter.Apply(sourceImage); break; case "Sharpen": Console.Write("Applying: " + filter); myFilter = new Sharpen(); filteredImage = myFilter.Apply(sourceImage); break; case "DifferenceEdgeDetector": Console.Write("Applying: " + filter); sourceImage = Grayscale.CommonAlgorithms.RMY.Apply(sourceImage); myFilter = new DifferenceEdgeDetector(); filteredImage = myFilter.Apply(sourceImage); break; case "HomogenityEdgeDetector": Console.Write("Applying: " + filter); sourceImage = Grayscale.CommonAlgorithms.RMY.Apply(sourceImage); myFilter = new HomogenityEdgeDetector(); filteredImage = myFilter.Apply(sourceImage); break; case "Sobel": Console.Write("Applying: " + filter); sourceImage = Grayscale.CommonAlgorithms.RMY.Apply(sourceImage); myFilter = new SobelEdgeDetector(); filteredImage = myFilter.Apply(sourceImage); break; case "Jitter": Console.Write("Applying: " + filter); myFilter = new Jitter(); //Needs Expand filteredImage = myFilter.Apply(sourceImage); break; case "OilPainting": Console.Write("Applying: " + filter); myFilter = new OilPainting(); //Needs Expand filteredImage = myFilter.Apply(sourceImage); break; case "TextureFiltering": Console.Write("Applying: " + filter); sourceImage = ImageUtilities.convert(sourceImage, System.Drawing.Imaging.PixelFormat.Format24bppRgb); myFilter = new Texturer(new TextileTexture(), 1.0, 0.8); //Needs Expand filteredImage = myFilter.Apply(sourceImage); break; case "Median": Console.Write("Applying: " + filter); myFilter = new Median(); filteredImage = myFilter.Apply(sourceImage); break; case "Mean": Console.Write("Applying: " + filter); myFilter = new Mean(); filteredImage = myFilter.Apply(sourceImage); break; case "Blur": //Need Extended Version Console.Write("Applying: " + filter); myFilter = new GaussianBlur(); filteredImage = myFilter.Apply(sourceImage); break; default: Console.Write("No Filter"); break; } Console.Write(filteredImage.PixelFormat.ToString()); Console.Write(sourceImage.PixelFormat.ToString()); filteredImage = ImageUtilities.convert(filteredImage, System.Drawing.Imaging.PixelFormat.Format32bppArgb); DA.SetData(0, filteredImage); }
public static Bitmap Sharpen(Bitmap sourceImage) { var filter = new Sharpen(); return(filter.Apply(sourceImage)); }
public static Bitmap ApplySharpenFilter(Bitmap input) { Sharpen sharpenFilter = new Sharpen(); return(sharpenFilter.Apply(input)); }