Пример #1
0
 private void filtergray_Click(object sender, EventArgs e)
 {//Grayscale Pictures Colors
     if (BitmapFilter.GrayScale(image))
     {
         this.Invalidate();
     }
 }
Пример #2
0
 private void filterinvert_Click(object sender, EventArgs e)
 {//Inverts Pictures Colors
     if (BitmapFilter.Invert(image))
     {
         this.Invalidate();
     }
 }
Пример #3
0
        public FrameByteBrightnessContrast(int brigtness, int contrast, bool preProcessFrames, int bitPix)
            : base(preProcessFrames, bitPix)
        {
            m_Brigtness = brigtness;
            m_Contrast  = (sbyte)contrast;

            uint maxPixelValue = bitPix.GetMaxValueForBitPix();

            Trace.Assert(maxPixelValue <= int.MaxValue, "32bit images not supported.");

            Pixelmap image = new Pixelmap((int)maxPixelValue + 1, 1, bitPix, new uint[maxPixelValue + 1], null, null);
            {
                for (int i = 0; i <= maxPixelValue; i++)
                {
                    image[i, 0] = (uint)i;
                }

                BitmapFilter.Brightness(image, m_Brigtness);
                BitmapFilter.Contrast(image, m_Contrast);

                for (int i = 0; i <= maxPixelValue; i++)
                {
                    m_MappedBytes[i] = image[i, 0];
                }
            }
        }
Пример #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (groupBox2.Controls.Count > 1)
            {
                groupBox3.Dispose();
            }
            try
            {
                oput      = Math.Sqrt(Convert.ToInt32(textBox3.Text));
                output    = (int)oput;
                iteration = Convert.ToInt32(textBox1.Text);
                epsilon   = Convert.ToDouble(textBox2.Text);

                nn = new NeuralNetwork(output, iteration, epsilon, (Functions)function);
                OpenFileDialog ofd = new OpenFileDialog();
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    fileName = ofd.FileName;
                    nn.ReadDataFromFile(ofd.FileName);
                    nn.Normalize = true;
                    nn.StartLearning();
                    Bitmap img = new Bitmap(output, output);
                    colorM = nn.ColorSOFM();
                    for (int i = 0; i < colorM.GetLength(0); i++)
                    {
                        for (int j = 0; j < colorM.GetLength(1); j++)
                        {
                            Color  d;
                            string c = colorM[i, j].Name;
                            if (c == "ButtonFace")
                            {
                                d = Color.FromArgb(255, 226, 232, 232);
                            }
                            else
                            {
                                d = Color.FromName(c);
                            }
                            img.SetPixel(j, i, d);
                        }
                    }

                    Bitmap img2 = new Bitmap(img);
                    BitmapFilter.Scale(ref img, ref img2, output * 20, output * 20);
                    pictureBox1.Image  = img2;
                    pictureBox1.Paint += new PaintEventHandler(AddLinesPaint);
                    CreateLegendGroup();
                    AddInputValues();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Input error!", "FATAL ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                textBox1.Text = textBox2.Text = textBox3.Text = "";
                foreach (RadioButton a in groupBox1.Controls.OfType <RadioButton>())
                {
                    a.Checked = false;
                }
            }
        }
Пример #5
0
 public Form1()
 {
     InitializeComponent();
     loaded = new Bitmap(@"C:\Users\dell\Downloads\coins1.jpg");
     BitmapFilter.Scale(ref loaded, ref processed, 251, 332);
     loaded            = processed;
     pictureBox1.Image = loaded;
 }
Пример #6
0
        private void Blur(Panel panel, PictureBox p)
        {
            Bitmap bmp = Screenshot.TakeSnapshot(panel);

            BitmapFilter.GaussianBlur(bmp, 4);

            p.Image = bmp;
            p.BringToFront();
        }
Пример #7
0
        public void ProcessIntTest()
        {
            BitmapFilter test = new BitmapFilter();

            test.SetMask(new int[, ] {
                { 1, 1, 1 }, { 1, 2, 1 }, { 1, 1, 1 }
            });
            Assert.IsNull(test.ProcessInt(null));
            Assert.IsNotNull(test.ProcessInt(new int[1000, 10000]));
        }
