%%%%计算图像的梯度及直方图%%%%
function [HistDist_image1_image2_gradientx,HistDist_image1_image2_gradienty ] = Gradient_difference( image1,image2 )
image1=double(image1);
image2=double(image2);
%计算x方向和y方向的梯度
[image1_gradientx,image1_gradienty]=gradient(image1);
[image2_gradientx,image2_gradienty]=gradient(image2);
%分别计算x方向和y方向的梯度直方图
hist_image1_gradientx=imhist(image1_gradientx);
hist_image1_gradienty=imhist(image1_gradienty);
hist_image2_gradientx=imhist(image2_gradientx);
hist_image2_gradienty=imhist(image2_gradienty);
%画出梯度直方图
figure;
subplot(2,2,1),plot(hist_image1_gradientx),title('hist_image1_gradientx');
subplot(2,2,2),plot(hist_image1_gradienty),title('hist_image1_gradienty');
subplot(2,2,3),plot(hist_image2_gradientx),title('hist_image2_gradientx');
subplot(2,2,4),plot(hist_image2_gradienty),title('hist_image2_gradienty');