【问题标题】:How can I find the value of the histogram?如何找到直方图的值?
【发布时间】:2012-11-14 09:50:11
【问题描述】:

我使用 matlab GUI。这是我的代码:

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 的情况下找到图像直方图的值?因为我将使用直方图的值来计算相似度。非常感谢您提供的帮助。

【问题讨论】:

  • 抱歉,您的问题似乎有点含糊(至少对我而言)。你能解释一下你做了什么,什么没用以及你想要实现什么?谢谢
  • 寻找图像的值直方图(概率)。你能帮助我吗?如何找到图像直方图(概率)的值。因为我没有找到参考源来搜索概率直方图的值。

标签: matlab user-interface histogram


【解决方案1】:

我假设您想要获取 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); @solimanelefant
  • 对不起,我没有仔细检查。图像数据属于数字类“uint8”,一个 8 位整数。 hist 函数期望数据在数字类“double”中传递。在执行 hist 之前,您必须转换为 double。我更新了我的帖子。它做你想做的事吗?
猜你喜欢
  • 2013-05-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-22
  • 2012-07-18
相关资源
最近更新 更多