imsharpen
Sharpen image using unsharp masking
Description
sharpens the grayscale or truecolor (RGB) image
B
= imsharpen(A
)A
by using the unsharp
masking method.
uses name-value arguments to control aspects of the unsharp
masking.B
= imsharpen(A
,Name,Value
)
Examples
Sharpen Image
Read an image into the workspace and display it.
a = imread('hestain.png'); imshow(a) title('Original Image');
Sharpen the image using the imsharpen
function and display it.
b = imsharpen(a);
figure, imshow(b)
title('Sharpened Image');
Control the Amount of Sharpening at the Edges
Read an image into the workspace and display it.
a = imread("rice.png"); imshow(a) title("Original Image")
Sharpen the image, specifying the Radius
and Amount
parameters.
b = imsharpen(a,Radius=2,Amount=1);
imshow(b)
title("Sharpened Image");
Input Arguments
A
— Image to be sharpened
grayscale image | RGB image
Image to be sharpened, specified as a grayscale or RGB image.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: B = imsharpen(A,Radius=1.5);
performs
sharpening using a Gaussian lowpass filter with standard deviation
1.5
.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: B =
imsharpen(A,"Radius",1.5);
Radius
— Standard deviation of Gaussian lowpass filter
1
(default) | positive number
Standard deviation of the Gaussian lowpass filter, specified as a positive number. This argument 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 sharpening effect
0.8
(default) | number
Strength of the sharpening effect, specified
as a number. A larger 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 argument 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 pixel
0
(default) | number in the range [0, 1]
Minimum contrast required for a pixel to be considered an edge pixel, specified as a number in the range [0, 1]. Larger values (closer to 1) allow sharpening only in high-contrast regions, such as strong edges, while leaving low-contrast regions unaffected. Smaller values (closer to 0) additionally allow sharpening in relatively smoother regions of the image. This argument 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
B
— Sharpened image
numeric array
Sharpened image, returned as a numeric array of the
same size and data type as the input image
A
.
More About
Sharpening
Sharpness is 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.
Tips
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
imsharpen
supports the generation of C
code (requires MATLAB®
Coder™). For more information, see Code Generation for Image Processing.
Version History
Introduced in R2013aR2022a: Changed color space conversion operations for RGB images
Starting in R2022a, imsharpen
uses different
color space conversion operations to sharpen RGB images. In R2021b
and earlier, the imsharpen
function performed
the color space conversions using the makecform
and applycform
functions. Starting in R2022a,
the imsharpen
function performs the color space
conversions using the rgb2lab
and
lab2rgb
functions.
The new operations yield different results for sharpened RGB images. If
you need to reproduce the old behavior, then you can replace the
call to imsharpen
with a call to the
images.compatibility.imsharpen.r2021b.imsharpen
function instead. You do not need to change the input
arguments.
R2022a: Generate C code using MATLAB Coder
imsharpen
now supports the generation of
C code (requires MATLAB
Coder).
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)