private void RenderImage()
        {
            if (radiusTrackBar.Value == 0 && sigmaTrackBar.Value == 0)
            {
                previewPictureBox.Image = image;
                okButton.Enabled        = false;
                return;
            }

            okButton.Enabled = true;
            int size  = radiusTrackBar.Value;
            int sigma = sigmaTrackBar.Value;

            switch (modeCB.SelectedIndex)
            {
            case 0:
                //резкость
                filter = new GaussianSharpenFilter(size, sigma);
                break;

            case 1:
                //размытие
                filter = new GaussianBlurFilter(size, sigma);
                break;
            }

            previewPictureBox.Image = filter.ApplyFilter(new List <Bitmap>()
            {
                image
            });
        }
 public EdgeDetectorForm(Bitmap image, AbstractFilter oldFilter)
 {
     InitializeComponent();
     this.image = image;
     if (oldFilter is HomogenityFilter)
     {
         homogenityRB.Checked = true;
     }
     else
     if (oldFilter is CannyFilter)
     {
         cannyRB.Checked = true;
     }
     else
     if (oldFilter is DifferenceFilter)
     {
         differenceRB.Checked = true;
     }
     else
     if (oldFilter is SobelFilter)
     {
         sobelRB.Checked = true;
     }
     else
     {
         throw new ArgumentException("Переданый тип фильтра не является фильтром определния границ");
     }
 }
Exemple #3
0
 //For initing first Node
 public Node(Bitmap input, AbstractFilter filter)
 {
     Input    = input;
     Filter   = filter;
     NodeType = NodeType.Image;
     Process();
 }
Exemple #4
0
 //For creating child nodes from other nodes
 public Node(List <Node> input, AbstractFilter filter)
 {
     InputNodes = input;
     Filter     = filter;
     NodeType   = NodeType.Filter;
     Process();
 }
        private void RenderImage()
        {
            if (!noFilterCB.Checked)
            {
                if (adaptiveRB.Checked)
                {
                    filter = new AdaptiveTresholdFilter();
                    previewPictureBox.Image = filter.ApplyFilter(new List <Bitmap>()
                    {
                        image
                    });
                }

                if (rangeRB.Checked)
                {
                    int min = thresholdSlider.Min;
                    int max = thresholdSlider.Max;
                    filter = new SimpleTresholdFilter(min, max);
                    previewPictureBox.Image = filter.ApplyFilter(new List <Bitmap>()
                    {
                        image
                    });
                }
            }
            else
            {
                previewPictureBox.Image = image;
            }
        }
Exemple #6
0
        public void AddFilter(AbstractFilter filter)
        {
            List <AbstractFilter> list = new List <AbstractFilter>(1)
            {
                filter
            };

            AddFilter(list);
        }
Exemple #7
0
        public IEnumerable <T> GetByFilter <T>(AbstractFilter filter)
        {
            if (filter == null)
            {
                throw new ArgumentException();
            }

            throw new NotImplementedException();
        }
Exemple #8
0
 private static AbstractFilter ContrastForm(Bitmap image, int value)
 {
     using (ContrastForm form = new ContrastForm(image, value, false)) {
         if (form.ShowDialog() == DialogResult.OK)
         {
             AbstractFilter newFilter = form.resultFilter;
             return(newFilter);
         }
         return(null);
     }
 }
        private void okButton_Click(object sender, EventArgs e)
        {
            if (contrastStretchCB.Checked)
            {
                resultFilter = new ContrastStretchFilter();
            }
            else
            {
                resultFilter = new ContrastFilter(valueTrackBar.Value);
            }

            DialogResult = DialogResult.OK;
        }
        private void applyButton_Click(object sender, EventArgs e)
        {
            if (adaptiveRB.Checked)
            {
                filter = new AdaptiveTresholdFilter();
            }

            if (rangeRB.Checked)
            {
                int min = thresholdSlider.Min;
                int max = thresholdSlider.Max;
                filter = new SimpleTresholdFilter(min, max);
            }

            DialogResult = DialogResult.OK;
        }
        private void okButton_Click(object sender, EventArgs e)
        {
            int size  = radiusTrackBar.Value;
            int sigma = sigmaTrackBar.Value;

            switch (modeCB.SelectedIndex)
            {
            case 0:
                //резкость
                filter = new GaussianSharpenFilter(size, sigma);
                break;

            case 1:
                //размытие
                filter = new GaussianBlurFilter(size, sigma);
                break;
            }

            DialogResult = DialogResult.OK;
        }
        private AbstractFilter GetFilter()
        {
            AbstractFilter tmpFilter = null;

            if (homogenityRB.Checked)
            {
                tmpFilter = new HomogenityFilter();
            }
            if (differenceRB.Checked)
            {
                tmpFilter = new DifferenceFilter();
            }
            if (sobelRB.Checked)
            {
                tmpFilter = new SobelFilter();
            }
            if (cannyRB.Checked)
            {
                tmpFilter = new CannyFilter();
            }
            return(tmpFilter);
        }
Exemple #13
0
        private void applyButton_Click(object sender, EventArgs e)
        {
            if (erodeRB.Checked)
            {
                filter = new ErodeFilter(DefaultMatrix3x3);
            }

            if (dilateRB.Checked)
            {
                filter = new DilateFilter(DefaultMatrix3x3);
            }

            if (openRB.Checked)
            {
                filter = new OpeningFilter(DefaultMatrix3x3);
            }

            if (closeRB.Checked)
            {
                filter = new ClosingFilter(DefaultMatrix3x3);
            }

            DialogResult = DialogResult.OK;
        }
Exemple #14
0
 public IEnumerable <T> GetByFilter <T>(AbstractFilter filter)
 {
     throw new NotImplementedException();
 }
Exemple #15
0
 public void Add(AbstractFilter filter)
 {
     FilterPreviewItems.Add(filter);
 }
Exemple #16
0
        public static bool ModifyFilter(int index)
        {
            Model.Node     selectedNode = ImageProcessingController.Instance.GetNode(index);
            AbstractFilter filter       = selectedNode.Filter;
            Type           t            = filter.GetType();

            /*
             #region Gaussian Blur Filter : Update
             * if (t == typeof(GaussianBlurFilter)) {
             *  GaussianBlurFilter updatedFilter = (GaussianBlurFilter)filter;
             *  updatedFilter = GaussianBlurForm(updatedFilter);
             *
             *  if (updatedFilter != null) {
             *      ImageProcessingController.Instance.GetNode(index).SetFilter(updatedFilter);
             *      return true;
             *  }
             * }
             #endregion
             *
             #region Gaussian Sharpen Filter : Update
             * if (t == typeof(GaussianSharpenFilter)) {
             *  GaussianSharpenFilter updatedFilter = (GaussianSharpenFilter)filter;
             *  updatedFilter = GaussianSharpenForm(updatedFilter);
             *
             *  if (updatedFilter != null) {
             *      ImageProcessingController.Instance.GetNode(index).SetFilter(updatedFilter);
             *      return true;
             *  }
             * }
             #endregion
             */

            /*
             #region Median Blur Filter : Update
             * if (t == typeof(MedianBlurFilter)) {
             *  MedianBlurFilter updatedFilter = (MedianBlurFilter)filter;
             *  updatedFilter = MedianBlurForm(updatedFilter);
             *
             *  if (updatedFilter != null) {
             *      ImageProcessingController.Instance.GetNode(index).SetFilter(updatedFilter);
             *      return true;
             *  }
             * }
             #endregion
             */

            #region Black White Filter : Update
            if (t == typeof(BlackWhiteFilter))
            {
                BlackWhiteFilter updatedFilter = (BlackWhiteFilter)filter;
                updatedFilter = BlackWhiteForm(selectedNode.Input, updatedFilter);

                if (updatedFilter != null)
                {
                    ImageProcessingController.Instance.GetNode(index).SetFilter(updatedFilter);
                    return(true);
                }
            }
            #endregion


            #region Brightness Filter
            if (t == typeof(BrightnessFilter))
            {
                BrightnessFilter updatedFilter = (BrightnessFilter)filter;
                updatedFilter = BrightnessForm(selectedNode.Input, updatedFilter.Value);

                if (updatedFilter != null)
                {
                    ImageProcessingController.Instance.GetNode(index).SetFilter(updatedFilter);
                    return(true);
                }
            }
            #endregion

            #region Contrast Filter
            if (t == typeof(ContrastFilter))
            {
                ContrastFilter oldFilter = (ContrastFilter)filter;
                AbstractFilter newFilter = ContrastForm(selectedNode.Input, oldFilter.Value);

                if (newFilter != null)
                {
                    ImageProcessingController.Instance.GetNode(index).SetFilter(newFilter);
                    return(true);
                }
            }
            #endregion

            #region Contrast Stretch Filter
            if (t == typeof(ContrastStretchFilter))
            {
                AbstractFilter updatedFilter = ContrastStretchForm(selectedNode.Input);

                if (updatedFilter != null)
                {
                    ImageProcessingController.Instance.GetNode(index).SetFilter(updatedFilter);
                    return(true);
                }
            }
            #endregion

            return(false);
        }
Exemple #17
0
 private void applyButton_Click(object sender, EventArgs e)
 {
     filter       = new EuclidColorFilter(colorWheel.Color, Convert.ToSByte(radiusTB.Value));
     DialogResult = DialogResult.OK;
 }
Exemple #18
0
 public void UpdateNode(AbstractFilter filter, int index)
 {
     Nodes[index].SetFilter(filter);
     Nodes[index].Process();
 }
Exemple #19
0
 public void AddNode(AbstractFilter filter)
 {
     Nodes.Add(new Node(new List <Node> {
         Nodes.Last()
     }, filter));
 }
Exemple #20
0
 public void AddFilters(AbstractFilter filter)
 {
     filters.Add(filter);
 }
Exemple #21
0
 public void SetFilter(AbstractFilter filter)
 {
     Filter = filter;
 }
 private void applyFilter_Click(object sender, EventArgs e)
 {
     filter = GetFilter();
 }
Exemple #23
0
 public void AddFilters(AbstractFilter filter)
 {
     filters.Add(filter);
 }