GRAY HISTOGRAM OF MATLAB

一、什么是灰度直方图?

灰度直方图是灰度级的函数,它表示图象中具有每种灰度级的象素的个数,反映图象中每种灰度出现的频率。灰度直方图的横坐标是灰度级,纵坐标是该灰度级出现的频率,是图象的最基本的统计特征。

灰度直方图的基本性质

1.表征了图像的一维信息。只反映图像中像素不同灰度值出现的次数(或频数)而未反映像素所在位置。

2.与图像之间的关系是多对一的映射关系。一幅图像唯一确定出与之对应的直方图,但不同图像可能有相同的直方图。

3.子图直方图之和为整图的直方图。

直方图均衡仪的作用

直方图均衡化 通常用来增加许多图像的全局对比度,尤其是当图像的有用数据的对比度相当接近的时候。通过这种方法,亮度可以更好地在直方图上分布。这样就可以用于增强局部的对比度而不影响整体的对比度,直方图均衡化通过有效地扩展常用的亮度来实现这种功能。

我们来看一个灰度图像,让ni表示灰度i出现的次数,这样图像中灰度为i 的像素的出现概率是

L 是图像中所有的灰度数,n 是图像中所有的像素数, p 实际上是图像的直方图,归一化到 0..1。

把 c 作为对应于 p 的累计概率函数, 定义为:

c 是图像的累计归一化直方图。

我们创建一个形式为 y = T(x) 的变化,对于原始图像中的每个值它就产生一个 y,这样 y 的累计概率函数就可以在所有值范围内进行线性化,转换公式定义为:

yi = T(xi) = c(i)

一、图像信噪比的概念

 图像的信噪比应该等于信号与噪声的功率谱之比,但通常功率谱难以计算, 有一种方法可以近似估计图像信噪比,即信号与噪声的方差之比。首先计算图像所有象素的局部方差,将局部方差的最大值认为是信号方差,最小值是噪声方差,求出它们的比值,再转成dB数,最后用经验公式修正。

峰值信噪比经常用作图像压缩等领域中信号重建质量的测量方法,它常简单地通过均方差MSE)进行定义。两个m×n单色图像IK,如果一个为另外一个的噪声近似,那么它们的的均方差定义为:

峰值信噪比定义为:

其中,MAXI是表示图像点颜色的最大数值,如果每个采样点用 8 位表示,那么就是 255。更为通用的表示是,如果每个采样点用 B 位线性脉冲编码调制表示,那么 MAXI就是

对于每点有RGB三个值的彩色图像来说峰值信噪比的定义类似,只是均方差是所有方差之和除以图像尺寸再除以 3。

图像压缩中典型的峰值信噪比值在 30 到 40dB 之间,愈高愈好。

%%%%%%%%%%%%%%%%%

程序:I 是原图像,K是滤波后的图像,默认原图无噪声,测试那种滤波效果好)

video=mmreader('che2.AVI');
 I1=read(video,590);
I1=rgb2gray(I1);
[m,n]=size(I1);
J=imnoise(I1,'gaussian',0,0.002); %加入高斯噪声
%进行均值滤波
h=fspecial('average',3);    %fspecial函数用于产生预定义滤波器
I2=uint8(round(filter2(h,I1)));   %filter2函数用于图像滤波,此处h是滤波参数(均值),I1是要处理的图像
%进行中值滤波
I3=medfilt2(J,[3,3]);   %medfilt2函数用于图像的中值滤波
%进行维纳滤波
I4=wiener2(J,[3,3]);%进行一次维纳滤波
I5=wiener2(I4,[3,3]);%进行二次维纳滤波
subplot(2,3,1),imshow(I1),title('原图象')
subplot(2,3,2),imshow(J),title('加噪声图象')
subplot(2,3,3),imshow(I2),title('均值滤波后图象')
subplot(2,3,4),imshow(I3),title('中值滤波后图象')
subplot(2,3,5),imshow(I4),title('维纳滤波后图象')
I1=double(I1);
I2=double(I2);
I3=double(I3);
I4=double(I4);
I5=double(I5);
s2=0;
s2=double(s2);
s3=0;
s3=double(s3);
s4=0;
s4=double(s4);
s5=0;
s5=double(s5);
for i=1:m
    for j=1:n

      s2=s2+(I1(i,j)-I2(i,j))^2;
   s3=s3+(I1(i,j)-I3(i,j))^2;
   s4=s4+(I1(i,j)-I4(i,j))^2;
   s5=s5+(I1(i,j)-I5(i,j))^2;
    end
