%x=imread('g.jpg');
x=imread('blood1.tif');
% x=x(:,1:1280);
x1=double(x);
%x1=double(x(:,1:1280));
a= [-1 0 1; 1 1 1; 2 4 6].*0.8;
%implementation of the linear filtering
y = filter2(a,x1);
y1=uint8(y);
%Implementation ofnon linear filtering
%Median method
m=median(a);
y2=filter2(m,x1);
y2=uint8(y2);
%dilation method
ma=max(max(a));
y3=filter2(ma,x1);
y3=uint8(y3);
%erosion method
mi=min(min(a));
y4=filter2(mi,x1);
y4=uint8(y4);
figure;
subplot(2,2,1), imshow(x);
subplot(2,2,2), imshow(y1);
subplot(2,2,3), imshow(y2);
subplot(2,2,4), imshow(y3);
figure;
imshow(y1);