【发布时间】:2011-03-29 16:30:37
【问题描述】:
我想找到两个图像的直方图并使用欧几里得距离找到相似度。我正在尝试使用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
【问题讨论】:
标签: matlab