⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 灰度直方图.txt

📁 matlab编写的灰度直方图程序
💻 TXT
字号:
clc
clear
fn='rice.tif';
I=imread (fn);
J=I;
%计算灰度图象的直方图数据
L=256; %灰度级 
Ps = zeros(L,1); %统计直方图结果数据
nk=zeros(L,1);
[row,col]=size(I);
n=row*col; %总像素个数
for i = 1:row
for j = 1:col
num = double(I(i,j))+1; %获取像素点灰度级
nk(num) = nk(num)+1; %统计nk 
end
end
%计算直方图概率估计
for i=1:L
Ps(i)=nk(i)/n; 
end
figure;
subplot(3,1,1);imshow(J),title('原图');
subplot(3,1,2),plot(nk),title('直方图(nk)');
subplot(3,1,3),plot(Ps),title('直方图(Ps)');

%figure(4),imhist(hist);
%p=imhist(hist); %生成直方图函数,返回灰度图象直方图数据
%figure(5),plot(p); 


看源代码的方法
>demo
>edit histeq
> 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -