码迷,mamicode.com
首页 > 其他好文 > 详细

matlab 直方图

时间:2015-03-05 23:30:29      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:

(1)灰度直方图

imhist(I)
imhist(I, n)  n灰度级数目 默认等于256
[counts, x]=imhist(...)   counts为直方图的数据向量,counts(a)表示第a个区间像素数目,x保存了对应的小区间的向量,stem(x,counts/m/n)表示直方图概率。

 

(2)彩色图像直方图

i=imread(‘theatre.jpg‘);

[x,y,z]=size(i);
figure
subplot(221), imshow(i);
title(‘original image‘)
%提取红色分量
r=i;
%r(:,:,1)=a(:,:,1);
r(:,:,2)=zeros(x,y);
r(:,:,3)=zeros(x,y);
r=uint8(r);
subplot(222),imshow(r);
title(‘R-component-image‘)
%提取绿色分量
g=i;
g(:,:,1)=zeros(x,y);
%g(:,:,2)=a(:,:,2);
g(:,:,3)=zeros(x,y);
g=uint8(g);
subplot(223),imshow(g);
title(‘G-component-image‘)
%提取蓝色分量
b=i;
b(:,:,1)=zeros(x,y);
b(:,:,2)=zeros(x,y);
%b(:,:,3)=a(:,:,3);
b=uint8(b);
subplot(224),imshow(b);
title(‘B-component-image‘)

 

或者

i=imread(‘theatre.jpg‘);
r=a(:,:,1);
g=a(:,:,2);
b=a(:,:,3);
subplot(1,3,1), imhist(r), title(‘R component‘);
subplot(1,3,2), imhist(g), title(‘G component‘);
subplot(1,3,3), imhist(b), title(‘B component‘);

 

matlab 直方图

标签:

原文地址:http://www.cnblogs.com/h1359705211/p/4316912.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!