Beispiel #1
0
        private void RGBFilter_Clicked(object sender, RoutedEventArgs e)
        {
            if (mainPhoto != null)
            {
                chf = new ChannelFiltering();

                // set channels' ranges to keep
                chf.Red   = new AForge.IntRange(int.Parse(RedIn.Text), int.Parse(RedOut.Text));
                chf.Green = new AForge.IntRange(int.Parse(GreenIn.Text), int.Parse(GreenOut.Text));
                chf.Blue  = new AForge.IntRange(int.Parse(BlueIn.Text), int.Parse(BlueOut.Text));

                // apply the filter
                System.Drawing.Bitmap tmp = chf.Apply((System.Drawing.Bitmap)mainPhoto.Clone());
                //BitmapImage tmpBmpIs = ToBitmapImage(tmp);

                /*RenderTargetBitmap rtb = new RenderTargetBitmap((int)Photography.ActualWidth, (int)Photography.ActualHeight, mainPhoto.HorizontalResolution, mainPhoto, PixelFormats.Pbgra32);
                 * rtb.Render(Photography);
                 *
                 * PngBitmapEncoder png = new PngBitmapEncoder();
                 * png.Frames.Add(BitmapFrame.Create(rtb));
                 * MemoryStream stream = new MemoryStream();
                 * png.Save(stream);
                 * System.Drawing.Bitmap image = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(stream);*/

                Photography.Source = ToBitmapImage(tmp);

                UpdateHistograms(tmp);
                UpdateChannelPreviews(tmp);
            }
        }
Beispiel #2
0
        Bitmap Filter(Bitmap bitmap, MarkerColor color)
        {
            var filter = new ChannelFiltering();

            filter.Red = filter.Green = filter.Blue = new IntRange(0, 0);

            switch (color)
            {
            case MarkerColor.Red:
                filter.Red = new IntRange(0, 255);
                break;

            case MarkerColor.Green:
                filter.Green = new IntRange(0, 255);
                break;

            case MarkerColor.Blue:
                filter.Blue = new IntRange(0, 255);
                break;

            case MarkerColor.White:
                filter.Red   = new IntRange(0, 255);
                filter.Green = new IntRange(0, 255);
                filter.Blue  = new IntRange(0, 255);
                break;

            default:
                throw new NotImplementedException();
            }

            return(filter.Apply(bitmap));
        }
Beispiel #3
0
        public Bitmap RedMask(Bitmap img)
        {
            ChannelFiltering filter = new ChannelFiltering();

            filter.Red   = new AForge.IntRange(0, 255);
            filter.Green = new AForge.IntRange(100, 255);
            filter.Blue  = new AForge.IntRange(100, 255);
            return(filter.Apply(img));
        }
Beispiel #4
0
        private void process_button_Click(object sender, EventArgs e)
        {
            //changes are made here

            // Channel filtering is more towards saturated range, it is focusing on whole channel
            var channelFilter = new ChannelFiltering();

            channelFilter.Red   = new AForge.IntRange(120, 229);
            channelFilter.Green = new AForge.IntRange(80, 221);
            channelFilter.Blue  = new AForge.IntRange(120, 183);
            var channelFilterOutput = channelFilter.Apply(_inputImage);

            pictureBoxOutput.Image = channelFilterOutput;
        }
Beispiel #5
0
 public static Bitmap getAzul(Bitmap image)
 {
     try
     {
         AForge.Imaging.Filters.ChannelFiltering filter = new ChannelFiltering(new IntRange(0, 0), new IntRange(0, 0), new IntRange(0, 255));
         System.Drawing.Bitmap newImage = filter.Apply(image);
         return(newImage);
     }
     catch (ArgumentException ex)
     {
         MessageBox.Show("No se puede apllicar el filtro" + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(null);
     }
 }
Beispiel #6
0
        private void applyfilter(int a, int b, int c)
        {
            copyimg = copyimg1;
            ChannelFiltering filter = new ChannelFiltering();

            filter.Red   = new IntRange(a, 255);
            filter.Green = new IntRange(b, 255);
            filter.Blue  = new IntRange(c, 255);
            try
            {
                copyimg = filter.Apply(copyimg);
                MainForm.getMainForm.pictureBox1ImagePreview.Image = copyimg;
            }
            catch (Exception ex)
            { }
        }
Beispiel #7
0
        // New frame event handler, which is invoked on each new available video frame
        private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            Invoke((MethodInvoker) delegate()
            {
                optChose = comboBox2.SelectedIndex;
            });

            Bitmap bmp    = (Bitmap)eventArgs.Frame.Clone();
            Bitmap bmpPrc = (Bitmap)eventArgs.Frame.Clone();

            switch (optChose)
            {
            case 0:
                Grayscale     filter0   = new Grayscale(0.2125, 0.7154, 0.0721);
                Bitmap        grayImage = filter0.Apply(bmpPrc);
                OtsuThreshold filter1   = new OtsuThreshold();
                pictureBox1.Image = bmp;
                pictureBox2.Image = filter1.Apply(grayImage);
                break;

            case 1:
                Sepia filter2 = new Sepia();
                pictureBox1.Image = bmp;
                pictureBox2.Image = filter2.Apply(bmpPrc);
                break;

            case 2:
                ChannelFiltering filter3 = new ChannelFiltering();
                filter3.Red       = new IntRange(0, 255);
                filter3.Green     = new IntRange(100, 255);
                filter3.Blue      = new IntRange(100, 255);
                pictureBox1.Image = bmp;
                pictureBox2.Image = filter3.Apply(bmpPrc);
                break;

            case 3:
                HSLFiltering filter4 = new HSLFiltering();
                filter4.Hue             = new IntRange(340, 20);
                filter4.UpdateLuminance = false;
                filter4.UpdateHue       = false;
                pictureBox1.Image       = bmp;
                pictureBox2.Image       = filter4.Apply(bmpPrc);
                break;
            }
        }