Documentation

This is machine translation

Mouseover text to see original. Click the button below to return to the English version of the page.

imboxfilt

2-D box filtering of images

Syntax

``B = imboxfilt(A)``
``B = imboxfilt(A,filterSize)``
``B = imboxfilt(___,Name,Value)``

Description

example

````B = imboxfilt(A)` filters image `A` with a 2-D, 3-by-3 box filter. A box filter is also called a mean filter.```

example

````B = imboxfilt(A,filterSize)` filters image `A` with a 2-D box filter with size specified by `filterSize`.```

example

````B = imboxfilt(___,Name,Value)` filters image `A` with a 2-D box filter where Name-Value pairs control aspects of the filtering.```

Examples

collapse all

`A = imread('cameraman.tif');`

Perform the mean filtering using an 11-by-11 filter.

`localMean = imboxfilt(A,11);`

Display the original image and the filtered image, side-by-side.

`imshowpair(A,localMean,'montage')` `A = imread('cameraman.tif');`

Change the data type of the image to `double` to avoid integer overflow.

`A = double(A);`

Filter image, calculating local area sums, using a 15-by-15 box filter. To calculate local area sums, rather than the mean, set the `NormalizationFactor` parameter to 1.

`localSums = imboxfilt(A, 15, 'NormalizationFactor',1);`

Display the original image and the filtered image, side-by-side.

`imshowpair(A,localSums,'montage')` Input Arguments

collapse all

Image to be filtered, specified as a real, nonsparse array of any dimension.

If `A` contains `Infs` or `NaNs`, the behavior of `imboxfilt` is undefined. This can happen when integral image based filtering is used. To restrict the propagation of `Infs` and `NaNs` in the output, consider using `imfilter` instead.

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

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

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 quotes. You can specify several name and value pair arguments in any order as `Name1,Value1,...,NameN,ValueN`.

Example: `A = imread('cameraman.tif'); B = imboxfilt(A,5,'Padding','circular');`

Padding pattern, specified as one of the following values or a numeric scalar. If you specify a scalar value, input image pixels outside the bounds of the image are implicitly assumed to have the scalar value.

ValueDescription
`'circular'`Input image values outside the bounds of the image are computed by implicitly assuming the input image is periodic.
`'replicate'`Input image values outside the bounds of the image are assumed equal to the nearest image border value.
`'symmetric'`Input image values outside the bounds of the image are computed by mirror-reflecting the array across the array border.

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

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

The default `'NormalizationFactor'` has the effect of a mean filter—the pixels in the output image are the local means of the image over the neighborhood determined by `filterSize`. 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`.

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

Output Arguments

collapse all

Filtered image, returned as a real, nonsparse matrix, the same size as the input image.

Algorithms

`imboxfilt` performs filtering using either convolution-based filtering or integral image filtering, using an internal heuristic to determine which filtering approach to use.