Wolf Jolion Threshold.
Inheritance: BaseFilter
        public void Binarize(object sender, DoWorkEventArgs e)
        {
            Bitmap InputImage = null;

            if (inPutRb.Checked)
            {
                InputImage = Accord.Imaging.Filters.Grayscale.CommonAlgorithms.BT709.Apply((Bitmap)input_PB.Image.Clone());
            }
            else if (outPutRB.Checked)
            {
                InputImage = (Bitmap)outputImageBox.Image.Clone();
            }
            if (wolfRb.Checked)
            {
                var wolfFilter = new Accord.Imaging.Filters.WolfJolionThreshold();
                if (holderTb_1.Text != String.Empty)
                {
                    wolfFilter.K = double.Parse(holderTb_1.Text);
                }
                if (holderTb_2.Text != String.Empty)
                {
                    wolfFilter.R = double.Parse(holderTb_2.Text);
                }
                if (holderTb_3.Text != String.Empty)
                {
                    wolfFilter.Radius = int.Parse(holderTb_3.Text);
                }
                Bitmap raw_img = InputImage;

                UnmanagedImage res = wolfFilter.Apply(UnmanagedImage.FromManagedImage(raw_img));
                outputImageBox.Image.Dispose();
                outputImageBox.Image = res.ToManagedImage();
            }
            else if (simpleThresh.Checked)
            {
                int Thresh       = int.Parse(holderTb_1.Text);
                var simpleThresh = new Threshold();
                simpleThresh.ThresholdValue = Thresh;
                Bitmap raw_img = InputImage;

                UnmanagedImage res = simpleThresh.Apply(UnmanagedImage.FromManagedImage(raw_img));
                outputImageBox.Image.Dispose();
                outputImageBox.Image = res.ToManagedImage();
            }
            else if (OtsuRb.Checked)
            {
                int Thresh     = int.Parse(holderTb_1.Text);
                var OtsuThresh = new Threshold();
                OtsuThresh.ThresholdValue = Thresh;
                Bitmap raw_img = InputImage;

                UnmanagedImage res = OtsuThresh.Apply(UnmanagedImage.FromManagedImage(raw_img));
                outputImageBox.Image.Dispose();
                outputImageBox.Image = res.ToManagedImage();
            }
        }
Example #2
0
        private void SetFilter()
        {
            ImageType = ImageTypes.GrayscaleBT709;
            Af.WolfJolionThreshold newFilter = new Af.WolfJolionThreshold();
            newFilter.K      = k;
            newFilter.R      = Remap(r, 0, 255);
            newFilter.Radius = radius;

            imageFilter = newFilter;
        }