예제 #1
0
 private void uxSharpen_Click(object sender, EventArgs e)
 {
     if (_currentImageHolder != null)
     {
         ImageForm.ShowImageDialog("Sharpen", _currentImageHolder.Sharpen());
     }
 }
예제 #2
0
        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);
                        }
                    }
                }
            }
        }