public void RansacLineConstructorTest2()
        {
            Accord.Math.Random.Generator.Seed = 0;

            Bitmap image = Accord.Imaging.Image.Clone(Resources.noise_line);

            //Accord.Controls.ImageBox.Show(image);

            var detector = new SusanCornersDetector();

            List <IntPoint> cloud = detector.ProcessImage(image);

            Assert.AreEqual(211, cloud.Count);

            Bitmap marks = new PointsMarker(cloud, Color.Pink).Apply(image);
            //Accord.Controls.ImageBox.Show(marks);

            RansacLine ransac = new RansacLine(5, 1e-10);
            Line       line   = ransac.Estimate(cloud);

            Assert.AreEqual(0.501134932f, line.Intercept, 1e-5);
            Assert.AreEqual(-0.865369201f, line.Slope, 1e-5);

            //var result = new LineMarker(line).Apply(image);
            //Accord.Controls.ImageBox.Show(result);
        }
Example #2
0
        public int cornerdetect(Bitmap input)
        {
            Accord.Imaging.SusanCornersDetector susanCorners = new SusanCornersDetector(1, 10);
            List <Accord.IntPoint> points = susanCorners.ProcessImage(input);

            return(points.Count);
        }
Example #3
0
 public void exBlockClickHandler(object sender, EventArgs e)
 {
     if (image != null)
     {
         OpenFileDialog ofd = new OpenFileDialog();
         ofd.Multiselect = false;
         ofd.Title       = "Choose an Image to Comparewith";
         DialogResult result = ofd.ShowDialog();
         if (result == DialogResult.OK)
         {
             string filename = ofd.FileName;
             try
             {
                 Bitmap   searchImage = new Bitmap(filename);
                 Bitmap   sourceImage = new Bitmap(path);
                 CompView mov         = this.WorkItem.SmartParts.AddNew <CompView>();
                 mov.panAndZoomPictureBox1.Image = searchImage;
                 SmartPartInfo spi =
                     new SmartPartInfo("Search Image", "MyOwnDescription");
                 this.WorkItem.Workspaces[WorkspaceNames.TabWorkspace].Show(mov, spi);
                 // collect reference points using corners detector (for example)
                 SusanCornersDetector scd    = new SusanCornersDetector(30, 18);
                 List <IntPoint>      points = scd.ProcessImage(sourceImage);
                 // create block matching algorithm's instance
                 ExhaustiveBlockMatching bm = new ExhaustiveBlockMatching();
                 // process images searching for block matchings
                 List <BlockMatch> matches = bm.ProcessImage(sourceImage, points, searchImage);
                 // draw displacement vectors
                 BitmapData data = sourceImage.LockBits(
                     new Rectangle(0, 0, sourceImage.Width, sourceImage.Height),
                     ImageLockMode.ReadWrite, sourceImage.PixelFormat);
                 foreach (BlockMatch match in matches)
                 {
                     // highlight the original point in source image
                     Drawing.FillRectangle(data,
                                           new Rectangle(match.SourcePoint.X - 1, match.SourcePoint.Y - 1, 3, 3),
                                           Color.Yellow);
                     // draw line to the point in search image
                     Drawing.Line(data, match.SourcePoint, match.MatchPoint, Color.Red);
                     // check similarity
                     if (match.Similarity > 0.98f)
                     {
                     }
                 }
                 sourceImage.UnlockBits(data);
                 CompView mov2 = this.WorkItem.SmartParts.AddNew <CompView>();
                 mov2.panAndZoomPictureBox1.Image = sourceImage;
                 SmartPartInfo spi2 =
                     new SmartPartInfo("Results", "MyOwnDescription");
                 this.WorkItem.Workspaces[WorkspaceNames.TabWorkspace].Show(mov2, spi2);
             }
             catch
             {
                 MessageBox.Show("Images Should be of same height and width");
                 return;
             }
         }
     }
 }
Example #4
0
        public static IEnumerable <System.Drawing.Point> GetCornersSusan(this Bitmap iBitmap)
        {
            SusanCornersDetector scd                 = new SusanCornersDetector();
            List <IntPoint>      corners             = scd.ProcessImage(iBitmap);
            CornersMarker        filterCornersMarker = new CornersMarker(scd, Color.Red);
            var result = filterCornersMarker.Apply(iBitmap);

            return(corners.Select(x => new System.Drawing.Point(x.X, x.Y)));
        }
