function imagesampling
%Programm zum Downsampling eines Bildes und anschlie§ender Rekonstruktion
clf reset
clc
clear all;
close all;
echo off

%input image
input_s=0;

if input_s==0              %Bild von Shannon
    a=imread ('Shannon_2.jpg');
	b=a(1:338,1:267);
	a=double(b);
	f=a/256;
elseif input_s==1          %Duisburger UniversitŠt
    a= imread ('duisburg.jpg');
	b=a(1:400,1:300);
    a=double(b);
    f=a/256;
end

figure,imagesc(f); axis image
set(gca,'FontSize',15);
colormap(gray);

% Downsampling
down1=3; down2=3;                   %Samplingfaktoren in x- und y-Richtung
[N1,N2] = size(f)
k1=floor((N1-1)/down1)
k2=floor((N2-1)/down2)
for i=0:k1 
   for j=0:k2 g(i+1,j+1)=f(1+down1*i,1+down2*j); 
   end;
end;   
 
figure,imagesc(g); axis image
set(gca,'FontSize',15);
colormap(gray);

%===Algorithmen===% 


f1=linearinterpolation(g,f,down1,down2);


figure,imagesc(f1); axis image
set(gca,'FontSize',15);
colormap(gray);

