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的值。

例程:

 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 的区别的更多相关文章

  1. matlab中findstr,strfind,strcmp,strncmp区别与联系

    在Matlab中,这几个函数区分如下: (以下默认S1和S2是字符串,同样也适用于cell细胞类型数据,也就是循环对cell中每个元素分别判断即可.) findstr(S1,S2):寻找是否有S1和S ...

  2. MATLAB中feval与eval的区别

    feval函数有两种调用形式1.[y1, y2, ...] = feval(fhandle, x1, ..., xn)2.[y1, y2, ...] = feval(fname, x1, ..., x ...

  3. 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); ...

  4. matlab中的卷积——filter,conv之间的区别

    %Matlab提供了计算线性卷积和两个多项式相乘的函数conv,语法格式w=conv(u,v),其中u和v分别是有限长度序列向量,w是u和v的卷积结果序列向量. %如果向量u和v的长度分别为N和M,则 ...

  5. MATLAB 中gcf、gca 以及gco 的区别

    MATLAB 中gcf.gca 以及gco 的区别gcf 返回当前Figure 对象的句柄值gca 返回当前axes 对象的句柄值gco 返回当前鼠标单击的句柄值,该对象可以是除root 对象外的任意 ...

  6. matlab中 mcc/mbuild/mex 区别

    mcc 的作用是将 .m文件编译为 c/c++动态链接库文件,使你可以在 c/c++程序中使用 matlab的一些函数功能.mcc 也可以将.m文件编译为exe可执行文件. mex 的作用是将 c/c ...

  7. Matlab中的eig函数和Opecv中eigen()函数的区别

    奇异值分解的理论参见下面的链接 http://www.cnblogs.com/pinard/p/6251584.html https://blog.csdn.net/shenziheng1/artic ...

  8. matlab中imfilter、conv2、imfilter2用法及区别

    来源 :https://blog.csdn.net/u013066730/article/details/56665308(比较详细) https://blog.csdn.net/yuanhuilin ...

  9. Matlab中的数据类型

    Matlab中有15种基本数据类型,主要是整型.浮点.逻辑.字符.日期和时间.结构数组.单元格数组以及函数句柄等.         1.整型:(int8:uint8:int16:uint16:int3 ...

随机推荐

  1. java 的关键字 native

    native native 关键字说明其修饰的方法是一个原生态方法,方法对应的实现不是在当前文件,而是在用其他语言(如C和C++)实现的文件中.Java语言本身不能对操作系统底层进行访问和操作,但是可 ...

  2. 数独求解程序 php版

    数独求解程序 php版 <?php class Sudoku { var $matrix; function __construct($arr = null) { if ($arr == nul ...

  3. tyvj1659中中救援队

    题目:http://www.joyoi.cn/problem/tyvj-1659 发现每条边要走两次,每个点要走它连接的边数次. 所以把边的权值赋成 本身的值+两个端点的点权,求最小生成树即可. !边 ...

  4. ubuntu 14.04 安装Eclipse与配置环境变量

    1. 安装JDK 1.1 源码包下载 首先到官网下载jdk,http://www.oracle.com/technetwork/java/javase/downloads/index.html,我下载 ...

  5. 【python】python中__name__的使用

    Py1.py #!/usr/bin/env python def test(): print '__name__ = ',__name__ if __name__ == '__main__': tes ...

  6. qt windows下的配置 以及VS2010的使用

    qt在windows下的使用方式有两种: 1.将qt内置在vs下,例如,内置在vs2010下,使用vs的编译器及调试器. 2.在windows下,使用qt creator以及MingW作为编译器的使用 ...

  7. 实际用户ID和有效用户ID (一) *****

    在Unix进程中涉及多个用户ID和用户组ID,包括如下: 1.实际用户ID和实际用户组ID:标识我是谁.也就是登录用户的uid和gid,比如我的Linux以simon登录,在Linux运行的所有的命令 ...

  8. Laravel日志查看器 -- log-viewer扩展

    1.修改laravel配置文件. config\app.php 'log'=>'daily' 2.在项目目录中composer命令安装扩展:composer require arcanedev/ ...

  9. 安卓秘钥生成命令以及SHA1值获取办法

    切换到秘钥所在目录,例如:cd C:\Program Files\Java\jdk1.8.0_171\bin 执行命令:keytool -genkey -alias demo.keystore -ke ...

  10. 胡乱摸的NOIP2017游记和总结

    来自YZK的总结 本篇总结主要分成两部分:NOI Professional游记和平日的刷题训练. 今年的NOI Professional TG的难度在洛谷上标记为:二黄一绿三紫.恭喜NOIP今年全面脱 ...