Documentation Center

  • Trial Software
  • Product Updates

integralKernel class

Integral image filter


This object describes box filters to use with integral images.


H = integralKernel(BBOX,WEIGHTS) defines a box filter, H, from an M-by-4 matrix of bounding boxes, BBOX, and an M-length vector, WEIGHTS, of corresponding weights. Each row of BBOX corresponds to a different region, which you can use to sum the pixels. The bounding boxes can overlap. The format of each row, [x y width height], contains the coordinates of the upper-left corner and size of each region. See Define a Vertical Derivative Filter for an example of how to specify a box filter.

Input Arguments


M-by-4 matrix of bounding boxes. Each of the M number of 4-element row vectors [x y width height] define a bounding box. The first two elements represent the coordinates of the upper-left corner of the bounding box. The second two elements represent the width and height of the bounding box.


M length vector of weights corresponding to the bounding boxes.


The following properties are read-only


Bounding boxes which define the filter. The format is [x y width height].


Vector containing a weight for each bounding box.


Conventional filter coefficients.


Center coordinates of the filter.


Filter size.


transposeTranspose filter


expand all

Define a Vertical Derivative Filter

Specify a conventional filter with coefficients.

Specify a conventional filter with the following coefficients.

Use the format [x y width height] for the two bounding boxes.

First regionx = 1, y = 1, width = 4, height = 2, weight = 1
Second regionx = 1, y = 3, width = 4, height = 2, weight = –1

Enter the specification as follows.

boxH = integralKernel([1 1 4 2; 1 3 4 2], [1, -1]);

Define an Average Filter

Define an 11-by-11 average filter.

avgH = integralKernel([1 1 11 11], 1/11^2);

Define a Filter Approximating a Second-Order Partial Derivative

Define filter which approximates second order partial derivative in XY direction. This filter can be used by the SURF feature detector.

% The filter is zero-padded, using weight of zero, so that it is centered at x=5, y=5.
xydH = integralKernel([1,1,9,9; 2,2,3,3; 6,2,3,3; 2 6 3 3; 6 6 3 3], [0, 1, -1, -1, 1]);

% Visualize the filter
  imshow(xydH.Coefficients, [], 'InitialMagnification', 'fit');

% Mark the filter center
  hold on; plot(xydH.Center(1), xydH.Center(2), 'o');

Define a Filter to Approximate a Gaussian Second-order Partial Derivative

Define a filter to approximate a Gaussian second order partial derivative in Y direction.

ydH = integralKernel([1,1,5,9;1,4,5,3], [1, -3]);

% Note that this same filter could have been defined as:
%   integralKernel([1,1,5,3;1,4,5,3;1,7,5,3], [1, -2, 1]);
% but it would be less efficient since it requires 3 bounding boxes.

ydH.Coefficients % visualize the filter



More About

 Computing an Integral Image and Using it for Filtering with Box Filters

See Also

| | | |

Was this topic helpful?