主要内容

Contrast Enhancement Techniques

This example shows several image enhancement approaches. Three functions are particularly suitable for contrast enhancement:imadjust,histeq,和Adapthisteq.。此示例比较了它们用于增强灰度和TrueColor图像的用途。

Enhance Grayscale Images

Using the default settings, compare the effectiveness of the following three techniques:

  • imadjustincreases the contrast of the image by mapping the values of the input intensity image to new values such that, by default, 1% of the data is saturated at low and high intensities of the input data.

  • histeq执行直方图均衡。它通过在强度图像中转换值来增强图像的对比度,使得输出图像的直方图大致匹配指定的直方图(默认均匀分布)。

  • Adapthisteq.performs contrast-limited adaptive histogram equalization. Unlikehisteq, it operates on small data regions (tiles) rather than the entire image. Each tile's contrast is enhanced so that the histogram of each output region approximately matches the specified histogram (uniform distribution by default). The contrast enhancement can be limited in order to avoid amplifying the noise which might be present in the image.

在工作区中读取灰度图像。使用三个对比度调整技术增强图像。

pout = imread('pout.tif');pout_imadjust = imadjust(pout); pout_histeq = histeq(pout); pout_adapthisteq = adapthisteq(pout);

显示原始图像,三个对比度调整图像作为蒙太奇。

蒙太奇({POUT,POUT_IMADJUST,POUT_HISTEQ,POUT_ADAPTHISTEQ},'Size',[1 4]) title("Original Image and Enhanced Images using imadjust, histeq, and adapthisteq")

将第二个灰度图像读入工作区并使用三个对比度调整技术增强图像。

tire = imread('tire.tif');tire_imadjust = imadjust(轮胎);tire_histeq =组合(轮胎);tire_adapthisteq = adapthisteq(轮胎);

显示原始图像,三个对比度调整图像作为蒙太奇。

montage({tire,tire_imadjust,tire_histeq,tire_adapthisteq},'Size',[1 4]) title("Original Image and Enhanced Images using imadjust, histeq, and adapthisteq")

Notice thatimadjusthad little effect on the image of the tire, but it caused a drastic change in the case of pout. Plotting the histograms ofpout.tif.Tire.tif.揭示第一图像中的大多数像素集中在直方图的中心,而在此情况下Tire.tif.,这些值已经在最小0之间散布,最大255°因此预防imadjustfrom being effective in adjusting the contrast of the image.

图形子图(1,2,1)IMHIST(POUT)标题('Histogram of pout.tif') subplot(1,2,2) imhist(tire) title('Histogram of tire.tif');

另一方面,直方图均衡基本上改变了两个图像。许多以前隐藏的特征暴露,特别是轮胎上的碎屑颗粒。不幸的是,同时,增强过度饱和两个图像的几个区域。请注意轮胎的中心,孩子的脸部,夹克都被冲了出来。

Concentrating on the image of the tire, it would be preferable for the center of the wheel to stay at about the same brightness while enhancing the contrast in other areas of the image. In order for that to happen, a different transformation would have to be applied to different portions of the image. The Contrast-Limited Adaptive Histogram Equalization technique, implemented inAdapthisteq., can accomplish this. The algorithm analyzes portions of the image and computes the appropriate transformations. A limit on the level of contrast enhancement can also be set, thus preventing the over-saturation caused by the basic histogram equalization method ofhisteq。This is the most sophisticated technique in this example.

增强彩色图像

Contrast enhancement of color images is typically done by converting the image to a color space that has image luminosity as one of its components, such as the L*a*b* color space. Contrast adjustment is performed on the luminosity layer 'L*' only, and then the image is converted back to the RGB color space. Manipulating luminosity affects the intensity of the pixels, while preserving the original colors.

Read an image into the workspace. The'shadow.tif'image is an indexed image, so convert the image to a truecolor (RGB) image. Then, convert the image from the RGB color space to the L*a*b* color space.

[x,地图] = imread('shadow.tif');shadow = Ind2RGB(X,地图);shadow_lab = rgb2lab(阴影);

The values of luminosity span a range from 0 to 100. Scale the values to the range [0 1], which is the expected range of images with data typedouble

max_luminosity = 100; L = shadow_lab(:,:,1)/max_luminosity;

在亮度通道上执行三种类型的对比度调整,并保持A *和B *通道不变。将图像转换回RGB颜色空间。

shadow_imadjust = shadow_lab; shadow_imadjust(:,:,1) = imadjust(L)*max_luminosity; shadow_imadjust = lab2rgb(shadow_imadjust); shadow_histeq = shadow_lab; shadow_histeq(:,:,1) = histeq(L)*max_luminosity; shadow_histeq = lab2rgb(shadow_histeq); shadow_adapthisteq = shadow_lab; shadow_adapthisteq(:,:,1) = adapthisteq(L)*max_luminosity; shadow_adapthisteq = lab2rgb(shadow_adapthisteq);

显示原始图像,三个对比度调整图像作为蒙太奇。

图蒙太奇({shadow,shadow_imadjust,shadow_histeq,shadow_adapthisteq},'Size',[1 4]) title("Original Image and Enhanced Images using imadjust, histeq, and adapthisteq")

See Also

||

相关话题