Home > Web Front-end > PS Tutorial > body text

Quick implementation of PS tone equalization filter (C# source code).

高洛峰
Release: 2017-02-15 09:59:29
Original
1634 people have browsed it

The tone equalization function of photoshop is usually one of the more commonly used functions in the early stage of photo retouching. It plays a certain role in expanding the contrast of the image and enhancing the visual effect. In many textbooks or articles, this kind of processing is also called gray equalization, histogram equalization, etc. The principle of the algorithm is to count the histogram of the original image, and then re-project the histogram data through the cumulative distribution function, so that the distribution probability of each color level is adjusted in the same direction. The descriptions of this process in the codes I have seen on the Internet or in some textbooks are quite redundant. Either the code is cumbersome and inefficient, or it is too long-winded and very uncomfortable.

Before giving my code, there are some issues that need to be explained. For grayscale images, since there is only one channel, this problem is not obvious. For common 24-bit images, since there are three RGB channels, there is a question of whether each channel is equalized individually or the three channels jointly calculate the histogram, and then use the same The mapping table reflects RGB data. After my testing, in Photoshop, the latter is used.

    for (Y = 0; Y <p></p><p><span style="font-size: 13px; font-family: 宋体;"> The algorithm part is just such a simple twenty-odd lines of code. The code is clear and the execution efficiency is very high. It is common in digital cameras. A photo of 4000*3000 can be processed within 100ms. </span></p><p><span style="font-size: 13px; font-family: 宋体;"> If an image is subjected to hue equalization once, then no pixels should be transformed if hue equalization is performed again. </span></p><p><span style="font-size: 13px; font-family: 宋体;"> Broadly speaking, hue equalization can be seen as a special case of histogram matching, that is, the matched histogram is distributed as a horizontal line. </span></p><p><span style="font-size: 13px; font-family: 宋体;"> The tone equalization in some books corrects each channel separately. It seems that the effect of this processing can easily lead to mismatch in the overall color of the image, such as the classic Lena picture: </span> </p><p><span style="font-size: 13px; font-family: 宋体;"> <img src="https://img.php.cn/upload/article/000/000/013/8eb48ac53c4b686a55a10d84272a9b1f-0.jpg" alt="Quick implementation of PS tone equalization filter (C# source code)."    style="max-width:90%"  style="max-width:90%" title="Quick implementation of PS tone equalization filter (C# source code)."> <img src="https://img.php.cn/upload/article/000/000/013/691628f7fd14aed82ce33125aefadd48-1.jpg" alt="Quick implementation of PS tone equalization filter (C# source code)."    style="max-width:90%"  style="max-width:90%" title="Quick implementation of PS tone equalization filter (C# source code)."> <img src="https://img.php.cn/upload/article/000/000/013/691628f7fd14aed82ce33125aefadd48-2.jpg" alt="Quick implementation of PS tone equalization filter (C# source code)."    style="max-width:90%"  style="max-width:90%" title="Quick implementation of PS tone equalization filter (C# source code)."></span></p><p>#                                                                                             The effect in Lang Rui’s textbook<span style="font-size: 13px; font-family: 宋体;"></span></p>More quick implementations of PS tone equalization filters (C# source code). For related articles, please pay attention to the PHP Chinese website! <p></p> <p></p>
Copy after login
Related labels:
ps
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template