Example #5
0
        public void GetCorners(int diff, int geo)
        {
            // create corners detector's instance
            SusanCornersDetector scd = new SusanCornersDetector(diff, geo);
            // process image searching for corners
            List <IntPoint> corners = scd.ProcessImage(AForge.Imaging.Image.FromFile(this.CurrentImage));

            if (ImageComplete != null)
            {
                ImageComplete(corners);
            }
        }
        public void Can_Process_8bpp()
        {
            // test for #1974

            UnmanagedImage image = UnmanagedImage.FromManagedImage(Accord.Imaging.Image.Clone(Resources.image1));

            Assert.AreEqual(System.Drawing.Imaging.PixelFormat.Format8bppIndexed, image.PixelFormat);

            SusanCornersDetector detector = new SusanCornersDetector(25, 18);

            // this shouldn't throw
            var points = detector.ProcessImage(image);
        }
        public mAnalyzeCornersSusan(Bitmap InitialBitmap, Color CornerColor, int DiffThreshold, int GeoThreshold)
        {
            BitmapType = BitmapTypes.None;

            SusanCornersDetector cMethod = new SusanCornersDetector();

            cMethod.DifferenceThreshold  = DiffThreshold;
            cMethod.GeometricalThreshold = GeoThreshold;

            Effect = new CornersMarker(cMethod, CornerColor);

            Effect.Detector = cMethod;


            List <IntPoint> corners = cMethod.ProcessImage(InitialBitmap);

            foreach (IntPoint corner in corners)
            {
                Points.Add(new wPoint(corner.X, InitialBitmap.Height - corner.Y));
            }
        }
Example #8
0
        public void RansacLineConstructorTest2()
        {
            Bitmap image = Properties.Resources.noise_line;

            ImageBox.Show(image);

            var detector = new SusanCornersDetector();

            List <IntPoint> cloud = detector.ProcessImage(image);

            Bitmap marks = new PointsMarker(cloud, Color.Pink).Apply(image);

            ImageBox.Show(marks);

            RansacLine ransac = new RansacLine(5, 1e-10);
            Line       line   = ransac.Estimate(cloud);

            Bitmap result = new LineMarker(line).Apply(image);

            ImageBox.Show(result);

            Assert.Fail();
        }
Example #9
0
        public void RansacLineConstructorTest2()
        {
            Bitmap image = Properties.Resources.noise_line;

            ImageBox.Show(image); 

            var detector = new SusanCornersDetector();

            List<IntPoint> cloud = detector.ProcessImage(image);

            Bitmap marks = new PointsMarker(cloud, Color.Pink).Apply(image);
            ImageBox.Show(marks);

            RansacLine ransac = new RansacLine(5, 1e-10);
            Line line = ransac.Estimate(cloud);

            Bitmap result = new LineMarker(line).Apply(image);
            ImageBox.Show(result);

            Assert.Fail();
        }
Example #10
0
        void TD()
        {
            if (!Triang.Checked)
            {
                return;
            }

            if ((int)PartCount.Value == 1)
            {
                return;
            }

            Polygon p = new Polygon();

            List <Vertex> corners;

            if (UserDeepSearch.Checked)
            {
                MoravecCornersDetector scd = new MoravecCornersDetector();
                corners = scd.ProcessImage(finalImage).Select(x => new Vertex(x.X, x.Y)).ToList();
            }
            else
            {
                SusanCornersDetector scd = new SusanCornersDetector();
                corners = scd.ProcessImage(finalImage).Select(x => new Vertex(x.X, x.Y)).ToList();
            }

            corners.ForEach(delegate(Vertex v)
            {
                p.Add(v);
            });

            triangulated = (Mesh)p.Triangulate();


            using (Graphics graphics = Graphics.FromImage(finalImage))
            {
                foreach (Triangle t in triangulated.Triangles)
                {
                    PointF[] points =
                    {
                        new PointF((float)t.GetVertex(0).X, (float)t.GetVertex(0).Y),
                        new PointF((float)t.GetVertex(1).X, (float)t.GetVertex(1).Y),
                        new PointF((float)t.GetVertex(2).X, (float)t.GetVertex(2).Y),
                    };

                    int ColR = imageBits[0, (int)points[0].Y, (int)points[0].X] +
                               imageBits[0, (int)points[1].Y, (int)points[1].X] +
                               imageBits[0, (int)points[2].Y, (int)points[2].X];

                    int ColG = imageBits[1, (int)points[0].Y, (int)points[0].X] +
                               imageBits[1, (int)points[1].Y, (int)points[1].X] +
                               imageBits[1, (int)points[2].Y, (int)points[2].X];

                    int ColB = imageBits[2, (int)points[0].Y, (int)points[0].X] +
                               imageBits[2, (int)points[1].Y, (int)points[1].X] +
                               imageBits[2, (int)points[2].Y, (int)points[2].X];


                    Brush brush = new SolidBrush(Color.FromArgb(ColR / 3, ColG / 3, ColB / 3));
                    graphics.FillPolygon(brush, points);
                }
            }
        }
