Integrating over an image? I am currently trying to implement the method described in this paper. In short we have a system of the form $a=B\times c$. Where 

$$a_i = \int d^3r \space w(r)f_i(r)t(r)\quad\text{and}\quad B_{ij} = \int d^3r \space w(r)f_i(r)f_j(r).$$

The solution is given by $c = B^{-1}a$. In this case $w,t,f_i$ are volumes, specifically a sequence of images obtained from an x-ray simulation. When I solve these integrals using MATLAB's trapz function I get a poorly-conditioned $B$ matrix. 


Is there any other way to integrate this type of data (images)? 
Or a different way to calculate my $a$ and $B$ terms?
You can try to improve one both sides. One issue is that smooth separable kernels $w$ or integration scheme like trapz tend to reduce rank, and pose conditioning problems. Did you use pinv or X = (A)\(b) already?


You can invest on non-separable or higher order integration rules, see for instance n-dimensional simplex quadrature;
You can invest in regularization, for instance with the simple diagonal update: $B_c = B + c*\operatorname{eye}(\operatorname{size}(B))$. If this is not sufficient, there are quantities of constrained or penalized methods (LASSO for instance), implemented for instance in the CVX toolbox (e.g. Premade solvers for specific problems (vector variables)).