If you need to implement color grading in your image editing application, this article is going to give you a simple yet useful solution. Particularly, you will learn how to adjust an image’s contrast, brightness and gamma in C# following a few simple steps.

Adjust Image Contrast, Brightness, and Gamma in C#

Contrast), brightness, and gamma are popular attributes that are used to tune images. Different values of these attributes are set to control and enhance the appearance of the images. In this article, we will show you how to adjust the contrast, brightness, and gamma of an image programmatically in C#. You can utilize this to implement image editing capabilities from within your .NET applications.

Adjust Image Contrast, Brightness, and Gamma in C# - API Installation

Aspose.Imaging for .NET is a powerful and feature-rich image processing API for .NET/.NET Standard platforms. It supports the manipulation of a wide range of image formats without writing complex code. We will use this API to adjust the contrast, brightness, and gamma of images in C#. You can download the API or install it into your .NET applications using NuGet.

PM> Install-Package Aspose.Imaging

Adjust Contrast of an Image in C#

The contrast is defined as the difference in pixel intensity. Its value is adjusted to make the objects in an image more visible and distinguishable. With high contrast, every object in the image looks very clear just like the photographs taken in the sunlight. Whereas, with low contrast, you hardly distinguish the objects just like in the foggy weather.

Let’s check out how to adjust the contrast of an image in C# using Aspose.Imaging for .NET.

The following code sample shows how to adjust the contrast of an image in C#.

The following is the comparison of input and output images after increasing the contrast value.

Adjust Contrast of Images in C#

Adjust Image Contrast

Adjust Brightness of an Image in C#

The brightness attribute usually controls the visibility of the objects in an image. Its value is adjusted to increase or decrease the darkness. The following are the steps to modify the brightness of an image in C#.

The following code sample shows how to adjust the brightness of an image in C#.

The following is the comparison of input and output images after adjusting brightness.

Adjust Brightness of Images in C#

Adjust Image Brightness

Modify Gamma of an Image in C#

The gamma attribute is used to modify the ratio of red, green, and blue colors in an image. Moreover, it also modifies the brightness of the image. The following are the steps to change the gamma value of an image in C#.

The following code sample shows how to adjust the gamma of an image in C#.

The following is the comparison of input and output images after adjusting gamma value.

Adjust Gamma of Images in C#

Adjust Image Gamma

Free License to Adjust Image’s Contrast and Brightness

You can get a free temporary license and adjust the image’s contrast, brightness, and gamma without evaluation limitations.

Conclusion

In this article, you have learned how to adjust the contrast, brightness, and gamma of images in C#. Furthermore, the code samples have demonstrated how an image looks after modifying the contrast, brightness, and gamma. In case you want to explore more about .NET image processing API, visit documentation. Also, download the complete source code samples of the API from GitHub. If you would have any questions or queries, reach us at our forum.

See Also