<< linkage Image_Processing_Tool_3 medfilt2 >>

Image_Processing_Tool_3 >> Image_Processing_Tool_3 > maskthresh

maskthresh

Computes threshold for binarization by using a edge or unsharp mask

Calling Sequence

thr = maskthresh(x)
thr = maskthresh(x,f)

Parameters

x

A matrix representing a gray scale image.

f

A matrix representing a 2D edge or unsharm mask.

thr

A scalar value representing a threshold value for binarizing the gray scale image.

Description

It computes a threshold value automatically using an edge or unsharp mask. It takes two inputs, gray scale image x and a filter mask f. The image is filtered with the given mask. If the mask is not given, it uses a default mask. Threshold value is then computed by dividing the sum of the product of the filtered image and original image by the sum of the filtered image. The threshold value of a symmetric edge mask is less than threshold value of an unsharp mask.

Examples

x=imread('lena.png');
x=double(rgb2gray(x)); // gray scale image matrix

// threshold estimation using edge mask 

f=[-2 1 -2; 1 4 1; -2 1 -2]; // edge mask
e_thr=maskthresh(x,f); // computing threshold
y=x>=e_thr;     // binarization
imshow(y)   // displaying the binarized image y

// threshold estimation using unsharp mask

f=[-1 1 -1; 1 1 1; -1 1 -1]; // unsharp mask
u_thr=maskthresh(x,f); // computing threshold
y=x>=u_thr;     // binarization
imshow(y)   // displaying the binarized image y

// average threshold 
thr=(e_thresh + u_thresh)/2;
imshow(x>=thr) // displaying binarized image at average threshold

See Also

Authors

<< linkage Image_Processing_Tool_3 medfilt2 >>