Matlab 如何找到直方图的值?
我使用MatlabGUI。这是我的代码:Matlab 如何找到直方图的值?,matlab,user-interface,histogram,Matlab,User Interface,Histogram,我使用MatlabGUI。这是我的代码: data = guidata(gcbo); for i = 1:5 citra3{i} = imread(['D:\,,TA,,\Skripsi Saya\Minggu, 6 Mei 2012\Tugas_Akhir1\Pelatihan\temulawak\' num2str(i) '.jpg']); graylawak{i}=rgb2gray(citra3{i}); citra3{i} = imresize(graylawak
data = guidata(gcbo);
for i = 1:5
citra3{i} = imread(['D:\,,TA,,\Skripsi Saya\Minggu, 6 Mei 2012\Tugas_Akhir1\Pelatihan\temulawak\' num2str(i) '.jpg']);
graylawak{i}=rgb2gray(citra3{i});
citra3{i} = imresize(graylawak{i}, [20 15]);
如何在不使用imhist的情况下找到图像直方图的值?因为我会用直方图的值来计算相似性。我非常感谢您提供的帮助。我假设您希望获得citra3数组中每个元素的灰度值直方图。 要实现这一点,您可以执行以下操作:
% This turns the 2D image into a vector:
foo = reshape(citra3{i},1,numel(citra3{i}));
% As the pixel values are in uint8, they can have 8 bit (2^8=256) different values.
% Make one bin for each possible pixel value:
numberOfBins = 256;
% Convert the image data (uint8) to double precision values:
foobar = double(foo);
% Calculate the distribution of values within the bins:
[n,xout] = hist(foobar,numberOfBins);
% Plot the resulting histogram:
bar(xout,n)
这回答了问题吗?对不起,你的问题似乎有点模糊(至少对我来说是这样)。你能解释一下你做了什么,什么不起作用,你想实现什么吗?感谢搜索图像的值直方图(概率)。你能帮助我吗?如何找到图像的直方图(概率)值。因为我还没有找到一个参考源来搜索概率直方图的值。很抱歉,但我不明白,有这样一个错误:???错误使用==>mtimes整数只能与同一类的整数或标量双精度整数组合。错误==>78 xx处的历史=miny+binwidth*(0:x)@对不起,我没有仔细检查。图像数据位于数字类“uint8”中,这是一个8位整数。hist函数期望数据以数字类“double”传递。在执行hist之前,必须转换为double。我更新了我的帖子。它能做你想做的吗?