两个未知数 3 个方程
我有3个eqns和2个未知数Hb和Hbo2,它们看起来像这样:
Bxy = AB * HB + AB * Hbo2
Rxy = AR * HB + AR * Hbo2
Gxy = AG * HB + AG * Hbo2
现在我一直在尝试使用矩阵方法来求解方程的未知数,这是一个痛苦的事情,因为当我将其转换为矩阵形式时,我得到一个不规则矩阵,因为它有两个未知数并且3个方程。
这里有人知道如何解 n 个具有 n-1 个未知数的方程吗?
编辑
感谢您迄今为止的回复,他们非常棒。
为了使这一点更清楚,我想做的是计算图像中给定像素处的含氧和脱氧血液的浓度。所以上面的变量对应于下面的变量。
Rxy Gxy 和 Bxy,红绿或蓝在位置 x,y 处被吸收。 (值在 0 - 255 之间)
AR、AG、AB 是血液对红绿光和蓝光波长的光吸收系数。 (但是,我可能必须为含氧血液和脱氧血液定义不同的吸收系数(因为它们吸收不同量的光))。
Hb 和 Hbo2 是含氧和脱氧血液的浓度。 (这些是未知的,因为我试图将 RGB 值映射到此)
但是我也注意到含氧血液和脱氧血液的系数不同,因此这意味着方程可能如下。
Bxy = (ABhb * HB) + (ABhbo2 * Hbo2)
Rxy = (ARhb * HB) + (ARhbo2 * Hbo2)
Gxy = (AGhb * HB) + (AGhbo2 * Hbo2)
上面唯一的区别是系数是含氧血液和脱氧血液不同。
这是我在计算机科学大学的最后一年项目的一部分,试图做一些功能成像。
@Chris 如果有不同的系数,同样适用,抱歉缺乏理解,数学不是我的强项。只是想编写这个算法。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能想要的是所谓的最小二乘解决方案(请参阅有关一般问题的部分)< /a>.总而言之,当您尝试在此处求解
A*x=b
时,无法保证根据您的A
和b
获得精确的解。但是,通过计算 xLS = inv(A'*A)*A'*b,您将得到尽可能接近解的结果(在最小二乘意义上)。请注意,
A'
表示A
的转置。另请注意,如果A'*A
不可逆,那么您的方程组是秩亏的(这意味着您的方程实际上比您想象的要少。)如果您有:
则:
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
andb
when you are trying to solveA*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 thatA'
means the transpose ofA
. Also note, ifA'*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:
Then:
如果你有 n 个方程和 n-1 个未知数,这意味着你可以消除其中一个方程,它是不相关的并且依赖于其他两个方程。找出最容易消除、替换的一个,然后剩下一个 (n-1)x(n-1) 矩阵,
假设所有三个方程都有一个解,也就是说,只需求解即可找到它其中两个得到两个未知数。
在这种情况下,除了系数之外,似乎所有方程都或多或少相等,所以我认为您选择排除三个方程中的哪一个并不重要。您可以简单地删除 Gxy 方程并最终得到 2x2 对:
Bxy = AB * HB + AB * Hbo2
Rxy = AR * HB + AR * Hbo2
产生矩阵
[AB AB]
[AR AR]
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]
表达式
HB+Hbo2
在所有 3 个方程中都是相同的,并且可以用z=HB+Hbo2
代替,使三个方程求解 z 执行最小二乘适合找到
每个组件的错误,
这就是您所能做的。您必须以某种方式决定如何将
z
拆分为HB
和Hbo2
。问题陈述中没有给出有关此的信息。The epxression
HB+Hbo2
is the same in all 3 equations, and it can be replaced byz=HB+Hbo2
making the three equationsTo solve for z do a least squares fit to find
and the error for each component as
That is all you can do. Somehow you have to decide how to split
z
intoHB
andHbo2
. No information about this is given in the problem statement.