主要内容

histeq

Enhance contrast using histogram equalization

描述

example

J= histeq (I,h)转换灰度图像Iso that the histogram of the output grayscale imageJwithlength(hgram)bins approximately matches the target histogramh

J= histeq (I,n)转换灰度图像Iso that the histogram of the output grayscale imageJwithn箱大约是平的。直方图Jis flatter whennis much smaller than the number of discrete levels inI

J= histeq (I)转换灰度图像Iso that the histogram of the output grayscale imageJhas 64 bins and is approximately flat.

newmap= histeq (X,地图)transforms the values in the color map so that the histogram of the gray component of the indexed imageXis approximately flat. The transformed color map isnewmap

newmap= histeq (X,地图,h)将与索引图像相关联的颜色映射转换Xso that the histogram of the gray component of the indexed image (X,newmap)大致匹配目标直方图h。该histeqfunction returns the transformed color map innewmaplength(hgram)must be the same as大小(地图,1)

[___,T] = histeq(___)also returns the transformationTthat maps the gray component of the input grayscale image or color map to the gray component of the output grayscale image or color map.

例子

collapse all

将图像读入工作区。

I = imread('tire.tif');

Enhance the contrast of an intensity image using histogram equalization.

j =组合(i);

Display the original image and the adjusted image.

imshowpair(我,j,'montage') axis关闭

Display a histogram of the original image.

图imhist(我,64)

Display a histogram of the processed image.

图imhist(J,64)

加载3-D数据集。

loadmristack

Perform histogram equalization.

enhanced = histeq(mristack);

Display the first slice of data for the original image and the contrast-enhanced image.

figure subplot(1,2,1) imshow(mristack(:,:,1)) title('Slice of Original Image') subplot(1,2,2) imshow(enhanced(:,:,1)) title('Slice of Enhanced Image')

Input Arguments

collapse all

输入灰度图像,指定为任何维度的数字数组。

Data Types:single|double|int16|uint8|uint16

目标直方图, specified as a numeric vector.h在适当的范围内具有强度值的平等间隔箱:

  • [0, 1] for images of classdouble要么single

  • [0, 255] for images of classuint8

  • [0, 65535] for images of classuint16

  • [-32768, 32767] for images of classint16

histeqautomatically scaleshso thatsum(hgram)=numel(I)。直方图J更好的比赛hwhenlength(hgram)is much smaller than the number of discrete levels inI

Data Types:single|double

离散灰度级数, specified as a positive integer.

Data Types:single|double

索引图像, specified as a numeric array of any dimension. The values inXare an index into the color map地图

Data Types:single|double|uint8|uint16

彩色地图, specified as ac-3个数字矩阵范围内的值[0,1]。每行是一个三个元素的RGB三元组,指定颜色图的单个颜色的红色,绿色和蓝色组件。

Data Types:double

Output Arguments

collapse all

Transformed grayscale image, returned as a numeric array of the same size and class as the input imageI

Grayscale transformation, returned as a numeric vector. The transformationT映射图像中的灰色级别Ito gray levels inJ

Data Types:double

Transformed color map, specified as ann-3个数字矩阵范围内的值[0,1]。每行是一个三个元素的RGB三元组,指定颜色图的单个颜色的红色,绿色和蓝色组件。

Data Types:double

算法

When you supply a desired histogramh,histeqchooses the grayscale transformationT最小化

| c 1 ( T ( k ) ) c 0 ( k ) | ,

c0是输入图像的累积直方图I,和c1is the cumulative sum ofhfor all intensitiesk。This minimization is subject to these constraints:

  • T必须是单调的

  • c1(t(a))不能过度c0(a)直方图计数之间的距离超过一半a

histequses the transformationb=T(a)映射灰度级别X(or the color map) to their new values.

If you do not specifyh, thenhisteqcreates a flath,

h= ones(1,n)*prod(size(A))/n;

and then applies the previous algorithm.

Extended Capabilities

在R2006A之前介绍