---
title: "Sharpening Images"
canonical: https://www.graphicsmill.com/docs/gm5/SharpeningImages.htm
product: "Graphics Mill 5.5 for .NET"
---

This documentation is for the old version. [Go to the latest Graphics Mill docs](https://www.graphicsmill.com/docs/gm/)

# Sharpening Images
 
To make image looking more sharp, Graphics Mill for .NET provides two ways: simple sharpen filter and unsharp mask. This article demonstrates how to use both of them.
 
## Sharpen
  
The common sharpen filter is easy to use. It has the single intuitive parameter - sharpen strength, which varies in range [0,100]. The higher sharpen strength you specify, the more strong sharpness you will get.
 
In Graphics Mill for .NET this filter is represented by transform [Sharpen](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Transforms_Sharpen.htm.md). The filter stength is specified with the property [Strength](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Transforms_Sharpen_Strength.htm.md). For shorter syntax, you can also use [Sharpen(Int32)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_TransformsProvider_Sharpen_1_e1836fc4.htm.md) method of the [TransformsProvider](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_TransformsProvider.htm.md) returned by the [Bitmap](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Bitmap.htm.md).
 
The figures below demonstrate a result of this filter.
 
Source image:
 
![Source image](https://www.graphicsmill.com/docs/gm5/flower_small.jpg)
 
Sharpened image:
 
![Sharpened image](https://www.graphicsmill.com/docs/gm5/sharpen.jpg)
 
Use this code to get above result:
 
```
'Sharpen the image (strongly)
bitmap.Transforms.Sharpen(95)
```
 
```csharp
//Sharpen the image (strongly)
bitmap.Transforms.Sharpen(95);
```
 
The same, but using Sharpen class.
 
```
'Sharpen the image (strongly)
Dim sharpen As New Aurigma.GraphicsMill.Transforms.Sharpen
sharpen.Strength = 95
sharpen.ApplyTransform(bitmap)
```
 
```csharp
//Sharpen the image (strongly)
Aurigma.GraphicsMill.Transforms.Sharpen sharpen =
    new Aurigma.GraphicsMill.Transforms.Sharpen();
sharpen.Strength = 95;
sharpen.ApplyTransform(bitmap);
```
 
Note, specifying high values of the sharpen strength will produce color distortions (see the figure below).
 
![Sharpened image with color distortions](https://www.graphicsmill.com/docs/gm5/sharpen95.jpg)
 
## Unsharp Mask
  
Sharpen filter is simple to use, but provides too few control. That's why there is an alternative and more advanced sharpening algorithm - unsharp mask.
 
Unsharp mask is a classic sharpening technique, which was widely used by photographers in precomputer times. The main idea is to blend image with blurred (out-of-focus) version. It will emphasis edges and make the image more sharp.
 
To apply unsharp mask algorithm, Graphics Mill for .NET provides a transform class [UnsharpMask](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Transforms_UnsharpMask.htm.md) (and appropriate [UnsharpMask](https://www.graphicsmill.com/docs/gm5/O_T_Aurigma_GraphicsMill_TransformsProvider_UnsharpMask.htm.md) method of the TransformsProvider returned by the Bitmap). It contains three parameters: the *amount* of sharpen, the *radius* of blur and the *threshold*.
 
The first parameter specifies how strong to sharpen the image. As mentioned above, algorithm creates blurred version of the image and for each pixel calculate the difference between original and blurred image. After that, it uses this difference to shapen image. Actually, Graphics Mill for .NET adds *difference\*amount* to each pixel of the original image. This parameter is modified with an [Amount](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Transforms_UnsharpMask_Amount.htm.md) property.
 
The second parameter specifies radius of blur effect which creates defocused image. The higher value you specify, the wider will be edges. That's why be carefull when you adjust this parameter - big radius will lead to unnatural effects (false halo around objects of the image). This parameter is modified with a [Radius](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Transforms_UnsharpMask_Radius.htm.md) property.
 
The third parameter specifies a threshold of the effect. If difference between pixels of original and blurred images is less than threshold, difference is discarded. It allow to keep minor details unchanged and apply sharpening only on noticeable details. For example, if you sharpen a photo which contains face, you would like to sharpen facial features (nose, lips, eyes, etc), but do not emphasis pimples, birthmark and other minor details. This parameter is modified with a [Threshold](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Transforms_UnsharpMask_Threshold.htm.md) property.
 
As you see, using unsharp mask is harder to use comparing to sharpen filter, but it allows producing much better result. The figure below demonstrates an example of unsharp mask result.
 
![Unsharp mask result](https://www.graphicsmill.com/docs/gm5/unsharpmask2.jpg)
 
The code below demonstrates how to get this image:
 
```
'Sharpen image via unsharp mask
bitmap.Transforms.UnsharpMask(1.5, 2.1, 0.04)
```
 
```csharp
//Sharpen image via unsharp mask
bitmap.Transforms.UnsharpMask(1.5f, 2.1f, 0.04f);
```
 
The same, but using UnsharpMask class.
 
```
'Sharpen image via unsharp mask
Dim unsharpMask As New Aurigma.GraphicsMill.Transforms.UnsharpMask
unsharpMask.Amount = 1.5
unsharpMask.Radius = 2.1
unsharpMask.Threshold = 0.04
unsharpMask.ApplyTransform(bitmap)
```
 
```csharp
//Sharpen image via unsharp mask
Aurigma.GraphicsMill.Transforms.UnsharpMask unsharpMask =
    new Aurigma.GraphicsMill.Transforms.UnsharpMask();
unsharpMask.Amount = 1.5f;
unsharpMask.Radius = 2.1f;
unsharpMask.Threshold = 0.04f;
unsharpMask.ApplyTransform(bitmap);
```
