C# Class Accord.Imaging.IntegralImage

Integral image.

The class implements integral image concept, which is described by Viola and Jones in: P. Viola and M. J. Jones, "Robust real-time face detection", Int. Journal of Computer Vision 57(2), pp. 137–154, 2004.

"An integral image I of an input image G is defined as the image in which the intensity at a pixel position is equal to the sum of the intensities of all the pixels above and to the left of that position in the original image."

The intensity at position (x, y) can be written as:

x y I(x,y) = SUM( SUM( G(i,j) ) ) i=0 j=0

The class uses 32-bit integers to represent integral image.

The class processes only grayscale (8 bpp indexed) images.

This class contains two versions of each method: safe and unsafe. Safe methods do checks of provided coordinates and ensure that these coordinates belong to the image, what makes these methods slower. Unsafe methods do not do coordinates' checks and rely that these coordinates belong to the image, what makes these methods faster.

Sample usage:

// create integral image IntegralImage im = IntegralImage.FromBitmap( image ); // get pixels' mean value in the specified rectangle float mean = im.GetRectangleMean( 10, 10, 20, 30 )
Inheritance: ICloneable
Afficher le fichier Open project: accord-net/framework Class Usage Examples

Protected Properties

Свойство Type Description
integralImage ].uint[

Méthodes publiques

Méthode Description
Clone ( ) : object

Creates a new object that is a copy of the current instance.

FromBitmap ( Bitmap image ) : IntegralImage

Construct integral image from source grayscale image.

FromBitmap ( BitmapData imageData ) : IntegralImage

Construct integral image from source grayscale image.

FromBitmap ( UnmanagedImage image ) : IntegralImage

Construct integral image from source grayscale image.

GetHaarXWavelet ( int x, int y, int radius ) : int

Calculate horizontal (X) haar wavelet at the specified point.

The method calculates horizontal wavelet, which is a difference of two horizontally adjacent boxes' sums, i.e. A-B. A is the sum of rectangle with coordinates (x, y-radius, x+radius-1, y+radius-1). B is the sum of rectangle with coordinates (x-radius, y-radius, x-1, y+radiys-1).

GetHaarYWavelet ( int x, int y, int radius ) : int

Calculate vertical (Y) haar wavelet at the specified point.

The method calculates vertical wavelet, which is a difference of two vertical adjacent boxes' sums, i.e. A-B. A is the sum of rectangle with coordinates (x-radius, y, x+radius-1, y+radius-1). B is the sum of rectangle with coordinates (x-radius, y-radius, x+radius-1, y-1).

GetRectangleMean ( int x, int y, int radius ) : float

Calculate mean value of pixels in the specified rectangle.

The method calculates mean value of pixels in square rectangle with odd width and height. In the case if it is required to calculate mean value of 3x3 rectangle, then it is required to specify its center and radius equal to 1.

GetRectangleMean ( int x1, int y1, int x2, int y2 ) : float

Calculate mean value of pixels in the specified rectangle.

Both specified points are included into the calculation rectangle.

GetRectangleMeanUnsafe ( int x, int y, int radius ) : float

Calculate mean value of pixels in the specified rectangle without checking it's coordinates.

The method calculates mean value of pixels in square rectangle with odd width and height. In the case if it is required to calculate mean value of 3x3 rectangle, then it is required to specify its center and radius equal to 1.

GetRectangleMeanUnsafe ( int x1, int y1, int x2, int y2 ) : float

Calculate mean value of pixels in the specified rectangle without checking it's coordinates.

Both specified points are included into the calculation rectangle.

GetRectangleSum ( int x, int y, int radius ) : uint

Calculate sum of pixels in the specified rectangle.

The method calculates sum of pixels in square rectangle with odd width and height. In the case if it is required to calculate sum of 3x3 rectangle, then it is required to specify its center and radius equal to 1.

GetRectangleSum ( int x1, int y1, int x2, int y2 ) : uint

Calculate sum of pixels in the specified rectangle.

Both specified points are included into the calculation rectangle.

GetRectangleSumUnsafe ( int x, int y, int radius ) : uint

Calculate sum of pixels in the specified rectangle without checking it's coordinates.

The method calculates sum of pixels in square rectangle with odd width and height. In the case if it is required to calculate sum of 3x3 rectangle, then it is required to specify its center and radius equal to 1.

GetRectangleSumUnsafe ( int x1, int y1, int x2, int y2 ) : uint

Calculate sum of pixels in the specified rectangle without checking it's coordinates.

Both specified points are included into the calculation rectangle.

Méthodes protégées

Méthode Description
IntegralImage ( int width, int height ) : System

Initializes a new instance of the IntegralImage class.

The constractor is protected, what makes it imposible to instantiate this class directly. To create an instance of this class FromBitmap(Bitmap) or FromBitmap(BitmapData) method should be used.

Method Details

Clone() public méthode

Creates a new object that is a copy of the current instance.
public Clone ( ) : object
Résultat object

FromBitmap() public static méthode

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.
Résultat IntegralImage

FromBitmap() public static méthode

Construct integral image from source grayscale image.
The source image has incorrect pixel format.
public static FromBitmap ( BitmapData imageData ) : IntegralImage
imageData System.Drawing.Imaging.BitmapData Source image data.
Résultat IntegralImage

FromBitmap() public static méthode

Construct integral image from source grayscale image.
The source image has incorrect pixel format.
public static FromBitmap ( UnmanagedImage image ) : IntegralImage
image UnmanagedImage Source unmanaged image.
Résultat IntegralImage

GetHaarXWavelet() public méthode

Calculate horizontal (X) haar wavelet at the specified point.

The method calculates horizontal wavelet, which is a difference of two horizontally adjacent boxes' sums, i.e. A-B. A is the sum of rectangle with coordinates (x, y-radius, x+radius-1, y+radius-1). B is the sum of rectangle with coordinates (x-radius, y-radius, x-1, y+radiys-1).

public GetHaarXWavelet ( int x, int y, int radius ) : int
x int X coordinate of the point to calculate wavelet at.
y int Y coordinate of the point to calculate wavelet at.
radius int Wavelet size to calculate.
Résultat int

GetHaarYWavelet() public méthode

Calculate vertical (Y) haar wavelet at the specified point.

The method calculates vertical wavelet, which is a difference of two vertical adjacent boxes' sums, i.e. A-B. A is the sum of rectangle with coordinates (x-radius, y, x+radius-1, y+radius-1). B is the sum of rectangle with coordinates (x-radius, y-radius, x+radius-1, y-1).

public GetHaarYWavelet ( int x, int y, int radius ) : int
x int X coordinate of the point to calculate wavelet at.
y int Y coordinate of the point to calculate wavelet at.
radius int Wavelet size to calculate.
Résultat int

GetRectangleMean() public méthode

Calculate mean value of pixels in the specified rectangle.
The method calculates mean value of pixels in square rectangle with odd width and height. In the case if it is required to calculate mean value of 3x3 rectangle, then it is required to specify its center and radius equal to 1.
public GetRectangleMean ( int x, int y, int radius ) : float
x int X coordinate of central point of the rectangle.
y int Y coordinate of central point of the rectangle.
radius int Radius of the rectangle.
Résultat float

GetRectangleMean() public méthode

Calculate mean value of pixels in the specified rectangle.
Both specified points are included into the calculation rectangle.
public GetRectangleMean ( int x1, int y1, int x2, int y2 ) : float
x1 int X coordinate of left-top rectangle's corner.
y1 int Y coordinate of left-top rectangle's corner.
x2 int X coordinate of right-bottom rectangle's corner.
y2 int Y coordinate of right-bottom rectangle's corner.
Résultat float

GetRectangleMeanUnsafe() public méthode

Calculate mean value of pixels in the specified rectangle without checking it's coordinates.
The method calculates mean value of pixels in square rectangle with odd width and height. In the case if it is required to calculate mean value of 3x3 rectangle, then it is required to specify its center and radius equal to 1.
public GetRectangleMeanUnsafe ( int x, int y, int radius ) : float
x int X coordinate of central point of the rectangle.
y int Y coordinate of central point of the rectangle.
radius int Radius of the rectangle.
Résultat float

GetRectangleMeanUnsafe() public méthode

Calculate mean value of pixels in the specified rectangle without checking it's coordinates.
Both specified points are included into the calculation rectangle.
public GetRectangleMeanUnsafe ( int x1, int y1, int x2, int y2 ) : float
x1 int X coordinate of left-top rectangle's corner.
y1 int Y coordinate of left-top rectangle's corner.
x2 int X coordinate of right-bottom rectangle's corner.
y2 int Y coordinate of right-bottom rectangle's corner.
Résultat float

GetRectangleSum() public méthode

Calculate sum of pixels in the specified rectangle.

The method calculates sum of pixels in square rectangle with odd width and height. In the case if it is required to calculate sum of 3x3 rectangle, then it is required to specify its center and radius equal to 1.

public GetRectangleSum ( int x, int y, int radius ) : uint
x int X coordinate of central point of the rectangle.
y int Y coordinate of central point of the rectangle.
radius int Radius of the rectangle.
Résultat uint

GetRectangleSum() public méthode

Calculate sum of pixels in the specified rectangle.

Both specified points are included into the calculation rectangle.

public GetRectangleSum ( int x1, int y1, int x2, int y2 ) : uint
x1 int X coordinate of left-top rectangle's corner.
y1 int Y coordinate of left-top rectangle's corner.
x2 int X coordinate of right-bottom rectangle's corner.
y2 int Y coordinate of right-bottom rectangle's corner.
Résultat uint

GetRectangleSumUnsafe() public méthode

Calculate sum of pixels in the specified rectangle without checking it's coordinates.

The method calculates sum of pixels in square rectangle with odd width and height. In the case if it is required to calculate sum of 3x3 rectangle, then it is required to specify its center and radius equal to 1.

public GetRectangleSumUnsafe ( int x, int y, int radius ) : uint
x int X coordinate of central point of the rectangle.
y int Y coordinate of central point of the rectangle.
radius int Radius of the rectangle.
Résultat uint

GetRectangleSumUnsafe() public méthode

Calculate sum of pixels in the specified rectangle without checking it's coordinates.

Both specified points are included into the calculation rectangle.

public GetRectangleSumUnsafe ( int x1, int y1, int x2, int y2 ) : uint
x1 int X coordinate of left-top rectangle's corner.
y1 int Y coordinate of left-top rectangle's corner.
x2 int X coordinate of right-bottom rectangle's corner.
y2 int Y coordinate of right-bottom rectangle's corner.
Résultat uint

IntegralImage() protected méthode

Initializes a new instance of the IntegralImage class.
The constractor is protected, what makes it imposible to instantiate this class directly. To create an instance of this class FromBitmap(Bitmap) or FromBitmap(BitmapData) method should be used.
protected IntegralImage ( int width, int height ) : System
width int Image width.
height int Image height.
Résultat System

Property Details

integralImage protected_oe property

Intergral image's array.
See remarks to InternalData property.
protected uint[,] integralImage
Résultat ].uint[