MATLAB中 histogram 和 imhist 的区别
matlab有两个生成直方图的库函数,分别是imhist和histogram,二者有何区别呢?
区别就是:
- imhist
- 官方help:imhist(I) calculates the histogram for the intensity image I and displays a plot of the histogram. The number of bins in the histogram is determined by the image type.
- 可见,imhist的NumBins值是由图像类型决定的。若图像为uint8类型,则bin的数量为256,即[0:1:255]。
histogram(早期版本为hist,现在matlab已不建议使用hist了)
- 官方help:
histogram(X) creates a histogram plot of X. The histogram function uses an automatic binning algorithm that returns bins with a uniform width, chosen to cover the range of elements in X and reveal the underlying shape of the distribution. histogram displays the bins as rectangles such that the height of each rectangle indicates the number of elements in the bin.
nbins — Number of bins
Number of bins, specified as a positive integer. If you do not specify nbins, then histogram automatically calculates how many bins to use based on the values in X.- 可见,histogram的NumBins值可以人为设定,在未指定该参数时,系统将基于图像的灰度分布自动计算NumBins的值。
- 官方help:
例程:
imgColor = imread('lena.jpg');
imgGray = rgb2gray(imgColor);
%% imhist
figure('name', 'imhist'),
imhist(imgGray);
%% histogram
figure('name', 'histogram auto'),
% histogram函数自动计算NumBins值
hist2 = histogram(imgGray);
% Find the bin counts
binCounts = hist2.Values;
% Get bin number
binNum = hist2.NumBins;
%% histogram 指定NumBins值
% Specify number of histogram bins
figure('name', 'histogram256'),
hist256 = histogram(imgGray, 256); % 等同于 imhist(imgGray)
由运行结果也可看出,histogram(imgGray, 256)与imhist(imgGray),二者在最大bin的灰度累计值是一样的。

reference
MATLAB中 histogram 和 imhist 的区别的更多相关文章
- matlab中findstr,strfind,strcmp,strncmp区别与联系
在Matlab中,这几个函数区分如下: (以下默认S1和S2是字符串,同样也适用于cell细胞类型数据,也就是循环对cell中每个元素分别判断即可.) findstr(S1,S2):寻找是否有S1和S ...
- MATLAB中feval与eval的区别
feval函数有两种调用形式1.[y1, y2, ...] = feval(fhandle, x1, ..., xn)2.[y1, y2, ...] = feval(fname, x1, ..., x ...
- Matlab中^2和.^2的区别
矩阵a a^2 -- 两个矩阵相乘 a.^2 -- 表示 矩阵对应位置相乘 如下: a=[ 1,2,3 4,5,6 7,8,9]; disp(a); disp(a^2); disp(a.^2); ...
- matlab中的卷积——filter,conv之间的区别
%Matlab提供了计算线性卷积和两个多项式相乘的函数conv,语法格式w=conv(u,v),其中u和v分别是有限长度序列向量,w是u和v的卷积结果序列向量. %如果向量u和v的长度分别为N和M,则 ...
- MATLAB 中gcf、gca 以及gco 的区别
MATLAB 中gcf.gca 以及gco 的区别gcf 返回当前Figure 对象的句柄值gca 返回当前axes 对象的句柄值gco 返回当前鼠标单击的句柄值,该对象可以是除root 对象外的任意 ...
- matlab中 mcc/mbuild/mex 区别
mcc 的作用是将 .m文件编译为 c/c++动态链接库文件,使你可以在 c/c++程序中使用 matlab的一些函数功能.mcc 也可以将.m文件编译为exe可执行文件. mex 的作用是将 c/c ...
- Matlab中的eig函数和Opecv中eigen()函数的区别
奇异值分解的理论参见下面的链接 http://www.cnblogs.com/pinard/p/6251584.html https://blog.csdn.net/shenziheng1/artic ...
- matlab中imfilter、conv2、imfilter2用法及区别
来源 :https://blog.csdn.net/u013066730/article/details/56665308(比较详细) https://blog.csdn.net/yuanhuilin ...
- Matlab中的数据类型
Matlab中有15种基本数据类型,主要是整型.浮点.逻辑.字符.日期和时间.结构数组.单元格数组以及函数句柄等. 1.整型:(int8:uint8:int16:uint16:int3 ...
随机推荐
- Centos7安装killall,fuser, killall,pstree和pstree.x11
centos7精简安装后,使用中发现没有killall命令. 经查找,可以通过以下命令解决: yum -y install psmisc 简单介绍一下 psmisc : Psmisc软件包包含三个帮助 ...
- 联想服务器配置 RAID
联想服务器配置 RAID BIOS 中配置 RAID 阵列卡 x3650 和 x3850 一.进入 RAID 1.在开机自检时按 F1 进入 UEFI 配置界面 2.选择 System Setting ...
- python列表中的pop
pop()将列表指定位置的元素移除,同时可以将移除的元素赋值给某个变量,不填写位置参数则默认删除最后一位. pop()根据键将字典中指定的键值对删除,同时可以将删除的值赋值给变量. a = [1, 2 ...
- Eclipse-Java EE
1.1 下载JDK 在Java官方网站下载最新版本的 Java SE: http://www.oracle.com/technetwork/java/javase/downloads/index.h ...
- bzoj 3978: [WF2012]Fibonacci Words
Description 斐波那契01字符串的定义如下 F(n) = { 0 if n = 0 1 if n = 1 F(n-1)+F(n-2) if n >= 2 } 这里+的定义是字符串的 ...
- bzoj 4927: 第一题
Description 给定n根直的木棍,要从中选出6根木棍,满足:能用这6根木棍拼 出一个正方形.注意木棍不能弯折.问方案数. 正方形:四条边都相等.四个角都是直角的四边形. Input 第一行一个 ...
- python学习笔记--装饰器
1.首先是一个很无聊的函数,实现了两个数的加法运算: def f(x,y): print x+y f(2,3) 输出结果也ok 5 2.可是这时候我们感觉输出结果太单一了点,想让代码的输出多一点看起来 ...
- java操作Excel之POI(3)
一.字体处理 /** * 字体处理 */ public static void main(String[] args) throws Exception { Workbook wb = new HSS ...
- java web程序 jdbc连接数据库错误排查方法
学习jsp.我遇到了麻烦,我总是看不懂500错误,因为每次都显示整个页面的错误,都是英文 我看不懂,后来,把他弄烦了,我也烦了,比起学习java.那个异常可以很简单的就知道.现在解决 了第一个问题,5 ...
- SqlBulkCopy 快速插入数据
[转]本文来自http://msdn.microsoft.com/zh-cn/library/system.data.sqlclient.sqlbulkcopy(v=vs.80).aspx 此代码用于 ...