Пример #8
0
            public static bool MeanRemoval(Bitmap bitmap, int nWeight)
            {
                ConvMatrix m = new ConvMatrix();

                m.SetAll(-1);
                m.Pixel  = nWeight;
                m.Factor = nWeight - 8;

                return(BitmapFilter.Conv3x3(bitmap, m));
            }
Пример #9
0
            public static bool Smooth(Bitmap bitmap, int nWeight)
            {
                ConvMatrix m = new ConvMatrix();

                m.SetAll(1);
                m.Pixel  = nWeight;
                m.Factor = nWeight + 8;

                return(BitmapFilter.Conv3x3(bitmap, m));
            }
Пример #10
0
        private void grayScaleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Bitmap currentBitmap = (Bitmap)drawingCanvas.Contents;

            if (BitmapFilter.GrayScale(currentBitmap))
            {
                drawingCanvas.Contents = currentBitmap;
                this.Invalidate();
            }
        }
Пример #11
0
        private async void CampoBatalla_LoadAsync(object sender, EventArgs e)
        {
            picxClose.BackgroundImageLayout = ImageLayout.Stretch;

            panel1.BackColor = Color.FromArgb(100, 44, 62, 80);

            await Task.Delay(500);

            Bitmap bmp = Screenshot.TakeSnapshot(panel1);

            BitmapFilter.GaussianBlur(bmp, 4);

            pb.Image = bmp;
            pb.Dock  = DockStyle.Fill;
            pb.BringToFront();
            panel1.Controls.Add(pb);

            troyanos = Con.CargarListaTroyanos();
            griegos  = Con.CargarListaGriego();

            Troyano troyano1 = troyanos[1];
            Griego  griego1  = griegos[1];

            progressBarFuerzaGriego.Maximum = griego1.Fuerza;
            progressBarFuerzaGriego.Value   = griego1.Fuerza;

            progressBarFuerzaTroyano.Maximum = troyano1.Fuerza;
            progressBarFuerzaTroyano.Value   = troyano1.Fuerza;

            lblNumFuerzaG.Text = Convert.ToString(griego1.Fuerza);
            lblNumFuerzaT.Text = Convert.ToString(troyano1.Fuerza);

            string msgGriego =
                "IdGuerrero: " + griego1.IdGuerrero +
                "\nNombre: " + griego1.Nombre +
                "\nEdad: " + griego1.Edad +
                "\nFuerza: " + griego1.Fuerza +
                "\nAtaque: " + griego1.Ataque +
                "\nHerido: " + griego1.Herido +
                "\nMuerto: " + griego1.Muerto;

            string msgTroyano =
                "IdGuerrero: " + troyano1.IdGuerrero +
                "\nNombre: " + troyano1.Nombre +
                "\nEdad: " + troyano1.Edad +
                "\nFuerza: " + troyano1.Fuerza +
                "\nAtaque: " + troyano1.Ataque +
                "\nHerido: " + troyano1.Herido +
                "\nMuerto: " + troyano1.Muerto;



            lblMsgGriego.Text  = msgGriego;
            lblMsgTroyano.Text = msgTroyano;
        }
Пример #12
0
            public static bool Sharpen(Bitmap bitmap, int nWeight)
            {
                ConvMatrix m = new ConvMatrix();

                m.SetAll(0);
                m.Pixel  = nWeight;
                m.TopMid = m.MidLeft = m.MidRight = m.BottomMid = -2;
                m.Factor = nWeight - 8;

                return(BitmapFilter.Conv3x3(bitmap, m));
            }
Пример #13
0
            public static bool GaussianBlur(Bitmap bitmap, int nWeight)
            {
                ConvMatrix m = new ConvMatrix();

                m.SetAll(1);
                m.Pixel  = nWeight;
                m.TopMid = m.MidLeft = m.MidRight = m.BottomMid = 2;
                m.Factor = nWeight + 12;

                return(BitmapFilter.Conv3x3(bitmap, m));
            }
