%DIP Class Demo
%Shreekanth Mandayam, Rowan University
%
%Prewitt's Gradient

close all;
%generating image
im=zeros(50);
a=ones(50);
im(5:45,20:30)=a(5:45,20:30);
im(20:30,5:45)=a(20:30,5:45);
figure(1);imshow(im,'InitialMagnification','fit');
title('Original Image');

pause;

%generating masks
prh=[-1 -1 -1; 0 0 0; 1 1 1];
prv=prh';

%generating gradients
figure(2);imshow(mat2gray(filter2(prh,im)),'InitialMagnification','fit');
title('Horizontal Gradients');

pause;

figure(3);imshow(mat2gray(filter2(prv,im)),'InitialMagnification','fit');
title('Vertical Gradients');

pause;

figure(4);imshow(mat2gray(filter2(prv,im)+filter2(prh,im)),'InitialMagnification','fit');
title('Composite');
