Main Content

stdfilt

Local standard deviation of image

Description

example

J = stdfilt(I) performs standard deviation filtering of image I and returns the filtered image J. The value of each output pixel is the standard deviation of the 3-by-3 neighborhood around the corresponding input pixel. For pixels on the borders of I, stdfilt uses symmetric padding. In symmetric padding, the values of padding pixels are a mirror reflection of the border pixels in I.

J = stdfilt(I,nhood) specifies the neighborhood, nhood, used to compute the standard deviation.

Examples

collapse all

This example shows how to perform standard deviation filtering using stdfilt. Brighter pixels in the filtered image correspond to neighborhoods in the original image with larger standard deviations.

Read an image into the workspace.

I = imread('circuit.tif');

Perform standard deviation filtering using stdfilt.

J = stdfilt(I);

Show the original image and the processed image.

imshow(I)
title('Original Image')

figure
imshow(J,[])
title('Result of Standard Deviation Filtering')

Input Arguments

collapse all

Image to be filtered, specified as a numeric array or logical array of any dimension.

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

Neighborhood, specified as a numeric or logical array containing 0s and 1s. The size of nhood must be odd in each dimension.

By default, stdfilt uses the neighborhood true(3). stdfilt determines the center element of the neighborhood by floor((size(nhood) + 1)/2).

To specify neighborhoods of various shapes, such as a disk, use the strel function to create a structuring element object of the desired shape. Then extract the neighborhood from the neighborhood property of the structuring element.

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

Output Arguments

collapse all

Filtered image, returned as a numeric array of the same size as the input image I. The class of J is double.

Algorithms

If the image contains Infs or NaNs, then the behavior of stdfilt is undefined. Propagation of Infs or NaNs might not be localized to the neighborhood around the Inf or NaN pixel.

Extended Capabilities

Introduced before R2006a