imRaw = rgb2gray(imread('Edgetest.png'));
figure(1)
imshow(imRaw)

hold on
plot([1,500],[200,200],'r');

test_line = double(imRaw(200,:)); % pick one line to be examined
				  % convert to data type double

[nx,ny] = size(imRaw);     % size of picture
ix = 2:nx-1; iy =  2:ny-1; % indices, unshifted
imRaw = double(imRaw);
t0 = cputime();
Gx = -1*imRaw(ix-1,iy-1) +1*imRaw(ix+1,iy-1)...
     -2*imRaw(ix-1,iy  ) +2*imRaw(ix+1,iy  )...
     -1*imRaw(ix-1,iy+1) +1*imRaw(ix+1,iy+1);

Gy = +1*imRaw(ix-1,iy-1) + 2*imRaw(ix,iy-1) + 1*imRaw(ix+1,iy-1)...
     -1*imRaw(ix-1,iy+1) - 2*imRaw(ix,iy+1) - 1*imRaw(ix+1,iy+1);

% Gx = 3*imRaw(ix-1,iy-1) - 3*imRaw(ix+1,iy-1)...
%    +10*imRaw(ix-1,iy  ) -10*imRaw(ix+1,iy  )...
%    + 3*imRaw(ix-1,iy+1) - 3*imRaw(ix+1,iy+1);
%
% Gy = 3*imRaw(ix-1,iy-1) + 10*imRaw(ix,iy-1) + 3*imRaw(ix+1,iy-1)...
%     -3*imRaw(ix-1,iy+1) - 10*imRaw(ix,iy+1) - 3*imRaw(ix+1,iy+1);

probe3edge = sqrt(Gx.^2 + Gy.^2);
timing = cputime()-t0
edgeLevel = 100;
figure(11)
imshow(1-(abs(Gx)>edgeLevel))
figure(12)
imshow(1-(abs(Gy)>edgeLevel))
figure(13)
imshow(1-((sqrt(Gx.^2+Gy.^2))>edgeLevel))

figure(14)
imSobel = edge(uint8(imRaw),'Sobel');
%imSobel = edge(imRaw,'Sobel');
imshow(1-imSobel)

