function [sdata] = adjust_counts(data,counts)
%------------------------------------------------------------------
% Function: adjust_counts(data)
%
% Inputs:    data - 2 Dimensional projection data 
%          counts - Number of counts to rescale data
%
% Output:   sdata - 2 Dimensional rescaled projection data
%------------------------------------------------------------------

    %Find the number of pixels
    [M N] = size(data);
    nangles = M;
    npixels = N;

    sdata = zeros(M,N);       % scaled projection data
    
    % Compute total counts in the data
    tcounts = sum(sum(data));
    
    % Create scale factor
    scale = counts/tcounts;
    
    % rescale the projection data
    sdata = scale.*data;
    
    % Compute total counts in the scaled data
    newtcounts = sum(sum(sdata));
    
    fprintf('Total counts - before: %g \t after: %g \n',tcounts,newtcounts);