Example #11
0
        public TrajectorySet CalculateTrajectorySet(Bitmap image, Double HoughRelativeIntensity, Int32 SusanCornerDifferenceTreshold, Int32 SusanCornerGeometricalTreshold, Int32 lineScanThreshold, Int32 lineScanRadius, Int32 radialThreshold, Boolean geometrical)
        {
            TrajectorySet ts = new TrajectorySet();

            ts.elaboration_start_time = DateTime.Now;

            Bitmap hough_image = AForge.Imaging.Image.Clone(image, PixelFormat.Format24bppRgb);
            Bitmap susan_image = AForge.Imaging.Image.Clone(image, PixelFormat.Format24bppRgb);

            // AForge.Imaging.Image.FormatImage(ref hough_image);
            // AForge.Imaging.Image.FormatImage(ref susan_image);

            //FILTERS AND SOURCE INIT
            hough_image = Grayscale.CommonAlgorithms.RMY.Apply(hough_image);
            susan_image = Grayscale.CommonAlgorithms.RMY.Apply(susan_image);

            hough_image = ApplyFilter(hough_image, new Threshold());
            susan_image = ApplyFilter(susan_image, new Threshold());



            //INIT OBJECTS


            HoughLineTransformation lineTransform  = new HoughLineTransformation();
            SusanCornersDetector    susanTransform = new SusanCornersDetector(SusanCornerDifferenceTreshold, SusanCornerGeometricalTreshold);

            FiltersSequence filter = new FiltersSequence(
                Grayscale.CommonAlgorithms.BT709,
                new Threshold(64)
                );

            //APPLY ALGOS AND GET ENTITIES
            BitmapData houghSourceData = hough_image.LockBits(
                new Rectangle(0, 0, hough_image.Width, hough_image.Height),
                ImageLockMode.ReadOnly, hough_image.PixelFormat);

            lineTransform.ProcessImage(houghSourceData);


            hough_image.UnlockBits(houghSourceData);
            ts.elaborated_image = AForge.Imaging.Image.Clone(hough_image, PixelFormat.Format24bppRgb);;
            hough_image.Dispose();

            HoughLine[] lines = lineTransform.GetLinesByRelativeIntensity(HoughRelativeIntensity);

            BitmapData sousanSourceData = susan_image.LockBits(
                new Rectangle(0, 0, susan_image.Width, susan_image.Height),
                ImageLockMode.ReadOnly, susan_image.PixelFormat);

            List <IntPoint> corners = susanTransform.ProcessImage(sousanSourceData);

            susan_image.UnlockBits(sousanSourceData);
            susan_image.Dispose();

            //populat trajectoryset
            ts.image          = image;
            ts.lineTransform  = lineTransform;
            ts.lines          = lines;
            ts.susanTransform = susanTransform;
            ts.corners        = corners;

            //get discontinuity points
            this.CalculateDiscontinuityPoints(ts, lineScanThreshold, lineScanRadius, radialThreshold, geometrical);

            //get trajectory lines (W=3)

            //get trajectory lines (W=2)

            //get trajectory lines (W=1)

            //get quadrant foreach lines W=3, W=2, W=1
            ts.elaboration_end_time = DateTime.Now;

            return(ts);
        }