%DIP Class Demo
%Shreekanth Mandayam, Rowan University
%
%Gradients & Edge Detection


clear; close all;

%Generating image
im_zero=zeros(4,256);
im_one=ones(4,256);
im=[im_zero,im_one,im_zero];
im=imresize(im,[256 256],'bilinear');
figure(1);imshow(im,'InitialMagnification','fit');
title('original image: f(x,y)');

pause;

f=im(256,:);
figure(2);subplot(3,1,1);plot(f);
xlabel('y');ylabel('f');
title('Horizontal scan'); grid on;

df=diff(f);
subplot(3,1,2);plot(df);
xlabel('y');ylabel('df/dy');
title('First derivative');grid on;

d2f=diff(df);
subplot(3,1,3);plot(d2f);
xlabel('y');ylabel('d^2f/dy^2');
title('Second  derivative');grid on;