function [sxx,sxy,syy] = color_edge(inp)
% COLOR_EDGE
%
%   [sxx, sxy, syy] = color_edge(inp) returns the elements of
% the color edge matrix S for the color image inp.
%

% define (red, green, blue) spectral channels
red = im2double(inp(:,:,1));
grn = im2double(inp(:,:,2));
blu = im2double(inp(:,:,3));

% Dx vector
h = 0.25*fspecial('sobel');
sy1 = filter2(h,red,
'valid');
sy2 = filter2(h,grn,
'valid');
sy3 = filter2(h,blu,
'valid');

% Dy vector
h = -h';
sx1 = filter2(h,red,
'valid');
sx2 = filter2(h,grn,
'valid');
sx3 = filter2(h,blu,
'valid');

% dot products, sxx = dot(Dx,Dx), sxy = dot(Dx,Dy), syy = dot(Dy,Dy)
sxx = sx1.*sx1+sx2.*sx2+sx3.*sx3;
sxy = sx1.*sy1+sx2.*sy2+sx3.*sy3;
syy = sy1.*sy1+sy2.*sy2+sy3.*sy3;


Maintained by John Loomis, last updated 18 March 2000