clc;
clear all;
close all;
a=imread('sam.jpg');
a=rgb2gray(a);
figure;
imshow(a);
title('original');
d=a;
l=a;
m=a;
%segmentation
for i=100:1:200
for j=10:1:20
d(i,j)=a(i,j)+100;
i=i+1;
j=j+1;
end
end
for i=10:1:200
l(i,10)=a(i,10)+100;
i=i+1;
end
m(50,50)=a(50,50)+100;
figure;
imshow(d);
title('bright edge');
figure;
imshow(l);
title('bright line');
figure;
imshow(m);
title('bright point');
%edge detection
b=edge(d,'sobel');
c=edge(d,'prewitt');
e=edge(d,'canny');
f=edge(d,'roberts');
figure;
subplot(3,2,1);
imshow(b);
title('sobel e');
subplot(3,2,2);
imshow(c);
title('prewitt e ');
subplot(3,2,3);
imshow(e);
title('canny e ');
subplot(3,2,4);
imshow(f);
title('roberts e');
h=[-1 -1 -1 ; 2 2 2; -1 -1 -1];
i=imfilter(d,h);
subplot(3,2,5);
imshow(i);
title('line e ');
j=[1 1 1:1 -8 1:1 1 1 ];
k=imfilter(d,j);
subplot(3,2,6);
imshow(k);
title('point e');
%line detection
figure;
b=edge(l,'sobel');
c=edge(l,'prewitt');
e=edge(l,'canny');
f=edge(l,'roberts');
subplot(3,2,1);
imshow(b);
title('sobel l');
subplot(3,2,2);
imshow(c);
title('prewitt l');
subplot(3,2,3);
imshow(e);
title('canny l');
subplot(3,2,4);
imshow(f);
title('roberts l');
h=[-1 -1 -1 ; 2 2 2; -1 -1 -1];
i=imfilter(l,h);
subplot(3,2,5);
imshow(i);
title('line l');
j=[1 1 1:1 -8 1:1 1 1 ];
k=imfilter(l,j);
subplot(3,2,6);
imshow(k);
title('point l');
%point detection
figure;
b=edge(m,'sobel');
c=edge(m,'prewitt');
e=edge(m,'canny');
f=edge(m,'roberts');
subplot(3,2,1);
imshow(b);
title('sobel p');
subplot(3,2,2);
imshow(c);
title('prewitt p');
subplot(3,2,3);
imshow(e);
title('canny p');
subplot(3,2,4);
imshow(f);
title('roberts p');
h=[-1 -1 -1 ; 2 2 2; -1 -1 -1];
i=imfilter(m,h);
subplot(3,2,5);
imshow(i);
title('line p');
j=[1 1 1:1 -8 1:1 1 1 ];
k=imfilter(m,j);
subplot(3,2,6);
imshow(k);
title('point p');