function rerr = relative_error_fixed(estimate, real)
%    rerr=abs(estimate-real)./(min(estimate,real)+1);
    %rerr=abs(log((estimate+0.01)./(real+0.01))./log(2));

    [m n] = size(estimate);
    estimate_fixed=zeros(m,n);

    for i = 1:m
        for j=1:n
            if (estimate(i,j) >= 0)
                estimate_fixed(i,j) = estimate(i,j)+1;
            else
                estimate_fixed(i,j) = exp(estimate(i,j));
            end
        end
    end
    %[bb/(aa+bb) total_neg/bb]
    
%     figure(6)
%     for i=1:m
%         for j=1:n
%             %if (estimate(i,j) < 0)
%                 plot(estimate(i,j), real(i,j));
%                 hold on;
%             %end
%         end
%     end
    
    
    rerr=abs(estimate_fixed-real)./(real+0.1);
    %mask  = (real>0) | (abs(estimate-real)>10);
    mask  = (real>0);
    rerr= rerr.*mask; 
    rerr = rerr(:); %% square -> line %%

%     real = real(:);
%     a = length(rerr);
%     point = 1;
%     for i=1:a
%         if (real(point) > 0)
%             point = point+1;
%         else
%             rerr(point) = [];
%         end
%     end