Пример #14
0
        public static T ApplyFilter <T>(this T e, BitmapFilter f) where T : DisplayObject
        {
            if (f != null)
            {
                var n = (DisplayObject)e;

                n.filters = new[] { f };
            }

            return(e);
        }
Пример #15
0
            public static bool EmbossLaplacian(Bitmap bitmap)
            {
                ConvMatrix m = new ConvMatrix();

                m.SetAll(-1);
                m.TopMid = m.MidLeft = m.MidRight = m.BottomMid = 0;
                m.Pixel  = 4;
                m.Offset = 127;

                return(BitmapFilter.Conv3x3(bitmap, m));
            }
Пример #16
0
            public static bool EdgeDetectQuick(Bitmap bitmap)
            {
                ConvMatrix m = new ConvMatrix();

                m.TopLeft    = m.TopMid = m.TopRight = -1;
                m.MidLeft    = m.Pixel = m.MidRight = 0;
                m.BottomLeft = m.BottomMid = m.BottomRight = 1;

                m.Offset = 127;

                return(BitmapFilter.Conv3x3(bitmap, m));
            }
Пример #17
0
        private void PrepareOsdArea(uint[] dataIn, uint[] dataOut, uint[] dataDebugNoLChD, int width, int height)
        {
            //DebugPrepareOsdArea(dataIn, dataOut, width, height);
            //return;

            // Split into fields only in the region where IOTA-VTI could be, Then threat as two separate images, and for each of them do:
            // 1) Gaussian blur (small) BitmapFilter.LOW_PASS_FILTER_MATRIX
            // 2) Sharpen BitmapFilter.SHARPEN_MATRIX
            // 3) Binarize - get Average, all below change to 0, all above change to Max (256)
            // 4) De-noise BitmapFilter.DENOISE_MATRIX

            if (m_UseNativePreProcessing)
            {
                TangraCore.PrepareImageForOCR(dataIn, dataOut, width, height);
            }
            else
            {
                uint median = dataIn.Median();
                for (int i = 0; i < dataIn.Length; i++)
                {
                    int darkCorrectedValue = (int)dataIn[i] - (int)median;
                    if (darkCorrectedValue < 0)
                    {
                        darkCorrectedValue = 0;
                    }
                    dataIn[i] = (uint)darkCorrectedValue;
                }

                uint[] blurResult = BitmapFilter.GaussianBlur(dataIn, 8, width, height);

                uint   average       = 128;
                uint[] sharpenResult = BitmapFilter.Sharpen(blurResult, 8, width, height, out average);

                // Binerize and Inverse
                for (int i = 0; i < sharpenResult.Length; i++)
                {
                    sharpenResult[i] = sharpenResult[i] > average ? (uint)0 : (uint)255;
                }

                uint[] denoised = BitmapFilter.Denoise(sharpenResult, 8, width, height, out average, false);

                for (int i = 0; i < denoised.Length; i++)
                {
                    dataOut[i] = denoised[i] < 127 ? (uint)0 : (uint)255;
                }

                Array.Copy(dataOut, dataDebugNoLChD, dataOut.Length);

                LargeChunkDenoiser.Process(false, dataOut, width, height);
            }
        }
Пример #18
0
        private void filtercontrast_Click(object sender, EventArgs e)
        {//Contrasts Pictures Colors
            Parameter dlg = new Parameter();

            dlg.nValue = 0;

            if (DialogResult.OK == dlg.ShowDialog())
            {
                if (BitmapFilter.Contrast(image, (sbyte)dlg.nValue))
                {
                    this.Invalidate();
                }
            }
        }
Пример #19
0
        private void filterbrightness_Click(object sender, EventArgs e)
        {//Brightness Correction
            Parameter dlg = new Parameter();

            dlg.nValue = 0;

            if (DialogResult.OK == dlg.ShowDialog())
            {
                if (BitmapFilter.Brightness(image, dlg.nValue))
                {
                    this.Invalidate();
                }
            }
        }
