Click or drag to resize
Accord.NET (logo)

IntegralImage2 Class

Joint representation of both Integral Image and Squared Integral Image.
Inheritance Hierarchy
SystemObject
  Accord.ImagingIntegralImage2

Namespace:  Accord.Imaging
Assembly:  Accord.Imaging (in Accord.Imaging.dll) Version: 3.8.0
Syntax
[SecurityCriticalAttribute]
public class IntegralImage2 : IDisposable
Request Example View Source

The IntegralImage2 type exposes the following members.

Constructors
  NameDescription
Protected methodIntegralImage2
Constructs a new Integral image of the given size.
Top
Properties
  NameDescription
Public propertyHeight
Gets the image's height.
Public propertyImage
Gets the Integral Image for values' sum.
Public propertyRotated
Gets the Integral Image for tilted values' sum.
Public propertySquared
Gets the Integral Image for values' squared sum.
Public propertyWidth
Gets the image's width.
Top
Methods
  NameDescription
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Protected methodDispose(Boolean)
Releases unmanaged and - optionally - managed resources
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Releases unmanaged resources and performs other cleanup operations before the IntegralImage2 is reclaimed by garbage collection.
(Overrides ObjectFinalize.)
Public methodStatic memberFromBitmap(Bitmap)
Constructs a new Integral image from a Bitmap image.
Public methodStatic memberFromBitmap(BitmapData)
Constructs a new Integral image from a BitmapData image.
Public methodStatic memberFromBitmap(UnmanagedImage)
Constructs a new Integral image from an unmanaged image.
Public methodStatic memberFromBitmap(Bitmap, Boolean)
Constructs a new Integral image from a Bitmap image.
Public methodStatic memberFromBitmap(Bitmap, Int32)
Constructs a new Integral image from a Bitmap image.
Public methodStatic memberFromBitmap(BitmapData, Boolean)
Constructs a new Integral image from a BitmapData image.
Public methodStatic memberFromBitmap(BitmapData, Int32)
Constructs a new Integral image from a BitmapData image.
Public methodStatic memberFromBitmap(UnmanagedImage, Boolean)
Constructs a new Integral image from an unmanaged image.
Public methodStatic memberFromBitmap(UnmanagedImage, Int32)
Constructs a new Integral image from an unmanaged image.
Public methodStatic memberFromBitmap(Bitmap, Int32, Boolean)
Constructs a new Integral image from a Bitmap image.
Public methodStatic memberFromBitmap(BitmapData, Int32, Boolean)
Constructs a new Integral image from a BitmapData image.
Public methodStatic memberFromBitmap(UnmanagedImage, Int32, Boolean)
Constructs a new Integral image from an unmanaged image.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetSum
Gets the sum of the pixels in a rectangle of the Integral image.
Public methodGetSum2
Gets the sum of the squared pixels in a rectangle of the Integral image.
Public methodGetSumT
Gets the sum of the pixels in a tilted rectangle of the Integral image.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodUpdate
Computes the integral image representation from the given image.
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

This class provides a unified representation for both integral images, squared integral images and tilted integral images under the same class. This class can be used to provide more efficient transformations whenever all those representations are required at the same time, such as when using the Viola-Jones (Haar Cascade) object detector.

Using this representation, both structures can be created in a single pass over the data. This is interesting for real time applications. This class also accepts a channel parameter indicating the Integral Image should be computed using a specified color channel. This avoids costly conversions.

Examples
// Let's say we have the following image representation:
byte[,] img =
{
    { 5, 2, 3, 4, 1 },
    { 1, 5, 4, 2, 3 },
    { 2, 2, 1, 3, 4 },
    { 3, 5, 6, 4, 5 },
    { 4, 1, 3, 2, 6 },
};

// Let's convert it to bitmap and 
// pretend it is our input image:
Bitmap bmp = img.ToBitmap();

// Now, create an integral image from this bitmap:
IntegralImage2 ii = IntegralImage2.FromBitmap(bmp);

// The sum-table would be:
long[,] actual = ii.Image;

// Which would be the same as:
long[,] expected =
{
    { 0,  0,  0,  0,  0,  0 },
    { 0,  5,  7, 10, 14, 15 },
    { 0,  6, 13, 20, 26, 30 },
    { 0,  8, 17, 25, 34, 42 },
    { 0, 11, 25, 39, 52, 65 },
    { 0, 15, 30, 47, 62, 81 }
};
// In this example, we will compute an integral image
// representation of Lena Söderberg's famous picture:
TestImages testImages = new TestImages(path: localPath);
Bitmap lena = testImages["lena.bmp"]; // get the image

// Create a new Integral Image (squared and tilted) from Lena's picture:
IntegralImage2 ii = IntegralImage2.FromBitmap(lena, computeTilted: true);

// Let's say we would like to get the summed area in the rectangular region
// delimited by pixel (34, 50) until pixels (60, 105). This is equivalent to
// the region under the rectangle (34, 50, 34+60, 50+105) = (34, 50, 94, 155):
long sum = ii.GetSum(34, 50, 94, 155); // this is the sum of values (1760032)

// Now let's say we would like to get the squared sum and tilted sum as well:
long ssum = ii.GetSum2(34, 50, 94, 155); // this is the sum of squared values (229508896)
long tsum = ii.GetSumT(34, 50, 94, 155); // this is the sum of tilted values (-593600)
See Also