我想要找到兩個圖像的直方圖並使用歐幾里得距離找到相似度。我試圖使用imhist
命令,但它給了以下錯誤:使用直方圖比較兩個圖像
Error using ==> iptcheckinput
Function IMHIST expected its first input, I or X, to be two-dimensional.
我的代碼如下:
% read two images
Im1 = imread('1.jpg');
Im2 = imread('2.jpg');
% convert images to type double (range from from 0 to 1 instead of from 0 to 255)
Im1 = im2double(Im1);
Im2 = im2double(Im2);
% Calculate the Normalized Histogram of Image 1 and Image 2
hn1 = imhist(Im1)./numel(Im1);
hn2 = imhist(Im2)./numel(Im2);
% Calculate the histogram error
f = sum((hn1 - hn2).^2);
f; %display the result to console
好帖子!但rgb2gray並未將所有頻道視爲平等。 - 「0.2989 * R + 0.5870 * G + 0.1140 * B」 – 2012-02-03 08:59:23
好,編輯! – ibanez 2012-08-29 09:04:48