Пример #20
0
        private void filtercolor_Click(object sender, EventArgs e)
        {//Color Correction
            ColorInput dlg = new ColorInput();

            dlg.red = dlg.green = dlg.blue = 0;

            if (DialogResult.OK == dlg.ShowDialog())
            {
                if (BitmapFilter.Color(image, dlg.red, dlg.green, dlg.blue))
                {
                    this.Invalidate();
                }
            }
        }
Пример #21
0
 public ActionResult view()
 {
     var file = Request.Files[0] as HttpPostedFileBase;
     BinaryReader br = new BinaryReader(file.InputStream);
     byte[] imageBytes = br.ReadBytes(file.ContentLength);
     filter = new BitmapFilter(imageBytes);
     ImageData data = new ImageData()
     {
         Image = filter.Image,
         Height = filter.Height,
         Width = filter.Width
     };
     return View(data);
 }
Пример #22
0
        void takeScreenShot()
        {
            this.Opacity = 0;
            this.Refresh();
            Bitmap temp = GetScreenBitmap(this.Width, this.Height, this.Location.X, this.Location.Y);

            this.Opacity = 100;
            this.Refresh();
            for (int i = 0; i < blurAmount; i++)
            {
                BitmapFilter.GaussianBlur(temp, 4);
            }
            this.pictureBox1.Image = temp;
            this.pictureBox1.Refresh();
        }
Пример #23
0
 public void OnPreProcess(Pixelmap newFrame)
 {
     if (m_PreProcessFrames &&
         newFrame != null)
     {
         if (m_Filter == TangraConfig.PreProcessingFilter.LowPassFilter)
         {
             BitmapFilter.LowPassFilter(newFrame);
         }
         else if (m_Filter == TangraConfig.PreProcessingFilter.LowPassDifferenceFilter)
         {
             BitmapFilter.LowPassDifference(newFrame);
         }
     }
 }
Пример #24
0
 private void button1_Click(object sender, EventArgs e)
 {
     BitmapFilter.Contrast(pirst, 100);
     progressBar1.Value += 2;
     BitmapFilter.GaussianBlur(pirst, 10);
     progressBar1.Value += 3;
     BitmapFilter.GrayScale(pirst);
     progressBar1.Value += 2;
     BitmapFilter.Threshold(ref pirst, ref sekond, 235);
     progressBar1.Value += 15;
     read();
     label1.Text       = "Done";
     pictureBox2.Image = sekond;
     show();
 }
Пример #25
0
        private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = @"Bitmap文件(*.bmp)|*.bmp|Jpeg文件(*.jpg)|*.jpg|所有合适文件(*.bmp;*.jpg)|*.bmp;*.jpg|所有文件(*.*)|*.*";
            openFileDialog.FilterIndex      = 2;
            openFileDialog.RestoreDirectory = true;
            if (DialogResult.OK == openFileDialog.ShowDialog())
            {
                m_Bitmap               = (Bitmap)Bitmap.FromFile(openFileDialog.FileName, false);
                m_Bitmap               = BitmapFilter.Resize(m_Bitmap, 295, 413, true);
                this.AutoScroll        = true;
                this.AutoScrollMinSize = new Size(m_Bitmap.Width, m_Bitmap.Height);
                this.Invalidate();
            }
        }
