コード例 #1
0
        public static void ExtractRegionsDevice2(Bitmap frame1, Bitmap frame2)
        {
            frame1 = greyscaleFilter2.Apply(frame1);
            frame2 = greyscaleFilter2.Apply(frame2);
            lock (_lock2)
            {
                cropFilter2.Rectangle = Region3;
                ROI3 = circleFilter2.Apply(resizeFilter2.Apply(cropFilter2.Apply(frame1)));
                diffFilter2.OverlayImage = circleFilter2.Apply(resizeFilter2.Apply(cropFilter2.Apply(frame2)));
                ROI3Diff = diffFilter2.Apply(ROI3);
                subFilter2.OverlayImage = invertFilter2.Apply(threshFilter2.Apply(ROI3Diff));
                ROI3DropDiff            = subFilter2.Apply(ROI3Diff);

                cropFilter2.Rectangle = Region4;
                ROI4 = circleFilter2.Apply(resizeFilter2.Apply(cropFilter2.Apply(frame1)));
                diffFilter2.OverlayImage = circleFilter2.Apply(resizeFilter2.Apply(cropFilter2.Apply(frame2)));
                ROI4Diff = diffFilter2.Apply(ROI4);
                subFilter2.OverlayImage = invertFilter2.Apply(threshFilter2.Apply(ROI4Diff));
                ROI4DropDiff            = subFilter2.Apply(ROI4Diff);

                cropFilter2.Rectangle = Region7;
                ROI7 = circleFilter2.Apply(resizeFilter2.Apply(cropFilter2.Apply(frame1)));
                diffFilter2.OverlayImage = circleFilter2.Apply(resizeFilter2.Apply(cropFilter2.Apply(frame2)));
                ROI7Diff = diffFilter2.Apply(ROI7);
                subFilter2.OverlayImage = invertFilter2.Apply(threshFilter2.Apply(ROI7Diff));
                ROI7DropDiff            = subFilter2.Apply(ROI7Diff);

                cropFilter2.Rectangle = Region8;
                ROI8 = circleFilter2.Apply(resizeFilter2.Apply(cropFilter2.Apply(frame1)));
                diffFilter2.OverlayImage = circleFilter2.Apply(resizeFilter2.Apply(cropFilter2.Apply(frame2)));
                ROI8Diff = diffFilter2.Apply(ROI8);
                subFilter2.OverlayImage = invertFilter2.Apply(threshFilter2.Apply(ROI8Diff));
                ROI8DropDiff            = subFilter2.Apply(ROI8Diff);
            }
        }
コード例 #2
0
        public static void ExtractRegionImages1(Bitmap frame1, Bitmap frame2)
        {
            frame1 = greyscaleFilter1.Apply(frame1);
            frame2 = greyscaleFilter1.Apply(frame2);
            lock (_lock1)
            {
                cropFilter1.Rectangle = Region1;
                ROI1 = circleFilter2.Apply(resizeFilter1.Apply(cropFilter1.Apply(frame1)));
                diffFilter1.OverlayImage = circleFilter2.Apply(resizeFilter1.Apply(cropFilter1.Apply(frame2)));
                ROI1Diff = diffFilter1.Apply(ROI1);
                subFilter1.OverlayImage = invertFilter1.Apply(threshFilter1.Apply(ROI1Diff));
                ROI1DropDiff            = subFilter1.Apply(ROI1Diff);

                cropFilter1.Rectangle = Region2;
                ROI2 = circleFilter2.Apply(resizeFilter1.Apply(cropFilter1.Apply(frame1)));
                diffFilter1.OverlayImage = circleFilter2.Apply(resizeFilter1.Apply(cropFilter1.Apply(frame2)));
                ROI2Diff = diffFilter1.Apply(ROI2);
                subFilter1.OverlayImage = invertFilter1.Apply(threshFilter1.Apply(ROI2Diff));
                ROI2DropDiff            = subFilter1.Apply(ROI2Diff);

                cropFilter1.Rectangle = Region5;
                ROI5 = circleFilter2.Apply(resizeFilter1.Apply(cropFilter1.Apply(frame1)));
                diffFilter1.OverlayImage = circleFilter2.Apply(resizeFilter1.Apply(cropFilter1.Apply(frame2)));
                ROI5Diff = diffFilter1.Apply(ROI5);
                subFilter1.OverlayImage = invertFilter1.Apply(threshFilter1.Apply(ROI5Diff));
                ROI5DropDiff            = subFilter1.Apply(ROI5Diff);

                cropFilter1.Rectangle = Region6;
                ROI6 = circleFilter2.Apply(resizeFilter1.Apply(cropFilter1.Apply(frame1)));
                diffFilter1.OverlayImage = circleFilter2.Apply(resizeFilter1.Apply(cropFilter1.Apply(frame2)));
                ROI6Diff = diffFilter1.Apply(ROI6);
                subFilter1.OverlayImage = invertFilter1.Apply(threshFilter1.Apply(ROI6Diff));
                ROI6DropDiff            = subFilter1.Apply(ROI6Diff);
            }
        }
