integralBoxFilter
2-D box filtering of integral images
Syntax
Description
filters the integral image B
= integralBoxFilter(A
,filterSize
)A
with a 2-D box
filter with size specified by
filterSize
.
also specifies the normalization factor applied to the box
filter.B
= integralBoxFilter(___,"NormalizationFactor",normFactor
)
Examples
Filter Integral Image
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')
Filter Image with Horizontal and Vertical Motion Blur
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
A
— Integral image to be filtered
numeric array
Integral image to be filtered, specified as a numeric array 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
.
Data Types: double
filterSize
— Size of box filter
3
(default) | positive, odd integer | 2-element vector of positive, odd integers
Size of box filter, specified as a positive, odd integer or 2-element vector of positive, odd
integers. If filterSize
is
scalar, then integralBoxFilter
uses a square box filter.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
normFactor
— Normalization factor applied to box filter
numeric scalar
Normalization factor applied to the box filter, specified as a numeric scalar.
By default, the normalization factor has the value
1/filterSize.^2
when
filterSize
is a scalar, and
1/prod(filterSize)
when
filterSize
is a vector. The
default 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
normFactor
to
1
. To avoid overflow in such
circumstances, consider using double precision
images by converting the input image to data type
double
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Output Arguments
B
— Filtered image
numeric array
Filtered image, returned as a numeric array. integralBoxFilter
returns only
the parts of the filtering that are computed without
padding.
Data Types: double
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
integralBoxFilter
supports the generation of C code (requires MATLAB® Coder™). For more information, see Code Generation for Image Processing.The
normFactor
argument must be a compile-time constant.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
Usage notes and limitations:
The
normFactor
argument must be a compile-time constant.
Version History
Introduced in R2015b
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)