Transform operation on histogram of image

Source: Internet
Author: User
Tags range

Objective

Image enhancement processing technology has been a very important basic image processing technology in the field of image processing. By taking appropriate enhancements, the original images that were blurred or even indistinguishable could be processed into a clear, clear and rich in useful information of the use of target images, so this kind of image processing technology in medicine, remote sensing, microbiology, criminal investigation and military and many other scientific research and application fields to the original image pattern recognition, Target detection and so on plays an important role. In this paper, we will introduce the method of gray histogram enhancement processing from the angle of space domain in detail.

Image Gray-level histogram processing technology

There are many ways to enhance image processing in the airspace, such as enhanced contrast and dynamic range compression, and so on, but these processing methods are aimed at each pixel of the original image directly to its grayscale processing, The processing process is mainly through the enhancement function to the pixel gray level operation and the result of the operation as the new gray value of the pixel to achieve. The different processing results can be obtained by changing the analytic expression of the selected enhancement function, which is more flexible and convenient, and the processing effect is quite good, but it is not obvious that the image with dense or weak contrast can play a certain enhancement effect. For this kind of situation, we need to use the gray histogram transform method proposed in this paper to compare the density of the original image of the gray distribution, so as to enlarge the contrast of the image and to achieve a significantly enhanced visual effect, so that some of the details can not be easily observed to become clear and debate.

The gray-scale transformation of image is realized by changing the probability distribution of each pixel of the original image at each gray level. A one-dimensional discrete image gray-level histogram function P (SK) =nk/n (k=0,1,2,......, L-1) can be obtained by statistical analysis of the gray value of the image. The expression of the number of pixels on the K-gray level, NK accounted for the total number of pixels n ratio, p (SK) gives the probability of the occurrence of SK 1 estimates. Therefore, the histogram function is actually the reflection of the distribution of the gray level of the image, in other words, it gives the whole description of all the gray values of the image. This function can clearly understand the dynamic range of the image corresponding to the image of the main concentration range of gray. Therefore, the image enhancement program can be used to change the histogram of gray distribution, so that the gray scale evenly or according to the expected target distribution and the entire gray scale space, so as to enhance the image contrast effect. This method is based on mathematical statistics and probability theory, which is much better than the contrast enhancement effect of the original image directly in the airspace. In practical application, there are two kinds of transformation of straight square graph, such as equilibrium transformation and regulation transformation, and the latter is based on different mapping rules and group mapping rules of gray level mapping rules.

The equalization of histogram processing

The central idea of the histogram equalization process is to change the gray histogram of the original image from one gray region of the relative set to the uniform distribution in the whole gray range. The enhancement process of the image spatial point is accomplished by the enhancement function T=eh (s), the T and S are respectively the target image and the pixel Point (x,y) on the original image, and the reinforcement function eh needs to meet two conditions in the equalization processing: the enhanced function eh (s) Within the range of 0≤S≤L-1 is a monotone increment function, which ensures that the gray order of the original image is not disturbed when the enhancement is processed. Another condition to be satisfied is that the 0≤s≤l-1 should have 0≤eh (s) ≤l-1, which guarantees the consistency of the dynamic range of the grayscale values of the transformation process. Similarly, for the reverse transformation process s=eh-1 (t), the above two conditions must be met when 0≤t≤1. The cumulative distribution function (cumulative distribution FUNCTION,CDF) is a kind of satisfying the above conditions, through which the uniform distribution transformation of s to T can be accomplished. The enhanced conversion equation at this point is:

tk = EH(sk) = ∑(ni/n) = ∑ps(si) ,(k=0,1,2,……,L-1)

The summation interval is 0 to K, according to which the gray value of each pixel can be obtained directly from the pixel gray value of the source image. In the actual process of transformation, the original image of the gray level of the first statistical analysis, and calculate the original histogram distribution, and then according to the calculated cumulative histogram distribution TK by type tk=[(N-1) * tk+0.5] to its integer and obtain the source gray-level SK to TK gray mapping relationship, where N is the level of gray scale. In order to achieve the histogram equalization of the source graph, the pixel of the source image is converted to gray level by the new mapping relation after the above steps are obtained by the mapping relation of all the gray level to the target image. Here are some of the main program codes implemented according to the above algorithm:

At first, the gray level of each pixel in the original image is calculated statistically. For 24-bit BMP images, the image array starts with the 54th byte, and each pixel occupies 3 bytes in the order of R, G, and B.

or(DWORD i=54;i<m_dwFileLen;i++)
{
 ns_r[m_cpBuffer[i]]++; //ns_r[k]为k灰度级像素数,m_cpBuffer[i]为当前的灰度值
 i++;
 ns_g[m_cpBuffer[i]]++;//ns_g为G分量的统计记数
 i++;
 ns_b[m_cpBuffer[i]]++;//ns_b为B分量的统计记数
}
for(i=0;i<256;i++) //计算R、G、B三分量的直方图分布
{
 ps_r[i]=ns_r[i]/((m_dwFileLen-54)/3.0f); //ps_r[i]为R分量中i灰度级出现的概率
 ps_g[i]=ns_g[i]/((m_dwFileLen-54)/3.0f); //ps_b[i]为G分量中i灰度级出现的概率
 ps_b[i]=ns_b[i]/((m_dwFileLen-54)/3.0f); //ps_b[i]为B分量中i灰度级出现的概率
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.