function [u2] = propIR(u1,pitch,lambda,z,shiftx,shifty,signal)
%========================================================================
%Copyright(c) 2017 EmergIMG project
%Universidade da Beira Interior - Instituto de Telecomunicações, Portugal
%All Rights Reserved.
%
%This is an implementation of the Impulse Response Reconstruction Method for holographic data.
%Assumes x and y side length and uniform sampling.
%Described in the following paper:
%
%[1] Marco V. Bernardo, Pedro Fernandes, Angelo Arrifano, Marc Antonini, Elsa Fonseca, Paulo T. Fiadeiro, António M. G. Pinheiro and Manuela Pereira,
% "Holographic Representation: Hologram Plane vs. Object Plane", submitted, 2018
%
%Input : u1     - Hologram Plane Field
%        pitch  - Pixel Pitch
%        lambda - Wavelength
%        z      - Propagation Distance
%        shiftx - Shift parameter for centering in Horizontal
%        shifty - Shift parameter for centering in Vertical
%        signal - +1 to EmergImg-HoloGrail - v1, -1 to EmergImg-HoloGrail - v2
%Output: u2 - Object Plane Field
%
%Example for Horse Hologram:
% load('horse.mat')
%
% [u2] = propIR(u1,pitch,lambda,z,sx,sy,signal);
% imshow(abs(u2),[])
%
%========================================================================

k = 2*pi/lambda;
[M,N] = size(u1);
dx = pitch;
dy = pitch;
Lx = N*pitch;
Ly = M*pitch;
x = -Lx/2+shiftx*N*dx: dx : Lx/2+shiftx*N*dx-dx;
y = -Ly/2+shifty*M*dy: dy : Ly/2+shifty*M*dy-dy;

[X,Y] = meshgrid(x,y);

h = (-signal*1i)*exp((signal*1i*k/(2*z))*(X.^2+Y.^2));

U2=h.*u1;
u2=fftshift(ifft2(fftshift(U2)));	% inv fft, center obs field
end 

