This commit is contained in:
nuknal
2024-09-10 14:13:30 +08:00
parent 52638b5ffe
commit 2fcbc389c6
8 changed files with 82 additions and 32 deletions

View File

@@ -11,6 +11,7 @@ import (
log "github.com/sirupsen/logrus"
"gonum.org/v1/gonum/mat"
"starwiz.cn/sjy01/image-proc/pkg/config"
"starwiz.cn/sjy01/image-proc/pkg/dem"
)
@@ -56,8 +57,8 @@ type RPCModel struct {
// rational polynomial coeffients
func NewRPC(r *Registrator, scene *Scene, rpb string) *RPC {
rpc := RPC{
elevationLayer: 5,
gridsize: 20,
elevationLayer: config.GCONFIG.RPC.AltitudeLayer,
gridsize: config.GCONFIG.RPC.GridSize,
registrator: r,
scene: scene,
rpb: rpb,
@@ -140,22 +141,28 @@ func (rpc *RPC) RPC() error {
rpc.saveVec(strings.Replace(rpc.scene.Tiff, ".tiff", ".vec.txt", -1),
rowVec, colVec, latVec, lonVec, heightVec)
rpc.lineOffset = float64(rpc.scene.Height) / 2.0
rpc.lineScale = float64(rpc.scene.Height) / 2.0
rpc.sampOffset = float64(rpc.scene.Width) / 2.0
rpc.sampScale = float64(rpc.scene.Width) / 2.0
rowVec = normalize2(rowVec, rpc.lineOffset, rpc.lineScale)
colVec = normalize2(colVec, rpc.sampOffset, rpc.sampScale)
// rpc.lineOffset = float64(rpc.scene.Height) / 2.0
// rpc.lineScale = float64(rpc.scene.Height)
// rowVec = normalize2(rowVec, rpc.lineOffset, rpc.lineScale)
// rpc.sampOffset = float64(rpc.scene.Width) / 2.0
// rpc.sampScale = float64(rpc.scene.Width)
// colVec = normalize2(colVec, rpc.sampOffset, rpc.sampScale)
// rpc.heightOffset = (rpc.minH + rpc.maxH) / 2.0
// rpc.heightScale = 1000.0
// heightVec = normalize2(heightVec, rpc.heightOffset, rpc.heightScale)
latVec, rpc.latOffset, rpc.latScale = normalize(latVec)
lonVec, rpc.longOffset, rpc.longScale = normalize(lonVec)
heightVec, rpc.heightOffset, rpc.heightScale = normalize(heightVec)
rowVec, rpc.lineOffset, rpc.lineScale = normalize(rowVec)
colVec, rpc.sampOffset, rpc.sampScale = normalize(colVec)
rpc.saveVec(strings.Replace(rpc.scene.Tiff, ".tiff", ".vec_norm.txt", -1),
rowVec, colVec, latVec, lonVec, heightVec)
// 设计矩阵 B = [ 20个分子系数 19个分母系数 ] W = 权矩阵 R = 观测结果
method := SolveMethodNelderMead
// x = (B^T * W^2 * B)^-1 * (B^T * W^2 * R), 其中 x = [a1..a20 b2..b20]^T
// 行参数
// B := setupSystemOfEquations(rowVec, latVec, lonVec, heightVec)