clear
close all
addpath('../samples')
N0 = 15;
m = (-N0:N0)';
n = (-N0:N0);
[M,N] = meshgrid(m,n);

r = sqrt(M.^2 + N.^2);

h_sep = zeros(length(m),length(n));
n0 = 2;
h_sep(n0+1:length(m)-n0,n0+1:length(n)-n0) = 1;
h_ns = double(r<N0);
h_sep = h_sep/sum(sum(h_sep));
h_ns = h_ns/sum(sum(h_ns));

figure;
subplot(2,2,1)
pcolor(h_sep);
shading interp
axis equal tight
title('Szeparábilis szûrõ impulzusválasza')

subplot(2,2,2)
pcolor(20*log10(fftshift(abs(fft2(h_sep,1024,1024)))));
shading interp
axis equal tight
title('Szeparábilis szûrõ átvitele')

subplot(2,2,3)
pcolor(h_ns);
shading interp
axis equal tight
title('Nem-szeparábilis szûrõ impulzusválasza')

subplot(2,2,4)
pcolor(20*log10(fftshift(abs(fft2(h_ns,1024,1024)))));
shading interp
axis equal tight
title('Nem-szeparábilis szûrõ átvitele')
%%
in = imread('star.png');
in = double( 0.3*in(:,:,1) + 0.59*in(:,:,2) + 0.11*in(:,:,3) );
out1 = uint8(conv2(in,h_sep,'same'));
out2 = uint8(conv2(in,h_ns,'same'));

figure;
subplot(1,2,1)
imshow(out1)

subplot(1,2,2)
imshow(out2)
