Accord.Imaging.IntegralImage.FromBitmap C# (CSharp) Method

FromBitmap() public static method

Construct integral image from source grayscale image.
The source image has incorrect pixel format.
public static FromBitmap ( Bitmap image ) : IntegralImage
image System.Drawing.Bitmap Source grayscale image.
return IntegralImage
        public static IntegralImage FromBitmap(Bitmap image)
        {
            // check image format
            if (image.PixelFormat != PixelFormat.Format8bppIndexed)
            {
                throw new UnsupportedImageFormatException("Source image can be graysclae (8 bpp indexed) image only.");
            }

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

            // process the image
            IntegralImage im = FromBitmap(imageData);

            // unlock image
            image.UnlockBits(imageData);

            return im;
        }

Same methods

IntegralImage::FromBitmap ( BitmapData imageData ) : IntegralImage
IntegralImage::FromBitmap ( UnmanagedImage image ) : IntegralImage

Usage Example

Example #1
0
        /// <summary>
        ///   Process image looking for interest points.
        /// </summary>
        ///
        /// <param name="image">Source image data to process.</param>
        ///
        /// <returns>Returns list of found interest points.</returns>
        ///
        public List <FastRetinaKeypoint> ProcessImage(UnmanagedImage 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.");
            }

            // make sure we have grayscale image
            if (image.PixelFormat == PixelFormat.Format8bppIndexed)
            {
                grayImage = image;
            }
            else
            {
                // create temporary grayscale image
                grayImage = Grayscale.CommonAlgorithms.BT709.Apply(image);
            }


            // 1. Extract corners points from the image.
            List <IntPoint> corners = Detector.ProcessImage(grayImage);

            var features = new List <FastRetinaKeypoint>();

            for (int i = 0; i < corners.Count; i++)
            {
                features.Add(new FastRetinaKeypoint(corners[i].X, corners[i].Y));
            }


            // 2. Compute the integral for the given image
            integral = IntegralImage.FromBitmap(grayImage);


            // 3. Compute feature descriptors if required
            descriptor = null;
            if (featureType != FastRetinaKeypointDescriptorType.None)
            {
                descriptor = GetDescriptor();
                descriptor.Compute(features);
            }

            return(features);
        }
All Usage Examples Of Accord.Imaging.IntegralImage::FromBitmap