コード例 #3
0
ファイル: clsImagePlate.cs プロジェクト: thquan99/DoAn_Bienso
        //===================method=========================
        public void Get_Plate()
        {
            image_input     = IMAGE;
            backgroundFrame = new Bitmap(Application.StartupPath + "\\anh\\nen.jpg");
            hor_coe         = 0.6; //0.5
            ver_coe         = 0.4; //0.4
            number_coe      = 13;  //13
            min_freq        = 100;
            plate_ratio     = 14;  //14;

            IFilter filt = new GrayscaleY();

            backgroundFrame = filt.Apply(backgroundFrame);
            image_input     = filt.Apply(image_input);

            //IFilter f = new Threshold(180);
            //image_input = f.Apply(image_input);
            p = image_input;
            Subtract sub_img = new Subtract();

            sub_img.OverlayImage = backgroundFrame;
            Bitmap temp_img = sub_img.Apply(image_input);

            image_input = get_object(image_input, temp_img);
            image_input = fft(image_input);
            PLATE       = image_input;
        }
コード例 #4
0
        public Bitmap Subtract(Bitmap leftOperand, Bitmap rightOperand)
        {
            ResizeBilinear resize = new ResizeBilinear(leftOperand.Width, leftOperand.Height);

            rightOperand = resize.Apply(rightOperand);
            Subtract filter = new Subtract(rightOperand);

            return(filter.Apply(leftOperand));
        }
コード例 #5
0
        public mCompositeSubtract(Bitmap UnderlayBitmap, Bitmap OverlayBitmap)
        {
            BitmapUnder = new mSetFormat(UnderlayBitmap, mFilter.BitmapTypes.Rgb24bpp).ModifiedBitmap;
            BitmapOver  = new mSetFormat(OverlayBitmap, mFilter.BitmapTypes.Rgb24bpp).ModifiedBitmap;

            ModifiedBitmap = UnderlayBitmap;

            Effect = new Subtract(BitmapOver);

            ModifiedBitmap = Effect.Apply(BitmapUnder);
        }
コード例 #6
0
        public Bitmap Apply(Bitmap input)
        {
            var            resize  = new Resize_filter(input.Width, input.Height);
            var            resMask = resize.Apply(_mask);
            GrayscaleToRGB grayscaleToRGBFilter = new GrayscaleToRGB();

            resMask = grayscaleToRGBFilter.Apply(resMask);
            resMask = _brightnessCorrection.Apply(resMask);
            Subtract subtractFilter = new Subtract(resMask);

            return(subtractFilter.Apply(input));
        }
コード例 #7
0
        ///http://www.aforgenet.com/framework/docs/html/2d04f587-3272-2ad5-f8bc-54ff407d41f2.htm
        public void SubtractAForge()
        {
            Bitmap back = (Bitmap)Bitmap.FromFile("C:\\Picture 70.jpg");

            Subtract filter      = new Subtract(back);
            Bitmap   sourceImage = (Bitmap)Bitmap.FromFile("C:\\Picture 71.jpg");
            var      image       = filter.Apply(sourceImage);

            ExtractBiggestBlob filter2           = new ExtractBiggestBlob();
            Bitmap             biggestBlobsImage = filter2.Apply(image);
            var o = filter2.OriginalImage;
            var p = filter2.BlobPosition;

            biggestBlobsImage.Save("C:\\Picture 71-70 Result.jpg", ImageFormat.Jpeg);
        }
