直方图均衡化变换函数 [英] histogram equalization transformation function
问题描述
假定给定的大小为64 * 64像素(M * N = 4096)的3位图像(L = 8)具有如下所示的强度分布.如何获得直方图均衡变换函数 然后计算图像的均匀直方图?
Suppose that a given 3-bit image(L=8) of size 64*64 pixels (M*N=4096) has the intensity distribution shown as below. How to obtain histogram equalization transformation function and then compute the equalized histogram of the image?
Rk nk
0 800
1 520
2 970
3 660
4 330
5 450
6 260
7 106
推荐答案
直方图均衡是自动获取变换函数的过程.因此,您不必担心变换函数的形状和性质"
因此,在直方图均衡中,使用累积频率方法计算变换函数,并且此过程是自动的.根据图像的直方图,我们确定累积直方图c
,并随即对这些值进行重新缩放,以使其占据8位范围.这样,c
成为一个查找表,可以随后将其应用于图像以进行均衡.
So in Histogram equalization, transformation function is calculated using cumulative frequency approach and this process is automatic. From the histogram of the image, we determine the cumulative histogram, c
, rescaling the values as we go so that they occupy an 8-bit range. In this way, c
becomes a look-up table that can be subsequently applied to the image in order to carry out equalization.
rk nk c sk = c/MN (L-1)sk rounded value
0 800 800 0.195 1.365 1
1 520 1320 0.322 2.254 2
2 970 2290 0.559 3.913 4
3 660 2950 0.720 5.04 5
4 330 3280 0.801 5.601 6
5 450 3730 0.911 6.377 6
6 260 3990 0.974 6.818 7
7 106 4096 1.000 7.0 7
因此,现在均衡后的直方图是
Now the equalized histogram is therefore
rk nk
0 0
1 800
2 520
3 0
4 970
5 660
6 330 + 450 = 780
7 260 + 106 = 366
均衡算法可以表示为
Compute a scaling factor, α= 255 / number of pixels
Calculate histogram of the image
Create a look up table c with
c[0] = α * histogram[0]
for all remaining grey levels, i, do
c[i] = c[i-1] + α * histogram[i]
end for
for all pixel coordinates, x and y, do
g(x, y) = c[f(x, y)]
end for
但是直方图均衡化存在一个问题,主要是因为它是一种完全自动化的技术,无需设置任何参数.有时,它可以提高我们显着解释图像的能力.但是,很难预测任何给定图像的均衡效果如何;实际上,它可能根本没有用.这是因为对比度的改进在统计上而非视觉上是最佳的.在具有窄直方图和相对较少的灰度级的图像中,由于直方图均衡化导致的对比度的大量增加可能具有降低感知图像质量的不利影响.尤其是采样或量化伪像和图像噪声可能会变得更加突出.
But there is a problem with histogram equalization and that is mainly because it is a completely automatic technique, with no parameters to set. At times, it can improve our ability to interpret an image dramatically. However, it is difficult to predict how beneficial equalization will be for any given image; in fact, it may not be of any use at all. This is because the improvement in contrast is optimal statistically, rather than perceptually. In images with narrow histograms and relatively few grey levels, a massive increase in contrast due to histogram equalisation can have the adverse effect of reducing perceived image quality. In particular, sampling or quantisation artefacts and image noise may become more prominent.
直方图规范是自动获取变换(映射)功能的替代方法.在直方图规范中,我们不需要明确的直方图,而是明确指定了特定形状.如果希望一组相关图像具有相同的直方图,则我们可能希望这样做,以便某个特定操作对所有图像产生相同的结果. 直方图规范可以可视化为两个阶段的过程.首先,我们通过均衡将输入图像转换为具有平坦直方图的临时图像.然后,我们将此均衡的临时图像转换为具有所需直方图的输出图像.第二阶段的映射功能很容易获得.由于累积直方图的重新缩放版本可用于将任何形状的直方图转换为平面直方图,因此,累积直方图的反方向将执行从法定直方图到具有指定形状的直方图的反变换.
The alternative to obtaining the transformation (mapping) function automatically is Histogram Specification. In histogram specification instead of requiring a flat histogram, we specify a particular shape explicitly. We might wish to do this in cases where it is desirable for a set of related images to have the same histogram- in order, perhaps, that a particular operation produces the same results for all images. Histogram specification can be visualised as a two-stage process. First, we transform the input image by equalisation into a temporary image with a flat histogram. Then we transform this equalised, temporary image into an output image possessing the desired histogram. The mapping function for the second stage is easily obtained. Since a rescaled version of the cumulative histogram can be used to transform a histogram with any shape into a flat histogram, it follows that the inverse of the cumulative histogram will perform the inverse transformation from a fiat histogram to one with a specified shape.
有关使用C和C ++代码的直方图均衡和映射函数的更多详细信息 https://programming-technique.blogspot. com/2013/01/histogram-equalization-using-c-image.html
For more details about histogram equalization and mapping functions with C and C++ code https://programming-technique.blogspot.com/2013/01/histogram-equalization-using-c-image.html
这篇关于直方图均衡化变换函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!