% Affine registration inside an optimization method. Parameters are the 
% solutions generated by the method(x), the two images (I1, I2), upper and lower bounds
% (lb, ub), scaling (scale) and the distance method (dist). It minimize it.

function [t,I]=affine_mask(x,scale,I1,I2,type,lb,ub)
    t = zeros(size(x,1),1);
    for i=1:size(x,1)
        el = x(i,:).*(ub-lb) + lb;
        [t(i),I]=affine_registration_image(el,scale,I1,I2,type);
    end
end