0

我使用 matlab 图形用户界面。这是我的代码:

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

4

1 回答 1

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)

这能回答问题吗?

于 2012-11-14T10:35:05.320 回答