function backproject, sinogram, angles, bilinear=bilinear, cubic=cubic

;+
; NAME:
;    BACKPROJECT
;
; PURPOSE:
;    Reconstructs a sinogram into an image using backprojection.
;
; CATEGORY:
;    Tomography data processing
;
; CALLING SEQUENCE:
;    Result = BACKPROJECT(Sinogram, Angles, /Binlinear, Cubic=cubic)
;
; INPUTS:
;    Sinogram:    The input sinogram, dimensions NX x NANGLES. This should have been filtered before 
;                calling this function.
;    Angles:        An array of dimensions NANGLES which contains the angle in radians of each projection.
; 
; KEYWORD PARAMETERS:
;    /BILINEAR:        This keyword is simply passed to the RIEMANN procedure. See the documentation for 
;                    the IDL RIEMANN procedure for details.
;    CUBIC:            This keyword is simply passed to the RIEMANN procedure. See the documentation for 
;                    the IDL RIEMANN procedure for details.
;
; OUTPUTS:
;    This function returns the reconstructed image.
;
; RESTRICTIONS:
;    This function does not yet properly scale the result. This will be fixed in the near future.
;
; PROCEDURE:
;    This function simply calls the IDL RIEMANN procedure for each row in the sinogram, using the
;    ROW and /BACKPROJECT keywords. The BILINEAR and CUBIC keywords are passed from BACKPROJECT to 
;    RIEMANN if they are present.
;
; EXAMPLE:
;    r = backproject(sinogram, angles)
;
; MODIFICATION HISTORY:
;    Written by:    Mark Rivers, May 13, 1998
;-

nx = n_elements(sinogram[*,0])
nviews = n_elements(sinogram[0,*])
b = fltarr(nx, nx)    ;Initial reconstructed image.
for i=0,nviews-1 do begin
    riemann, sinogram, b, angles[i], row=i, /backproject, $
            bilinear=binear, cubic=cubic
endfor
return, b
end