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;
}