标签:cat none name mod 结果 图像 reference form enc
matlab有两个生成直方图的库函数,分别是imhist和histogram,二者有何区别呢?
区别就是:
histogram(早期版本为hist,现在matlab已不建议使用hist了)
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.
例程:
1 imgColor = imread(‘lena.jpg‘); 2 imgGray = rgb2gray(imgColor); 3 4 %% imhist 5 figure(‘name‘, ‘imhist‘), 6 imhist(imgGray); 7 8 %% histogram 9 figure(‘name‘, ‘histogram auto‘), 10 % histogram函数自动计算NumBins值 11 hist2 = histogram(imgGray); 12 % Find the bin counts 13 binCounts = hist2.Values; 14 % Get bin number 15 binNum = hist2.NumBins; 16 17 %% histogram 指定NumBins值 18 % Specify number of histogram bins 19 figure(‘name‘, ‘histogram256‘), 20 hist256 = histogram(imgGray, 256); % 等同于 imhist(imgGray)
由运行结果也可看出,histogram(imgGray, 256)与imhist(imgGray),二者在最大bin的灰度累计值是一样的。
MATLAB中 histogram 和 imhist 的区别
标签:cat none name mod 结果 图像 reference form enc
原文地址:http://www.cnblogs.com/gxcdream/p/7710729.html