private void uxSharpen_Click(object sender, EventArgs e) { if (_currentImageHolder != null) { ImageForm.ShowImageDialog("Sharpen", _currentImageHolder.Sharpen()); } }
public void RunThreshold(int threshold, bool showGrayScale) { using (Bitmap newBitmap = LoadBitmap()) { Rectangle rect = new Rectangle(0, 0, newBitmap.Width, newBitmap.Height); using (UnmanagedImage image = new UnmanagedImage(newBitmap.LockBits(rect, ImageLockMode.ReadWrite, newBitmap.PixelFormat))) { using (UnmanagedImage grayImage = UnmanagedImage.Create(image.Width, image.Height, PixelFormat.Format8bppIndexed)) { Grayscale.CommonAlgorithms.BT709.Apply(image, grayImage); if (showGrayScale) { ImageForm.ShowImageDialog("Gray scale", grayImage); } Threshold thresholdFilter = new Threshold(threshold); using (UnmanagedImage thresholdImage = thresholdFilter.Apply(grayImage)) { ImageForm.ShowImageDialog("Threshold", thresholdImage); } } } } }