end
MSE2=s2/(m*n)
MSE3=s3/(m*n)
MSE4=s4/(m*n)
MSE5=s5/(m*n)
 PSNR2=10*log10(double(255^2/MSE2))
  PSNR3=10*log10(double(255^2/MSE3))
   PSNR4=10*log10(double(255^2/MSE4))
    PSNR5=10*log10(double(255^2/MSE5))

PSNR2 =                  

   33.6596

PSNR3 =

   32.6051

PSNR4 =

   33.8043

PSNR5 =

   34.3825

 







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
基于Matlab直方图Histogram的人脸识别程序-Processed histogram based Face Recognition.part1.rar 基于Matlab 直方图Histogram的人脸识别程序 因为数据库图片太大,所以分成几个压缩文件。 Face recognition 原理介绍: matlab12.jpg Recognizing objects from large image databases, histogram based methods have proved simplicity and usefulness in last decade. Initially, this idea was based on color histograms that were launched by swain [1]. This algorithm presents the first part of our proposed technique named as “Histogram processed Face Recognition” [2] For training, grayscale images with 256 gray levels are used. Firstly, frequency of every gray-level is computed and stored in vectors for further processing. Secondly, mean of consecutive nine frequencies from the stored vectors is calculated and are stored in another vectors for later use in testing phase. This mean vector is used for calculating the absolute differences among the mean of trained images and the test image. Finally the minimum difference found identifies the matched class with test image. Recognition accuracy is of 99.75% [1] M. J. Swain and D. H. Ballard, “Indexing via color histogram”, In Proceedings of third international conference on Computer Vision , pages 390–393, Osaka, Japan, 1990. [2] Fazl-e-Basit, Younus Javed and Usman Qayyum, "Face Recognition using processed histogram and phase only correlation ", 3rd IEEE International Conference on Emerging Technology pp. 238-242
基于Matlab直方图Histogram的人脸识别程序-Processed histogram based Face Recognition.part4.rar 基于Matlab 直方图Histogram的人脸识别程序 因为数据库图片太大,所以分成几个压缩文件。 Face recognition 原理介绍: matlab12.jpg Recognizing objects from large image databases, histogram based methods have proved simplicity and usefulness in last decade. Initially, this idea was based on color histograms that were launched by swain [1]. This algorithm presents the first part of our proposed technique named as “Histogram processed Face Recognition” [2] For training, grayscale images with 256 gray levels are used. Firstly, frequency of every gray-level is computed and stored in vectors for further processing. Secondly, mean of consecutive nine frequencies from the stored vectors is calculated and are stored in another vectors for later use in testing phase. This mean vector is used for calculating the absolute differences among the mean of trained images and the test image. Finally the minimum difference found identifies the matched class with test image. Recognition accuracy is of 99.75% [1] M. J. Swain and D. H. Ballard, “Indexing via color histogram”, In Proceedings of third international conference on Computer Vision , pages 390–393, Osaka, Japan, 1990. [2] Fazl-e-Basit, Younus Javed and Usman Qayyum, "Face Recognition using processed histogram and phase only correlation ", 3rd IEEE International Conference on Emerging Technology pp. 238-242
基于Matlab直方图Histogram的人脸识别程序-Processed histogram based Face Recognition.part2.rar 基于Matlab 直方图Histogram的人脸识别程序 因为数据库图片太大,所以分成几个压缩文件。 Face recognition 原理介绍: matlab12.jpg Recognizing objects from large image databases, histogram based methods have proved simplicity and usefulness in last decade. Initially, this idea was based on color histograms that were launched by swain [1]. This algorithm presents the first part of our proposed technique named as “Histogram processed Face Recognition” [2] For training, grayscale images with 256 gray levels are used. Firstly, frequency of every gray-level is computed and stored in vectors for further processing. Secondly, mean of consecutive nine frequencies from the stored vectors is calculated and are stored in another vectors for later use in testing phase. This mean vector is used for calculating the absolute differences among the mean of trained images and the test image. Finally the minimum difference found identifies the matched class with test image. Recognition accuracy is of 99.75% [1] M. J. Swain and D. H. Ballard, “Indexing via color histogram”, In Proceedings of third international conference on Computer Vision , pages 390–393, Osaka, Japan, 1990. [2] Fazl-e-Basit, Younus Javed and Usman Qayyum, "Face Recognition using processed histogram and phase only correlation ", 3rd IEEE International Conference on Emerging Technology pp. 238-242
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值