This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

stdfilt

Local standard deviation of image

Syntax

J = stdfilt(I)
J = stdfilt(I,nhood)

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.

You optionally can perform the operation using a GPU (requires Parallel Computing Toolbox™). For more information, see Image Processing on a GPU.

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')

Read an images into a gpuArray.

I = gpuArray(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 or logical array of any dimension.

To perform the operation using a GPU, specify I as a gpuArray that contains a numeric or logical array.

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

Neighborhood, specified as a multidimensional, logical, or numeric array containing zeros and ones. 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.

Note

When running this function on a GPU, the neighborhood must be 2-D.

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.

If the filtered image is computed using a GPU, then J is returned as a gpuArray containing a numeric array of the same class as in I.

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