Professional Documents
Culture Documents
Xla Nguyễn Văn Thiện Btcd3
Xla Nguyễn Văn Thiện Btcd3
imshow(uint8(y));
figure,imshow(uint8(z));
for i=1:sz1
for j=1:sz2
sum=0;
m=i;
n=j;
for x=1:szcorr1
for y=1:szcorr2
sum=sum+(B(m,n)*corr(x,y));
n =n+1;
end
n=j;
m=m+1;
end
output(i,j)= sum;
end
end
figure,imshow(output);
title('After linear filtering');
3.6.1. Lc Trung V
input=imread('funny.jpg')
f = rgb2gray(input)
output = uint8(zeros(size(f)));
% bo loc mxn
m = 15;
n = 15;
extendImage = zeros(size(f, 1) + m - 1, size(f, 2)+ n - 1);
for x=1:size(f,1)
for y=1:size(f,2)
extendImage(x + floor(m / 2),y + floor(n / 2)) = f(x, y);
end
end
%lc trung v mxn
for i = 1:size(f, 1)
for j = 1:size(f, 2)
%tao 1 mang m * n phan tu tuong ung ma tran mxn
window = zeros(1, (m * n));
index = 1;
for x = 1:m
for y = 1:n
window(index) = extendImage(i + x - 1, j + y - 1);
index = index + 1;
end
end
windownSorted = sort(window);
3.6.2 Lc cc i
input=imread('funny.jpg')
f = rgb2gray(input)
output = uint8(zeros(size(f)));
% bo loc mxn
m = 3;
n = 3;
extendImage = zeros(size(f, 1) + m - 1, size(f, 2)+ n - 1);
for x=1:size(f,1)
for y=1:size(f,2)
extendImage(x + floor(m / 2),y + floor(n / 2)) = f(x, y);
end
end
%lc cc i mxn
for i = 1:size(f, 1)
for j = 1:size(f, 2)
window = zeros(1, (m * n));
index = 1;
for x = 1:m
for y = 1:n
window(index) = extendImage(i + x - 1, j + y - 1);
index = index + 1;
end
end
output(i, j) = max(window);
end
end
figure(1),imshow(f)
figure(2),imshow(output)
3.6.3. Lc Cc Tiu
input=imread('funny.jpg')
f = rgb2gray(input)
output = uint8(zeros(size(f)));
% bo loc mxn
m = 3;
n = 3;
extendImage = zeros(size(f, 1) + m - 1, size(f, 2)+ n - 1);
for x=1:size(f,1)
for y=1:size(f,2)