Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

integralBoxFilter

2-D box filtering of integral images

Syntax

B = integralBoxFilter(intA)
B = integralBoxFilter(intA,filterSize)
B = integralBoxFilter(___,Name,Value)

Description

B = integralBoxFilter(intA) filters the integral image intA with a 3-by-3 box filter. Returns the filtered image, B.

example

B = integralBoxFilter(intA,filterSize) filters the integral image intA with a 2-D box filter with size specified by filterSize.

B = integralBoxFilter(___,Name,Value) filters integral image intA with Name-Value pairs to control various aspects of the filtering.

Examples

collapse all

Read image into the workspace.

A = imread('cameraman.tif');

Pad the image by the radius of the filter neighborhood. This example uses an 11-by-11 filter.

filterSize = [11 11];
padSize = (filterSize-1)/2;
Apad = padarray(A, padSize, 'replicate','both');

Compute the integral image of the padded input image.

intA = integralImage(Apad);

Filter the integral image.

B = integralBoxFilter(intA, filterSize);

Display original image and filtered image.

figure
imshow(A)
title('Original Image')

figure
imshow(B,[])
title('Filtered Image')

Read image into the workspace.

 A = imread('cameraman.tif');

Pad the image by radius of the filter neighborhood, calculated (11-1)/2.

padSize = [5 5]; 
Apad = padarray(A, padSize, 'replicate', 'both');

Calculate the integral image of the padded input.

intA = integralImage(Apad);

Filter the integral image with a vertical [11 1] filter.

Bvert = integralBoxFilter(intA, [11 1]);

Crop the output to retain input image size and display it.

Bvert = Bvert(:,6:end-5);

Filter the integral image with a horizontal [1 11] filter.

Bhorz = integralBoxFilter(intA, [1 11]);

Crop the output to retain input image size.

Bhorz = Bhorz(6:end-5,:);

Display the original image and the filtered images.

figure,
imshow(A)
title('Original Image')

figure,
imshow(Bvert,[])
title('Filtered with Vertical Filter')

figure,
imshow(Bhorz,[])
title('Filtered with Horizontal Filter')

Input Arguments

collapse all

Integral image to be filtered, specified as a real, nonsparse matrix of any dimension. The integral image must be upright—integralBoxFilter does not support rotated integral images. The first row and column of the integral image is assumed to be zero-padded, as returned by integralImage.

Example: B = integralBoxFilter(A);

Data Types: double

Size of box filter, specified as a scalar or 2-element vector of positive, odd integers. If filterSize is scalar, integralBoxFilter uses a square box filter.

Example: B = integralBoxFilter(A,5);

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: B = integralBoxFilter(A,5,'NormalizationFactor',1);

collapse all

Normalization factor applied to box filter, specified as a numeric scalar or vector.

The default 'NormalizationFactor' has the effect of a mean filter—the pixels in the output image are the local means of the image. To get local area sums, set 'NormalizationFactor' to 1. To avoid overflow in such circumstances, consider using double precision images by converting the input image to class double.

Example: B = integralBoxFilter(A,5,'NormalizationFactor',1);

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

Filtered image, returned as a real, nonsparse matrix of class double. integralBoxFilter returns only the parts of the filtering that are computed without padding.

Extended Capabilities

Introduced in R2015b

Was this topic helpful?