function [bloch,cloch, Z,fker_nel, ker_nel,nois,fnois] = buildInputFunctions_RMP_D( changeNoise, noiseFactor, time_param,  inputFile)
%preparation of the orinal image 'bloch', noised blurred input 'Z', 
% DFT of the blurring kernel 'fker' and additive noise 'nois'
%if changeNoise == 'y' then noise is changed, otherwise it is retained
%noiseFactor-- STD of noise vectors
%time_param--STD of gaussiam kernel




f =  imread(inputFile);
%f=f(1:2:512,1:2:512);
[ln, hn, df]=size(f);

if df > 1
    f = rgb2gray(f);
end
bloch = double(f);

 fbloch=transpose(fft(bloch)); 
    if time_param>0
ker_nel=fspecial('gaussian',[1,ln],time_param);
ker_nel=double(ker_nel);
  
ker_nel=circ_h(ker_nel,ln/2);
  else
        ker_nel =zeros(1,ln);
  ker_nel(1)=1;
    end
fker_nel=fft(ker_nel,[],2); 
fcloch=(repmat(fker_nel,hn,1)).*fbloch;
cloch=real(ifft(fcloch,[],2))';
clear fcloch
  load answerMP_D parameters nois;
  if(changeNoise == 'y' || isempty(nois))
    nois=[];
    for kk=1:hn
    %nois=[nois sqrt(va)*randn(vc,1)];
    nois=[nois noiseFactor*randn(ln,1)];
    end
     
    save answerMP_D parameters nois;
  end
  
 fnois=transpose(fft(nois));
  Z = cloch + nois; %this is the noised convolved function
end

% Copyright (c) 2013. Valery A. Zheludev