コード例 #8
0
        public static Bitmap operationImages(Bitmap img1, Bitmap img2, int op)
        {
            img1 = ImageUtil.convert(img1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            img2 = ImageUtil.convert(img2, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            Bitmap  filteredImage = img1;
            IFilter myFilter;

            if (op == Filters.mode["Add"])
            {
                myFilter      = new Add(img2);
                filteredImage = myFilter.Apply(img1);
            }
            else if (op == Filters.mode["Subtract"])
            {
                myFilter      = new Subtract(img2);
                filteredImage = myFilter.Apply(img1);
            }
            else if (op == Filters.mode["Intersect"])
            {
                myFilter      = new Intersect(img2);
                filteredImage = myFilter.Apply(img1);
            }
            else if (op == Filters.mode["Difference"])
            {
                myFilter      = new Difference(img2);
                filteredImage = myFilter.Apply(img1);
            }
            else if (op == Filters.mode["Merge"])
            {
                myFilter      = new Merge(img2);
                filteredImage = myFilter.Apply(img1);
            }
            else if (op == Filters.mode["Multiply"])
            {
                myFilter      = new Multiply(img2);
                filteredImage = myFilter.Apply(img1);
            }
            return(filteredImage);
        }
コード例 #9
0
        public HashSet <int> Process(string input, int numberOfDocs)
        {
            var wordsWithPlusSign  = RegexOperator.AssortTheWords(input, PLUS_REGEX, 2);
            var wordsWithMinusSign = RegexOperator.AssortTheWords(input, MINUS_REGEX, 2);
            var noneSignWords      = RegexOperator.AssortTheWords(input, NONE_SIGN_REGEX, 2);

            var and = new And();
            var or  = new Or();
            var sub = new Subtract();

            var beforeMinus = and.Apply(and.ApplyOnAll(noneSignWords, tokens),
                                        or.ApplyOnAll(wordsWithPlusSign, tokens));

            if (noneSignWords.Count == 0 && wordsWithPlusSign.Count == 0)
            {
                for (int i = 0; i < numberOfDocs; i++)
                {
                    beforeMinus.Add(i);
                }
            }
            return(sub.Apply(beforeMinus, or.ApplyOnAll(wordsWithMinusSign, tokens)));
        }
コード例 #10
0
ファイル: ImUtility.cs プロジェクト: chencen2000/testMQ
        public static Tuple <bool, float, Bitmap> diff_images(Bitmap f1, Bitmap f2)
        {
            bool   retB = false;
            float  retF = 0.0f;
            Bitmap retI = null;

            Program.logIt("diff_images: ++");
            if (f1 != null && f2 != null)
            {
                if (f1.Width == f2.Width && f1.Height == f2.Height)
                {
                    Subtract sf = new Subtract(f1);
                    Bitmap   r  = sf.Apply(f2);
                    retI = r;
                }
                else
                {
                    Program.logIt("diff_images: can not process due to the size of image is not same.");
                }
            }
            Program.logIt(string.Format("diff_images: -- ret={0} similarity={1}", retB, retF));
            return(new Tuple <bool, float, Bitmap>(retB, retF, retI));
        }
コード例 #11
0
        void SelectedCam_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            Bitmap   bmp         = new Bitmap(100, 100);
            Graphics placeholder = Graphics.FromImage(bmp);

            placeholder.FillRectangle(Brushes.White, 0, 0, bmp.Width, bmp.Height);
            Bitmap image         = (Bitmap)eventArgs.Frame.Clone();
            Bitmap originalImage = (Bitmap)eventArgs.Frame.Clone();


            // set color ranges to keep red-orange
            filter.Hue        = new IntRange(0, 35);
            filter.Saturation = new Range(0.19f, 1);
            //filter.Luminance = new Range(0.31f, 255);
            // apply the filter
            filter.ApplyInPlace(image);
            openingFilter.ApplyInPlace(image);
            Bitmap greyimage = grayscaleFilter.Apply(image);

            thresholdFilter.ApplyInPlace(greyimage);
            erosionFilter.Apply(greyimage);



            // process binary image
            bc.ProcessImage(image);
            bc.MinWidth     = 50;
            bc.MinHeight    = 50;
            bc.FilterBlobs  = true;
            bc.ObjectsOrder = ObjectsOrder.Size;
            Rectangle[] rects = bc.GetObjectsRectangles();
            if (rects.Length > 0)
            {
                bmp = new Bitmap(rects[0].Width, rects[0].Height);


                Graphics g = Graphics.FromImage(bmp);
                g.DrawImage(greyimage, 0, 0, rects[0], GraphicsUnit.Pixel);

                g.Dispose();



                // process blobs
                foreach (Rectangle rect in rects)
                {
                    Graphics g1 = Graphics.FromImage(originalImage);


                    using (Pen pen = new Pen(Color.FromArgb(160, 255, 160), 5))
                    {
                        g1.DrawRectangle(pen, rect);
                    }

                    g1.Dispose();
                }
            }

            Crop cropFilter = new Crop(new Rectangle(0, (int)(0.15 * bmp.Height), bmp.Width, (int)(0.25 * bmp.Height)));


            Bitmap handImage = cropFilter.Apply(bmp);
            Bitmap overlay   = new Bitmap(handImage.Width, handImage.Height);

            using (Graphics g = Graphics.FromImage(overlay))
            {
                g.FillRectangle(Brushes.White, 0, 0, overlay.Width, overlay.Height);
            }
            Subtract subfilter   = new Subtract(handImage);
            Bitmap   resultImage = subfilter.Apply(overlay);
            HorizontalIntensityStatistics his = new HorizontalIntensityStatistics(handImage);


            double palmlimit = 0.4 * handImage.Height;

            int[] hisValues = (int[])his.Red.Values.Clone();
            for (int i = 0; i < handImage.Width; i++)
            {
                hisValues[i] = ((double)hisValues[i] / 255 > palmlimit) ? 1 : 0;
            }


            histogram.Values  = his.Red.Values;
            histogram1.Values = hisValues;
            //display number of fingers

            Graphics num  = Graphics.FromImage(image);
            string   text = "0";

            if (bmp.Height > 1.5 * bmp.Width)
            {
                text = string.Format(countfingers(hisValues));
            }
            else
            {
                text = "0";
            }
            Font       drawFont  = new Font("Courier", 18, FontStyle.Bold);
            SolidBrush drawBrush = new SolidBrush(Color.White);

            num.DrawString(text, drawFont, drawBrush, new PointF(0, 5));

            drawFont.Dispose();
            drawBrush.Dispose();

            num.Dispose();

            // display in picture box
            pictureBox1.Image = originalImage;
            original.Image    = image;
            crop.Image        = handImage;
        }