Accord.Imaging.HoughLineTransformation.ProcessImage C# (CSharp) Method

ProcessImage() public method

Process an image building Hough map.
Unsupported pixel format of the source image.
public ProcessImage ( Bitmap image ) : void
image System.Drawing.Bitmap Source image to process.
return void
        public void ProcessImage(Bitmap image)
        {
            ProcessImage(image, new Rectangle(0, 0, image.Width, image.Height));
        }

Same methods

HoughLineTransformation::ProcessImage ( Bitmap image, Rectangle rect ) : void
HoughLineTransformation::ProcessImage ( BitmapData imageData ) : void
HoughLineTransformation::ProcessImage ( BitmapData imageData, Rectangle rect ) : void
HoughLineTransformation::ProcessImage ( UnmanagedImage image ) : void
HoughLineTransformation::ProcessImage ( UnmanagedImage image, Rectangle rect ) : void

Usage Example

Example #1
0
        private Bitmap HoughTransform(Bitmap originalImage)
        {
            var imgBitmap     = new Bitmap(originalImage);
            var lineTransform = new Accord.Imaging.HoughLineTransformation();
            // Convert it to binary and mark the possible lines
            // in white so it can be processed by the transform
            var sequence = new FiltersSequence(
                Grayscale.CommonAlgorithms.BT709,
                new NiblackThreshold(),
                new Invert()
                );
            var contoursBitmap = ImageFilter.PrewittFilter(imgBitmap, true);
            // Apply the sequence of filters above:
            Bitmap binaryImage = sequence.Apply(contoursBitmap);

            lineTransform.ProcessImage(binaryImage);
            // Now, let's say we would like to retrieve the lines and use them
            // for further processing. First, the lines can be ordered by their
            // relative intensity using
            HoughLine[] lines = lineTransform.GetLinesByRelativeIntensity(1);

            // Then, let's plot them on top of the input image. Since we will
            // apply many operations to a single image, it is better to first
            // convert it to an UnmanagedImage object to avoid having to lock
            // the image into memory multiple times.

            UnmanagedImage unmanagedImage = UnmanagedImage.FromManagedImage(binaryImage);

            // Finally, plot them in order:
            foreach (HoughLine line in lines)
            {
                line.Draw(unmanagedImage, color: Color.Red);
            }

            return(unmanagedImage.ToManagedImage());
        }