%m-file for improving an acquired image by Giotto software
%
%Author: Branislav Micusik  -  Center for Machine Perception, Prague
%        micusb1@cmp.felk.cvut.cz 

function p=shift(name1)

%name1='bad-01.bmp';
%name1='ov-faces.bmp';
name2='out.bmp';

[im map]=imread(name1);
%/convert to rgb level according to input format of name1 file
%im1=ind2gray(im,map);
im1=double(rgb2gray(im));

%show original image
fig1=figure(1);
imshow(im1,[]);
set(gca,'Position',[0,0,1,1])
axis equal;

im2=double(im1);

x=1:size(im1,2);
x2=2:size(im1,2);

%shift every second row by 0.5 pixel
for i=1:2:size(im1,1)
  im2(i,x2)=interp1(x,im1(i,x),x2-0.5);
end

%show shifted image
fig2=figure(2);
imshow(im2,[]);
set(gca,'Position',[0,0,1,1]);
axis equal;

%write to output file          
imwrite(im2,gray(256),name2,'bmp');




