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 ...
随机推荐
- Oracle GI 日志收集工具 - TFA 简介
转载自:https://blogs.oracle.com/Database4CN/entry/tfa_collector_%E4%BB%8B%E7%BB%8D 1.TFA的目的: TFA是个11.2版 ...
- Generator 知识点
Generator 函数的执行过程,其实是将同一个回调函数,反复传入 next 方法的 value 属性. Iterator 接口的 next 方法必须是同步的,只要调用就必须立刻返回值.也就是说,一 ...
- Refused to display '[url]' in a frame because it set 'X-Frame-Options' to 'Deny'.
X-Frame-Options是一个HTTP标头(header),用来告诉浏览器这个网页是否可以放在iFrame内.例如: X-Frame-Options: DENY X-Frame-Options: ...
- mysql ssh 端口转发
某些时候 mysql 只允许 指定的 ip连接 .这时候怎么在本机 连接mysql 的呢? 条件 1 mysql 只有 允许 指定ip连接 2 有连接 指定 ip 服务器的 账密 这时候我们可以通 ...
- Oracle根据表的大小排序SQL语句
--按照数据行数排序select table_name,blocks,num_rows from dba_tables where owner not like '%SYS%' and table_n ...
- golang init函数
init函数有一下几点特性: init函数在main执行之前,自动被调用执行的,不能显示调用 每个包的init函数在包被引用时,自动被调用 每个包可以有多个init函数 同一个文件中可定义多个init ...
- Sql中判断"数据库"、"表"、"临时表"、"存储过程"和列"是否存在
--判断数据库是否存在 IF EXISTS (SELECT * FROM MASTER..sysdatabases WHERE NAME = '库名') PRINT 'exists ' else ...
- 织梦调用文章 ID (来源:百度知道)
问:{dede:field.id /} {dede:channel type='son' orderby='sortrank'} <a href='[field:typeurl/]'>&l ...
- FileStream 和StreamWriter 一起用时
StreamWriter Flush 即可. FileStream Flush 无用.
- ES之六:ElasticSearch中Filter和Query的异同
如下例子,查找性别是女,所在的州是PA,过滤条件是年龄是39岁,balance大于等于10000的文档: { "query": { "bool": { &quo ...