Main Content

imdiffuseest

Estimate parameters for anisotropic diffusion filtering

Description

example

[gradientThreshold,numberOfIterations] = imdiffuseest(I)estimates the gradient threshold and number of iterations required to filter the grayscale imageIusing anisotropic diffusion.

[gradientThreshold,numberOfIterations] = imdiffuseest(I,Name,Value)uses name-value pairs to change the behavior of the anisotropic diffusion algorithm.

Examples

collapse all

Read a grayscale image, then apply strong Gaussian noise to it. Display the noisy image.

I = imread('pout.tif'); Inoisy = imnoise(I,'gaussian',0,0.005); imshow(Inoisy) title('Noisy Image')

Figure contains an axes object. The axes object with title Noisy Image contains an object of type image.

Estimate the gradient threshold and number of iterations needed to perform anisotropic diffusion filtering of the image.

[gradThresh,numIter] = imdiffuseest(Inoisy)
gradThresh =1x5 uint8 row vector64 50 39 34 29
numIter = 5

Filter the noisy image by using anisotropic diffusion with the estimated parameters.

Idiffuseest = imdiffusefilt(Inoisy,'GradientThreshold',...gradThresh,'NumberOfIterations',numIter);

For comparison, also filter the noisy image by using anisotropic diffusion with the default parameters. The default gradient threshold is 25.5 because the data type of the image isuint8, and the default number of iterations is 5.

Idiffusedef = imdiffusefilt(Inoisy);

Visually compare the two filtered images.

montage({Idiffusedef,Idiffuseest},'ThumbnailSize',[]) title(['Anisotropic Diffusion Filtering Using '...'Default Parameters (Left) vs. Estimated Parameters (Right)'])

Figure contains an axes object. The axes object with title Anisotropic Diffusion Filtering Using Default Parameters (Left) vs. Estimated Parameters (Right) contains an object of type image.

Some noise remains in the image that was filtered using default parameters. The noise is almost completely absent from the image that was filtered using estimated parameters. The sharpness of edges in both images, especially high-contrast edges such as the trellis and white collar, is preserved.

Input Arguments

collapse all

Image to be filtered, specified as a 2-D grayscale image.

Data Types:single|double|int16|uint8|uint16

Name-Value Arguments

Specify optional comma-separated pairs ofName,Valuearguments.Nameis the argument name andValueis the corresponding value.Namemust appear inside quotes. You can specify several name and value pair arguments in any order asName1,Value1,...,NameN,ValueN.

Example:imdiffuseest(I,'Connectivity','minimal')estimates parameters required for anisotropic diffusion on imageI, using minimal connectivity.

Connectivity of a pixel to its neighbors, specified as the comma-separated pair consisting of'Connectivity'and'maximal'or'minimal'. Maximal connectivity considers eight nearest neighbors and minimal connectivity considers four nearest neighbors.

Conduction method, specified as the comma-separated pair consisting of'ConductionMethod'and'exponential'or'quadratic'. Exponential diffusion favors high-contrast edges over low-contrast edges. Quadratic diffusion favors wide regions over smaller regions.

Output Arguments

collapse all

Gradient threshold, returned as a numeric vector of the same data type as the input image,I. The length of the vector is equal tonumberOfIterations.

Number of iterations to use in the diffusion process, returned as a positive integer.

References

[1] Perona一起,P., and J. Malik. "Scale-space and edge detection using anisotropic diffusion."IEEE®Transactions on Pattern Analysis and Machine Intelligence. Vol. 12, No. 7, July 1990, pp. 629–639.

[2] Tsiotsios, C., and M. Petrou. "On the choice of the parameters for anisotropic diffusion in image processing."Pattern Recognition. Vol. 46, No. 5, May 2013, pp. 1369–1381.

See Also

Introduced in R2018a