A=imread('image.jpg');
Image = rgb2gray(A);
M=[1/4,1/2,1/4;
1/2,1,1/2;
1/4,1/2,1/4];
r=2*size(Image,1)+1;
c=2*size(Image,2)+1;
C=zeros(r,c);
p=1;
for i=2:2:r-1
q=1;
for j=2:2:c-1
C(i,j)=Image(p,q);
q=q+1;
end
p=p+1;
end
R=zeros(r,c);
p=1;
for i=1:size(C,1)-2;
q=1;
for j=1:size(C,2)-2;
sum=0;
for a=1:3;
for b=1:3;
sum=sum+C(i+a-1,j+b-1)*M(a,b);
end
end
R(i+1,j+1)=sum;
q=q+1;
end
p=p+1;
end
resultImage=uint8(R);
figure
subplot(1,2,1), imshow(Image);
subplot(1,2,2), imshow(resultImage);
truesize
No comments
Post a Comment