function proj_out = trans_to_absorp(proj_in)
% Marek Zemek function
    % Internal function for absorption transform
    
    % Check if there are any 0s in projection data, replace if there are
    nonpositive_vals = proj_in(:) <= 0;
    if any(nonpositive_vals) % Replacing zero values in sinogram with the second smallest value
        temp_proj = proj_in(:,:,1); % find 2nd smallest value in 1st projection
        min_val = min(temp_proj(temp_proj>0));
        proj_in(nonpositive_vals) = min_val;
    end
    if max(proj_in(:))>1
        proj_in = proj_in/max(proj_in(:));
    end
    % Lambert-Beer law
    proj_out = -log(proj_in);
end
