integralFilter

Integral image filter

Syntax

J = integralFilter(intI,H)

Description

J = integralFilter(intI,H) filters an image, given its integral image, intI, and filter object, H. The integralKernel function returns the filter object used for the input to the integralFilter. The integralFilter returns only the parts of correlation that are computed without padding. The resulting size of the filtered output J equals:

size(J) = size(intI) – H.Size

This function uses integral images for filtering an image with box filters. You can obtain the integral image, intI, by calling the integralImage function. The filter size does not affect the speed of the filtering operation. Thus, the integralFilter function is ideally suited to use for fast analysis of images at different scales, as demonstrated by the Viola-Jones algorithm [1].

Tips

Because the integralFilter function uses correlation for filtering, the filter is not rotated before computing the result.

Input Arguments

intI

Integral image. You can obtain the integral image, intI, by calling the integralImage function. The class for this value can be double or single.

H

Filter object. You can obtain the filter object, H, by calling the integralKernel function.

Output Arguments

J

Filtered image. The filtered image, J, returns only the parts of correlation that are computed without padding. The resulting size of the filtered output equals:

size(J) = size(intI) – H.Size

Because the function uses correlation for filtering, the filter is not rotated before computing the result.

Examples

expand all

Blur an Image Using a Filter

Use an averaging filter to blur an image.

Read the input image and compute the integral image.

I = imread('pout.tif');
figure; imshow(I);
intImage = integralImage(I);

Create a 7-by-7 average filter object.

avgH = integralKernel([1 1 7 7], 1/49);

Blur the image using the integral filter.

J = integralFilter(intImage, avgH);

Cast the result back to the same class as the input image and display the results.

J = uint8(J); % cast the result back to same class as I
figure; imshow(J); 

Find Vertical and Horizontal Edges in Image

Construct Haar-like wavelet filters to find vertical and horizontal edges in an image.

Read the input image and compute the integral image.

I = imread('pout.tif');
intImage = integralImage(I);

Construct Haar-like wavelet filters. Use the dot notation to find the vertical filter.

horiH = integralKernel([1 1 4 3; 1 4 4 3], [-1, 1]); % horizontal filter
vertH = horiH.';

Display the horizontal filter.

imtool(horiH.Coefficients, 'InitialMagnification','fit');

Compute the filter responses.

horiResponse = integralFilter(intImage, horiH);
vertResponse = integralFilter(intImage, vertH);

Display the results.

figure; imshow(horiResponse, []); title('Horizontal edge responses');
figure; imshow(vertResponse, []); title('Vertical edge responses');

References

[1] Viola, Paul and Michael J. Jones, "Rapid Object Detection using a Boosted Cascade of Simple Features", Proceedings of the 2001 IEEE Computer Society Conference on Computer Vision and Pattern Recognition, 2001. Volume: 1, pp.511–518.

Was this topic helpful?