AForge.Imaging.SusanCornersDetector.ProcessImage C# (CSharp) Method

ProcessImage() public method

Process image looking for corners.
The source image has incorrect pixel format.
public ProcessImage ( Bitmap image ) : List
image System.Drawing.Bitmap Source image to process.
return List
        public List<IntPoint> ProcessImage( Bitmap image )
        {
            // check image format
            if (
                ( image.PixelFormat != PixelFormat.Format8bppIndexed ) &&
                ( image.PixelFormat != PixelFormat.Format24bppRgb ) &&
                ( image.PixelFormat != PixelFormat.Format32bppRgb ) &&
                ( image.PixelFormat != PixelFormat.Format32bppArgb )
                )
            {
                throw new UnsupportedImageFormatException( "Unsupported pixel format of the source image." );
            }

            // lock source image
            BitmapData imageData = image.LockBits(
                new Rectangle( 0, 0, image.Width, image.Height ),
                ImageLockMode.ReadOnly, image.PixelFormat );

            List<IntPoint> corners;

            try
            {
                // process the image
                corners = ProcessImage( new UnmanagedImage( imageData ) );
            }
            finally
            {
                // unlock image
                image.UnlockBits( imageData );
            }

            return corners;
        }

Same methods

SusanCornersDetector::ProcessImage ( BitmapData imageData ) : List
SusanCornersDetector::ProcessImage ( UnmanagedImage image ) : List

Usage Example

        public void RansacLineConstructorTest2()
        {
            Accord.Math.Tools.SetupGenerator(0);

            Bitmap image = 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);
            Assert.AreEqual(-0.865369201f, line.Slope);

            //var result = new LineMarker(line).Apply(image);
            //Accord.Controls.ImageBox.Show(result);
        }
All Usage Examples Of AForge.Imaging.SusanCornersDetector::ProcessImage