Question

I have 3 eqns and 2 unknowns Hb and Hbo2, they look like this:

Bxy = AB * HB + AB * Hbo2

Rxy = AR * HB + AR * Hbo2

Gxy = AG * HB + AG * Hbo2

Now I have been trying to use a matrix method in order to solve the unknowns for them equations, which is a pain in the ass cause when I convert it to matrix form I get an irregular matrix because it is 2 unknowns and 3 equations.

Does anyone on here know how to solve n number of equations with n-1 unknowns.

EDIT

Thanks for the responses so far, they have been great.

To help make this more clear, what I am trying to do is work out the concentration of oxygenated and deoxygenated blood at a given pixel in an image. so the variables above correspond to the following.

Rxy Gxy and Bxy, red green or blue absorbed at position x,y. (value between 0 - 255)

AR, AG, AB is the absorption coefficient of light for Red geen and blue wavelengths for blood. (HOWEVER there is a possibility I might have to define different absorption coefficients for oxygenated and deoxygenated blood (as they absorb different amounts of light)).

Hb and Hbo2 is the concentration of Oxygenated and Deoxygenated blood. (these are unknown as I'm trying to map the RGB values to this)

However I have also noticed that the coefficients for Oxygenated and Deoxygenated blood are different so this means the equation could possibly be the following.

Bxy = (ABhb * HB) + (ABhbo2 * Hbo2)

Rxy = (ARhb * HB) + (ARhbo2 * Hbo2)

Gxy = (AGhb * HB) + (AGhbo2 * Hbo2)

The only difference in the above is that the coefficients are different for oxygenated and deoxygenated blood.

This is all part of my Final Year Project at uni for Computer Science, trying to do some functional imaging.

@Chris does the same apply if there is different coefficients, sorry for lack of understanding, Maths is not my strongest point. Just trying to program this algorithm.

Was it helpful?

Solution

What you probably want is what's called the least squares solution (see the section on the general problem). To summarize, you are not guaranteed an exact solution depending on your A and b when you are trying to solve A*x=b here.

However, by computing xLS = inv(A'*A)*A'*b you'll get something that's as close as possible to a solution (in the least squares sense). Note that A' means the transpose of A. Also note, if A'*A is not invertible then your system of equations is rank deficient (that means you effectively have less equations than you think.)

If you have:

 Bxy = (ABhb * HB) + (ABhbo2 * Hbo2)
 Rxy = (ARhb * HB) + (ARhbo2 * Hbo2)
 Gxy = (AGhb * HB) + (AGhbo2 * Hbo2)

Then:

 A = [ ABhb  ABhbo2 
       ARhb  ARhbo2 
       AGhb  AGhbo2 ];

 x = [HB
      Hbo2];


 b = [Bxy
      Rxy
      Gxy];

OTHER TIPS

If you have n equations and n-1 unknowns, that means you can eliminate one of the equations, it is irrelevant and dependent on the other two. Figure out which one is easiest to eliminate, substitute, and then you're left with an (n-1)x(n-1) matrix

assuming there is a solution for all three equations that is, it can be found by only solving two of them to get the two unknowns.

In this case, it seems all of your equations are more or less equal, aside from the coefficients, so I don't think it will matter which of the three you chose to exclude. You could simply drop the Gxy equation and end up with the 2x2 pair of:

Bxy = AB * HB + AB * Hbo2

Rxy = AR * HB + AR * Hbo2

resulting in the matrix

[AB AB]

[AR AR]

The epxression HB+Hbo2 is the same in all 3 equations, and it can be replaced by z=HB+Hbo2 making the three equations

B = AB*z
R = AR*z
G = AG*z

To solve for z do a least squares fit to find

z = HB + Hbo2 = (AB*B+AG*G+AR*R)/(AB*AB+AG*AG+AR*AR)

and the error for each component as

dB = B - AB*z
dR = R - AR*z
dG = G - AG*z

That is all you can do. Somehow you have to decide how to split z into HB and Hbo2. No information about this is given in the problem statement.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top