Пример #26
0
 protected override void OnPaint(PaintEventArgs e)
 {
     if (_points != null)
     {
         //first get max count to even the spread.
         int max = 0;
         foreach (KeyValuePair <Point, int> p in _points)
         {
             if (p.Value > max)
             {
                 max = p.Value;
             }
         }
         //linear spread for colors - blue = cold, yellow = warm, red = hot
         Brush[] brushes = new Brush[max];
         for (int i = 1; i <= max; i++)
         {
             brushes[i - 1] = new SolidBrush(ComputeColor((float)i / max));
         }
         //paint the dots!
         using (Bitmap b = new Bitmap(Width, Height, e.Graphics))
         {
             Graphics g = Graphics.FromImage(b);
             g.Clear(Color.Blue);
             //draw all, lowest first, then to highest
             for (int i = 1; i <= max; i++)
             {
                 foreach (KeyValuePair <Point, int> p in _points)
                 {
                     if (p.Value == i)
                     {
                         g.FillEllipse(brushes[p.Value - 1], p.Key.X - HALF_CIRCLE_SIZE, p.Key.Y - HALF_CIRCLE_SIZE, CIRCLE_SIZE, CIRCLE_SIZE);
                     }
                 }
             }
             //blur the hell outta it
             BitmapFilter.GaussianBlur(b, 10);
             BitmapFilter.GaussianBlur(b, 10);
             BitmapFilter.GaussianBlur(b, 10);
             BitmapFilter.GaussianBlur(b, 10);
             BitmapFilter.GaussianBlur(b, 10);
             BitmapFilter.GaussianBlur(b, 10);
             //draw it on the form
             e.Graphics.DrawImage(b, new Point(0, 0));
         }
     }
 }
Пример #27
0
        public MySoundDemo()
        {
            Text   = "Howdy!";
            Color  = 0x00ffff00;
            Filter = new DropShadowFilter();

            "assets/MySoundDemo/world.mp3".PlaySoundLoop();



            for (var j = 0.0; j < 1; j += 0.1)
            {
                this.graphics.beginFill(0xff0000, j);
                this.graphics.drawCircle(40, 40, 40 * (1.0 - j));
                this.graphics.endFill();
            }


            DrawHelloWorld(50);



            addChild(
                new TextField
            {
                text       = "powered by jsc",
                x          = 20,
                y          = 40,
                selectable = false,
                sharpness  = -400,
                textColor  = 0xffffff,
                filters    = new [] { new BlurFilter() }
            }
                );

            addChild(
                new TextField
            {
                text       = "powered by jsc",
                x          = 20,
                y          = 40,
                selectable = false,
                textColor  = 0xffffff,
            }
                );
        }
Пример #28
0
        private async void NuevoGuerrero_LoadAsync(object sender, EventArgs e)
        {
            BackgroundImageLayout = ImageLayout.Stretch;

            panel1.BackColor = Color.FromArgb(100, 44, 62, 80);

            await Task.Delay(500);

            Bitmap bmp = Screenshot.TakeSnapshot(panel1);

            BitmapFilter.GaussianBlur(bmp, 4);

            pb.Image = bmp;
            pb.Dock  = DockStyle.Fill;
            pb.BringToFront();
            panel1.Controls.Add(pb);
        }
Пример #29
0
        public uint[,] OnPreProcessPixels(uint[,] pixels)
        {
            if (m_PreProcessFrames &&
                pixels != null)
            {
                if (m_Filter == TangraConfig.PreProcessingFilter.LowPassFilter)
                {
                    pixels = BitmapFilter.LowPassFilter(pixels, m_Bpp);
                }
                else if (m_Filter == TangraConfig.PreProcessingFilter.LowPassDifferenceFilter)
                {
                    pixels = BitmapFilter.LowPassDifferenceFilter(pixels, m_Bpp, false);
                }
            }

            return(pixels);
        }
Пример #30
0
        public MySoundDemo()
        {
            Text = "Howdy!";
            Color = 0x00ffff00;
            Filter = new DropShadowFilter();

            "assets/MySoundDemo/world.mp3".PlaySoundLoop();



            for (var j = 0.0; j < 1; j += 0.1)
            {
                this.graphics.beginFill(0xff0000, j);
                this.graphics.drawCircle(40, 40, 40 * (1.0 - j));
                this.graphics.endFill();
            }


            DrawHelloWorld(50);



            addChild(
                    new TextField
                    {
                        text = "powered by jsc",
                        x = 20,
                        y = 40,
                        selectable = false,
                        sharpness = -400,
                        textColor = 0xffffff,
                        filters = new [] { new BlurFilter() }
                    }
                );

            addChild(
                new TextField
                {
                    text = "powered by jsc",
                    x = 20,
                    y = 40,
                    selectable = false,
                    textColor = 0xffffff,
                }
            );
        }
