imsharpen

Sharpen image using unsharp masking

Syntax

Description

example

B = imsharpen(A) returns an enhanced version of the grayscale or truecolor (RGB) input image A, where the image features, such as edges, have been sharpened using the unsharp masking method.

example

B = imsharpen(A,Name,Value,...) sharpens the image using name-value pairs to control aspects of unsharp masking. Parameter names can be abbreviated.

Examples

expand all

Sharpen an Image

Read image and display it.

a = imread('hestain.png');
imshow(a), title('Original Image');

Sharpen the image and display sharpened version.

b = imsharpen(a);
figure, imshow(b), title('Sharpened Image');

Control the Amount of Sharpening at the Edges

Read image and display it.

a = imread('rice.png');
imshow(a), title('Original Image');

Sharpen image, specifying the radius and amount parameters.

b = imsharpen(a,'Radius',2,'Amount',1);
figure, imshow(b), title('Sharpened Image');

Input Arguments

expand all

A — Grayscale or truecolor (RGB) image to be enhancednonsparse numeric array

Grayscale or truecolor (RGB) image to be enhanced, specified as a nonsparse, numeric array.

If A is a truecolor (RGB) image, imsharpen converts the image to the L*a*b* colorspace, applies sharpening to the L* channel only, and then converts the image back to the RGB colorspace before returning it as the output image B.

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

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

Example: ‘Radius', 1.5

'Radius' — Standard deviation of the Gaussian lowpass filter1 (default) | numeric

Standard deviation of the Gaussian lowpass filter, specified as a numeric value. This value controls the size of the region around the edge pixels that is affected by sharpening. A large value sharpens wider regions around the edges, whereas a small value sharpens narrower regions around edges.

Example: ‘Radius', 1.5

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

'Amount' — Strength of the sharpening effect0.8 (default) | numeric

Strength of the sharpening effect, specified as a numeric value. A higher value leads to larger increase in the contrast of the sharpened pixels. Typical values for this parameter are within the range [0 2], although values greater than 2 are allowed. Very large values for this parameter may create undesirable effects in the output image.

Example: 'Amount',1.2

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

'Threshold' — Minimum contrast required for a pixel to be considered an edge pixel0 (default) | scalar in the range [0 1]

Minimum contrast required for a pixel to be considered an edge pixel, specified as a scalar in the range [0 1]. Higher values (closer to 1) allow sharpening only in high-contrast regions, such as strong edges, while leaving low-contrast regions unaffected. Lower values (closer to 0) additionally allow sharpening in relatively smoother regions of the image. This parameter is useful in avoiding sharpening noise in the output image.

Example: 'Threshold', 0.7

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

Output Arguments

expand all

B — Sharpened imagenonsparse array the same size and class as the input image.

Image that has been sharpened, returned as a nonsparse array the same size and class as the input image.

More About

expand all

sharpening

Sharpness is actually the contrast between different colors. A quick transition from black to white looks sharp. A gradual transition from black to gray to white looks blurry. Sharpening images increases the contrast along the edges where different colors meet.

Unsharp masking

The unsharp masking technique comes from a publishing industry process in which an image is sharpened by subtracting a blurred (unsharp) version of the image from itself. Do not be confused by the name of this filter: an unsharp filter is an operator used to sharpen an image.

Was this topic helpful?