I need to find out if the output from some matlab code is actually correct. It takes an input image and convolves it with Dxx, Dxy, and Dyy, which are the 2nd order derivatives of a Gaussian with sigma=1.
I = zeros(32, 32, 'double');
I(16,:) = 0.5;
I(17,:) = 1.0;
I(18,:) = 0.5;
sigma=1;
% Make kernel coordinates
[X,Y] = ndgrid(-round(3*sigma):round(3*sigma));
% Build the gaussian 2nd derivatives filters
DGaussxx = 1/(2*pi*sigma^4) * (X.^2/sigma^2 - 1) .* exp(-(X.^2 + Y.^2)/(2*sigma^2));
DGaussxy = 1/(2*pi*sigma^6) * (X .* Y) .* exp(-(X.^2 + Y.^2)/(2*sigma^2));
DGaussyy = DGaussxx';
Dxx = imfilter(I,DGaussxx,'conv');
Dxy = imfilter(I,DGaussxy,'conv');
Dyy = imfilter(I,DGaussyy,'conv');
% display them
figure;
subplot(2,2,1), imshow(I,[]), title('input');
subplot(2,2,2), imshow(Dxx,[]), title('Dxx');
subplot(2,2,3), imshow(Dxy,[]), title('Dxy');
subplot(2,2,4), imshow(Dyy,[]), title('Dyy');
The output looks like this:

- Could someone verify these outputs are correct (are they the 'right way round')?
- If they are correct, is there an intuitive explanation for why Dxx appears to be showing me changes that happen in the y-direction? (am I mis-understanding something?)
Kind regards