Пример #31
0
        private async void Index_LoadAsync(object sender, EventArgs e)
        {
            btnHistoricoPartidos.Enabled = false;
            btnHistoricoPartidos.Visible = false;

            BackgroundImageLayout = ImageLayout.Stretch;

            panel1.BackColor = Color.FromArgb(100, 44, 62, 80);

            await Task.Delay(500);

            Bitmap bmp = Screenshot.TakeSnapshot(panel1);

            BitmapFilter.GaussianBlur(bmp, 4);

            pb.Image = bmp;
            pb.Dock  = DockStyle.Fill;
            pb.BringToFront();
            panel1.Controls.Add(pb);
        }
Пример #32
0
        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            string picName = "Pattern" + noPattern;

            Bitmap originalImage = new Bitmap(openFileDialog1.FileName);
            Bitmap image2        = new Bitmap(10, 10);
            Bitmap temp          = new Bitmap(originalImage);

            BitmapFilter.Scale(ref temp, ref image2, 150, 150);

            CreatePictureBox(picName, image2, originalImage);
            noPattern++;


            runNetworkDynamicToolStripMenuItem.Enabled = true;

            UpdateValue();


            //addPatternOnRemoveMenu(picName);
        }
Пример #33
0
 /// <summary>
 /// Takes a source image and a filter object and generates the filtered image.
 /// </summary>
 public void applyFilter(BitmapData sourceBitmapData, Rectangle sourceRect, Point destPoint, BitmapFilter filter)
 {
 }
Пример #34
0
 public Rectangle generateFilterRect(Rectangle source, BitmapFilter filter)
 {
     return source;
 }
Пример #35
0
 /// <summary>
 /// Determines the destination rectangle that the applyFilter() method call affects, given a BitmapData object, a source rectangle, and a filter object.
 /// </summary>
 public Rectangle generateFilterRect(Rectangle sourceRect, BitmapFilter filter)
 {
     return default(Rectangle);
 }
Пример #36
0
 public void applyFilter(BitmapData sourceBitmapData, Rectangle sourceRectangle, Point destination, BitmapFilter filter)
 {
     return;
 }
Пример #37
0
        public MySoundDemo2()
        {
            Text = "Howdy!";
            Color = 0x00ffff00;
            Filter = new DropShadowFilter();


            

            var preview = Assets.Preview;

            preview.x = 100;
            preview.y = 100;
            var front = new TextField
                {
                    text = "powered by jsc",
                    x = 20,
                    y = 40,
                    selectable = false,
                    textColor = 0xffffff,
                };

            front.mouseOver += ev => front.textColor = 0x00ff0000;

            front.mouseOut += ev => front.textColor = 0xffffff;

            var timer = new Timer(10, 0);


            preview.rotation = 45;


            timer.timer +=
                ev =>
                {
                    preview.rotation++;
                };

           // timer.start();

            preview.filters = new[] { new BlurFilter() };
            addChild(preview);




            for (var j = 0.0; j < 1; j += 0.1)
            {
                this.graphics.beginFill(0xff0000, j);
                this.graphics.drawCircle(40, 40, 40 * (1.0 - j));
                this.graphics.endFill();
            }


            DrawHelloWorld(50);



            addChild(
                    new TextField
                    {
                        text = "powered by jsc",
                        x = 20,
                        y = 40,
                        selectable = false,
                        sharpness = -400,
                        textColor = 0xffffff,
                        filters = new[] { new BlurFilter() }
                    }
                );

            addChild(
           front
            );


            var snd = Assets.world;
            var channel = default(SoundChannel);

            stage.activate +=
                delegate
                {
                    channel = snd.play(0, 999);
                    timer.start();
                };

            stage.deactivate +=
                delegate
                {
                    if (channel != null)
                    {
                        channel.stop();
                        channel = null;
                    }

                    timer.stop();
                };
        }