Optimization
This commit is contained in:
@@ -4,15 +4,16 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
|
|
||||||
"gonum.org/v1/gonum/mat"
|
"gonum.org/v1/gonum/mat"
|
||||||
|
"starwiz.cn/sjy01/image-proc/pkg/payload"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FocalLength = 1300.0 // 焦距, mm
|
FocalLength = 1300.0 // 焦距, mm
|
||||||
FOV = 1.7 // 对角线视场角,degree
|
FOV = 1.7 // 对角线视场角,degree
|
||||||
FOVCALC = 1.86 // 对角线视场角,degree
|
FOVCALC = 1.86 // 对角线视场角,degree
|
||||||
PANPixels = 9344.0
|
PANPixels = float64(payload.PAN_PIXEL_WIDTH)
|
||||||
PANCellSize = 3.2 // µm
|
PANCellSize = 3.2 // µm
|
||||||
MSSPixels = 2336.0
|
MSSPixels = float64(payload.MSS_PIXEL_WIDTH)
|
||||||
MSSCellSize = 12.8 // µm
|
MSSCellSize = 12.8 // µm
|
||||||
CameraRoll = 0.0 // 相机与卫星本体X轴的安装角度, degree FIXME: 安装矩阵应该由卫星方提供
|
CameraRoll = 0.0 // 相机与卫星本体X轴的安装角度, degree FIXME: 安装矩阵应该由卫星方提供
|
||||||
CameraPitch = 0.5 // 相机与卫星本体Y轴的安装角度, degree
|
CameraPitch = 0.5 // 相机与卫星本体Y轴的安装角度, degree
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import "github.com/sirupsen/logrus"
|
import (
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"starwiz.cn/sjy01/image-proc/pkg/payload"
|
||||||
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
CoRegistration CoRegistrationConfig `yaml:"coregistration" mapstructure:"coregistration"`
|
CoRegistration CoRegistrationConfig `yaml:"coregistration" mapstructure:"coregistration"`
|
||||||
@@ -38,8 +41,8 @@ func init() {
|
|||||||
CoRegistration: CoRegistrationConfig{
|
CoRegistration: CoRegistrationConfig{
|
||||||
MssBands: 4,
|
MssBands: 4,
|
||||||
PixelBytes: 2,
|
PixelBytes: 2,
|
||||||
PanWidth: 9344,
|
PanWidth: payload.PAN_PIXEL_WIDTH,
|
||||||
MssWidth: 2336,
|
MssWidth: payload.MSS_PIXEL_WIDTH,
|
||||||
OverlappedBlockLines: 3000,
|
OverlappedBlockLines: 3000,
|
||||||
CRBlockNW: 8,
|
CRBlockNW: 8,
|
||||||
CRBlockNH: 4,
|
CRBlockNH: 4,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/paulmach/orb/planar"
|
"github.com/paulmach/orb/planar"
|
||||||
"starwiz.cn/sjy01/image-proc/pkg/auxilary"
|
"starwiz.cn/sjy01/image-proc/pkg/auxilary"
|
||||||
"starwiz.cn/sjy01/image-proc/pkg/calculator"
|
"starwiz.cn/sjy01/image-proc/pkg/calculator"
|
||||||
|
"starwiz.cn/sjy01/image-proc/pkg/payload"
|
||||||
"starwiz.cn/sjy01/image-proc/pkg/utils"
|
"starwiz.cn/sjy01/image-proc/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -133,11 +134,11 @@ func (r *Registrator) SetSceneBoundary(scene *Scene) (topLeft, bottomRight orb.P
|
|||||||
log.Info("using attitude quaternion to calculate image boundary...")
|
log.Info("using attitude quaternion to calculate image boundary...")
|
||||||
Qsat2eci := calculator.Quaternion{W: as.QuatAttstarQ0, X: as.QuatAttstarQ1, Y: as.QuatAttstarQ2, Z: as.QuatAttstarQ3}
|
Qsat2eci := calculator.Quaternion{W: as.QuatAttstarQ0, X: as.QuatAttstarQ1, Y: as.QuatAttstarQ2, Z: as.QuatAttstarQ3}
|
||||||
line0Start, _ := calculator.IntersectionAttitude(Qsat2eci, startPos84, startTime, 0)
|
line0Start, _ := calculator.IntersectionAttitude(Qsat2eci, startPos84, startTime, 0)
|
||||||
line0End, _ := calculator.IntersectionAttitude(Qsat2eci, startPos84, startTime, 9344)
|
line0End, _ := calculator.IntersectionAttitude(Qsat2eci, startPos84, startTime, payload.PAN_PIXEL_WIDTH)
|
||||||
|
|
||||||
Qsat2eci = calculator.Quaternion{W: ae.QuatAttstarQ0, X: ae.QuatAttstarQ1, Y: ae.QuatAttstarQ2, Z: ae.QuatAttstarQ3}
|
Qsat2eci = calculator.Quaternion{W: ae.QuatAttstarQ0, X: ae.QuatAttstarQ1, Y: ae.QuatAttstarQ2, Z: ae.QuatAttstarQ3}
|
||||||
lineNStart, _ := calculator.IntersectionAttitude(Qsat2eci, endPos84, endTime, 0)
|
lineNStart, _ := calculator.IntersectionAttitude(Qsat2eci, endPos84, endTime, 0)
|
||||||
lineNEnd, _ := calculator.IntersectionAttitude(Qsat2eci, endPos84, endTime, 9344)
|
lineNEnd, _ := calculator.IntersectionAttitude(Qsat2eci, endPos84, endTime, payload.PAN_PIXEL_WIDTH)
|
||||||
|
|
||||||
// ------------------ 使用本体和轨道四元数计算图像边界 ECI------------------
|
// ------------------ 使用本体和轨道四元数计算图像边界 ECI------------------
|
||||||
// log.Info("using orbit and body quaternion to calculate image boundary...")
|
// log.Info("using orbit and body quaternion to calculate image boundary...")
|
||||||
@@ -146,14 +147,14 @@ func (r *Registrator) SetSceneBoundary(scene *Scene) (topLeft, bottomRight orb.P
|
|||||||
// Qorbit2eci := calculator.Quaternion{X: as.QuatOrbJQ1, Y: as.QuatOrbJQ2, Z: as.QuatOrbJQ3}
|
// Qorbit2eci := calculator.Quaternion{X: as.QuatOrbJQ1, Y: as.QuatOrbJQ2, Z: as.QuatOrbJQ3}
|
||||||
// Qorbit2eci.W = math.Sqrt(1 - Qorbit2eci.X*Qorbit2eci.X - Qorbit2eci.Y*Qorbit2eci.Y - Qorbit2eci.Z*Qorbit2eci.Z)
|
// Qorbit2eci.W = math.Sqrt(1 - Qorbit2eci.X*Qorbit2eci.X - Qorbit2eci.Y*Qorbit2eci.Y - Qorbit2eci.Z*Qorbit2eci.Z)
|
||||||
// line0Start,_ := calculator.IntersectionECI(Qsat2orbit, Qorbit2eci, startPos84, startTime, 0)
|
// line0Start,_ := calculator.IntersectionECI(Qsat2orbit, Qorbit2eci, startPos84, startTime, 0)
|
||||||
// line0End,_ := calculator.IntersectionECI(Qsat2orbit, Qorbit2eci, startPos84, startTime, 9344)
|
// line0End,_ := calculator.IntersectionECI(Qsat2orbit, Qorbit2eci, startPos84, startTime, payload.PAN_PIXEL_WIDTH)
|
||||||
|
|
||||||
// Qsat2orbit = calculator.Quaternion{X: ae.QuatOrbitQ1, Y: ae.QuatOrbitQ2, Z: ae.QuatOrbitQ3}
|
// Qsat2orbit = calculator.Quaternion{X: ae.QuatOrbitQ1, Y: ae.QuatOrbitQ2, Z: ae.QuatOrbitQ3}
|
||||||
// Qsat2orbit.W = math.Sqrt(1 - Qsat2orbit.X*Qsat2orbit.X - Qsat2orbit.Y*Qsat2orbit.Y - Qsat2orbit.Z*Qsat2orbit.Z)
|
// Qsat2orbit.W = math.Sqrt(1 - Qsat2orbit.X*Qsat2orbit.X - Qsat2orbit.Y*Qsat2orbit.Y - Qsat2orbit.Z*Qsat2orbit.Z)
|
||||||
// Qorbit2eci = calculator.Quaternion{X: ae.QuatOrbJQ1, Y: ae.QuatOrbJQ2, Z: ae.QuatOrbJQ3}
|
// Qorbit2eci = calculator.Quaternion{X: ae.QuatOrbJQ1, Y: ae.QuatOrbJQ2, Z: ae.QuatOrbJQ3}
|
||||||
// Qorbit2eci.W = math.Sqrt(1 - Qorbit2eci.X*Qorbit2eci.X - Qorbit2eci.Y*Qorbit2eci.Y - Qorbit2eci.Z*Qorbit2eci.Z)
|
// Qorbit2eci.W = math.Sqrt(1 - Qorbit2eci.X*Qorbit2eci.X - Qorbit2eci.Y*Qorbit2eci.Y - Qorbit2eci.Z*Qorbit2eci.Z)
|
||||||
// lineNStart,_ := calculator.IntersectionECI(Qsat2orbit, Qorbit2eci, endPos84, endTime, 0)
|
// lineNStart,_ := calculator.IntersectionECI(Qsat2orbit, Qorbit2eci, endPos84, endTime, 0)
|
||||||
// lineNEnd,_ := calculator.IntersectionECI(Qsat2orbit, Qorbit2eci, endPos84, endTime, 9344)
|
// lineNEnd,_ := calculator.IntersectionECI(Qsat2orbit, Qorbit2eci, endPos84, endTime, payload.PAN_PIXEL_WIDTH)
|
||||||
|
|
||||||
// ------------------ 使用本体和轨道四元数计算图像边界 ECEF------------------
|
// ------------------ 使用本体和轨道四元数计算图像边界 ECEF------------------
|
||||||
// log.Info("using orbit and body quaternion to calculate image boundary...")
|
// log.Info("using orbit and body quaternion to calculate image boundary...")
|
||||||
@@ -161,13 +162,13 @@ func (r *Registrator) SetSceneBoundary(scene *Scene) (topLeft, bottomRight orb.P
|
|||||||
// Qsat2orbit.W = math.Sqrt(1 - Qsat2orbit.X*Qsat2orbit.X - Qsat2orbit.Y*Qsat2orbit.Y - Qsat2orbit.Z*Qsat2orbit.Z)
|
// Qsat2orbit.W = math.Sqrt(1 - Qsat2orbit.X*Qsat2orbit.X - Qsat2orbit.Y*Qsat2orbit.Y - Qsat2orbit.Z*Qsat2orbit.Z)
|
||||||
// vec84 := []float64{as.W84VelX, as.W84VelY, as.W84VelZ}
|
// vec84 := []float64{as.W84VelX, as.W84VelY, as.W84VelZ}
|
||||||
// line0Start, _ := calculator.IntersectionECEF(Qsat2orbit, startPos84, vec84, 0)
|
// line0Start, _ := calculator.IntersectionECEF(Qsat2orbit, startPos84, vec84, 0)
|
||||||
// line0End, _ := calculator.IntersectionECEF(Qsat2orbit, startPos84, vec84, 9344)
|
// line0End, _ := calculator.IntersectionECEF(Qsat2orbit, startPos84, vec84, payload.PAN_PIXEL_WIDTH)
|
||||||
|
|
||||||
// Qsat2orbit = calculator.Quaternion{X: ae.QuatOrbitQ1, Y: ae.QuatOrbitQ2, Z: ae.QuatOrbitQ3}
|
// Qsat2orbit = calculator.Quaternion{X: ae.QuatOrbitQ1, Y: ae.QuatOrbitQ2, Z: ae.QuatOrbitQ3}
|
||||||
// Qsat2orbit.W = math.Sqrt(1 - Qsat2orbit.X*Qsat2orbit.X - Qsat2orbit.Y*Qsat2orbit.Y - Qsat2orbit.Z*Qsat2orbit.Z)
|
// Qsat2orbit.W = math.Sqrt(1 - Qsat2orbit.X*Qsat2orbit.X - Qsat2orbit.Y*Qsat2orbit.Y - Qsat2orbit.Z*Qsat2orbit.Z)
|
||||||
// vec84 = []float64{ae.W84VelX, ae.W84VelY, ae.W84VelZ}
|
// vec84 = []float64{ae.W84VelX, ae.W84VelY, ae.W84VelZ}
|
||||||
// lineNStart, _ := calculator.IntersectionECEF(Qsat2orbit, endPos84, vec84, 0)
|
// lineNStart, _ := calculator.IntersectionECEF(Qsat2orbit, endPos84, vec84, 0)
|
||||||
// lineNEnd, _ := calculator.IntersectionECEF(Qsat2orbit, endPos84, vec84, 9344)
|
// lineNEnd, _ := calculator.IntersectionECEF(Qsat2orbit, endPos84, vec84, payload.PAN_PIXEL_WIDTH)
|
||||||
|
|
||||||
// ------------------ 计算图像边界距离和分辨率 ------------------
|
// ------------------ 计算图像边界距离和分辨率 ------------------
|
||||||
W0 := geo.Distance(orb.Point{line0Start.Lon, line0Start.Lat}, orb.Point{line0End.Lon, line0End.Lat})
|
W0 := geo.Distance(orb.Point{line0Start.Lon, line0Start.Lat}, orb.Point{line0End.Lon, line0End.Lat})
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"gonum.org/v1/gonum/interp"
|
"gonum.org/v1/gonum/interp"
|
||||||
"gonum.org/v1/gonum/spatial/r3"
|
"gonum.org/v1/gonum/spatial/r3"
|
||||||
"starwiz.cn/sjy01/image-proc/pkg/auxilary"
|
"starwiz.cn/sjy01/image-proc/pkg/auxilary"
|
||||||
|
"starwiz.cn/sjy01/image-proc/pkg/payload"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Registrate interface{}
|
type Registrate interface{}
|
||||||
@@ -21,8 +22,8 @@ type Registrate interface{}
|
|||||||
const (
|
const (
|
||||||
MssBands = 4
|
MssBands = 4
|
||||||
PixelBytes = 2
|
PixelBytes = 2
|
||||||
PanWidth = 9344 // 像素宽度
|
PanWidth = payload.PAN_PIXEL_WIDTH // 像素宽度
|
||||||
MssWidth = 2336
|
MssWidth = payload.MSS_PIXEL_WIDTH
|
||||||
BlockNH = 4
|
BlockNH = 4
|
||||||
BlockNW = 8
|
BlockNW = 8
|
||||||
OverlappedBlockLines = 3000 // 重叠块的行数
|
OverlappedBlockLines = 3000 // 重叠块的行数
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
"starwiz.cn/sjy01/image-proc/pkg/payload"
|
||||||
"starwiz.cn/sjy01/image-proc/pkg/rrc"
|
"starwiz.cn/sjy01/image-proc/pkg/rrc"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ func (r *Registrator) DoRRCbyLUT(lutDir string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < 4; i++ {
|
for i := 0; i < 4; i++ {
|
||||||
lutMSS, err := rrc.LoadLUT(filepath.Join(lutDir, fmt.Sprintf("B%d.LUT", i+1)), 2336)
|
lutMSS, err := rrc.LoadLUT(filepath.Join(lutDir, fmt.Sprintf("B%d.LUT", i+1)), payload.MSS_PIXEL_WIDTH)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("load mss gray table failed")
|
logrus.Error("load mss gray table failed")
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"gocv.io/x/gocv"
|
"gocv.io/x/gocv"
|
||||||
"starwiz.cn/sjy01/image-proc/pkg/config"
|
"starwiz.cn/sjy01/image-proc/pkg/config"
|
||||||
|
"starwiz.cn/sjy01/image-proc/pkg/payload"
|
||||||
"starwiz.cn/sjy01/image-proc/pkg/rrc"
|
"starwiz.cn/sjy01/image-proc/pkg/rrc"
|
||||||
"starwiz.cn/sjy01/image-proc/pkg/utils"
|
"starwiz.cn/sjy01/image-proc/pkg/utils"
|
||||||
)
|
)
|
||||||
@@ -47,8 +48,8 @@ func CleanScenes(scenes []*Scene) {
|
|||||||
// MSS 2336 * 2336 - 1764
|
// MSS 2336 * 2336 - 1764
|
||||||
// PAN 9344 * 9344 - 7056
|
// PAN 9344 * 9344 - 7056
|
||||||
func (r *Registrator) SubScenes() (panScenes []*Scene, mssScenes []*Scene, err error) {
|
func (r *Registrator) SubScenes() (panScenes []*Scene, mssScenes []*Scene, err error) {
|
||||||
hPAN := (9344 - 2336)
|
hPAN := (payload.PAN_PIXEL_WIDTH - payload.MSS_PIXEL_WIDTH)
|
||||||
hPANOverlap := 2336
|
hPANOverlap := payload.MSS_PIXEL_WIDTH
|
||||||
panScenesCnt := r.PanHeight / hPAN
|
panScenesCnt := r.PanHeight / hPAN
|
||||||
|
|
||||||
for i := 0; i <= panScenesCnt; i++ {
|
for i := 0; i <= panScenesCnt; i++ {
|
||||||
@@ -59,7 +60,7 @@ func (r *Registrator) SubScenes() (panScenes []*Scene, mssScenes []*Scene, err e
|
|||||||
|
|
||||||
scene := &Scene{
|
scene := &Scene{
|
||||||
Type: "PAN",
|
Type: "PAN",
|
||||||
Width: 9344,
|
Width: payload.PAN_PIXEL_WIDTH,
|
||||||
Height: y1 - i*hPAN,
|
Height: y1 - i*hPAN,
|
||||||
X: 0,
|
X: 0,
|
||||||
Y: i * hPAN,
|
Y: i * hPAN,
|
||||||
@@ -74,7 +75,7 @@ func (r *Registrator) SubScenes() (panScenes []*Scene, mssScenes []*Scene, err e
|
|||||||
name = strings.TrimSuffix(name, ".tiff")
|
name = strings.TrimSuffix(name, ".tiff")
|
||||||
scene.SceneId = fmt.Sprintf("%s_%03d", name, i+1)
|
scene.SceneId = fmt.Sprintf("%s_%03d", name, i+1)
|
||||||
|
|
||||||
mat := r.PanImage.Region(image.Rect(0, i*hPAN, 9344, y1))
|
mat := r.PanImage.Region(image.Rect(0, i*hPAN, payload.PAN_PIXEL_WIDTH, y1))
|
||||||
if config.GCONFIG.Radiation.PANRemoveHfNoise {
|
if config.GCONFIG.Radiation.PANRemoveHfNoise {
|
||||||
log.Println("applying hf noise filter on", scene.SceneId)
|
log.Println("applying hf noise filter on", scene.SceneId)
|
||||||
matFiltered := rrc.HFNoiseFilter(mat, float64(mat.Cols())*config.GCONFIG.Radiation.HfRadiusRatio)
|
matFiltered := rrc.HFNoiseFilter(mat, float64(mat.Cols())*config.GCONFIG.Radiation.HfRadiusRatio)
|
||||||
@@ -101,7 +102,7 @@ func (r *Registrator) SubScenes() (panScenes []*Scene, mssScenes []*Scene, err e
|
|||||||
|
|
||||||
scene := &Scene{
|
scene := &Scene{
|
||||||
Type: "MSS",
|
Type: "MSS",
|
||||||
Width: 2336,
|
Width: payload.MSS_PIXEL_WIDTH,
|
||||||
Height: y1 - i*hMSS,
|
Height: y1 - i*hMSS,
|
||||||
X: 0,
|
X: 0,
|
||||||
Y: i * hMSS,
|
Y: i * hMSS,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/airbusgeo/godal"
|
"github.com/airbusgeo/godal"
|
||||||
"gocv.io/x/gocv"
|
"gocv.io/x/gocv"
|
||||||
|
"starwiz.cn/sjy01/image-proc/pkg/payload"
|
||||||
"starwiz.cn/sjy01/image-proc/pkg/utils"
|
"starwiz.cn/sjy01/image-proc/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -53,8 +54,8 @@ func TestMomentMatching(t *testing.T) {
|
|||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
height := len(data) / (9344 * 2)
|
height := len(data) / (payload.PAN_PIXEL_WIDTH * 2)
|
||||||
img, err := gocv.NewMatFromBytes(height, 9344, gocv.MatTypeCV16U, data)
|
img, err := gocv.NewMatFromBytes(height, payload.PAN_PIXEL_WIDTH, gocv.MatTypeCV16U, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"gocv.io/x/gocv"
|
"gocv.io/x/gocv"
|
||||||
|
"starwiz.cn/sjy01/image-proc/pkg/payload"
|
||||||
"starwiz.cn/sjy01/image-proc/pkg/utils"
|
"starwiz.cn/sjy01/image-proc/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -17,9 +18,9 @@ import (
|
|||||||
// 采用在轨统计定标方法。利用卫星在轨后获取的常规影像数据,统计每个探元出现的灰度频次。
|
// 采用在轨统计定标方法。利用卫星在轨后获取的常规影像数据,统计每个探元出现的灰度频次。
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PANCameraProbeNum = 9344 // 全色探元数
|
PANCameraProbeNum = payload.PAN_PIXEL_WIDTH // 全色探元数
|
||||||
MSSCameraProbeNum = 2336 // 多光谱探元数
|
MSSCameraProbeNum = payload.MSS_PIXEL_WIDTH // 多光谱探元数
|
||||||
MaxGrayLevel = 65536 // 16bit像素值
|
MaxGrayLevel = 65536 // 16bit像素值
|
||||||
)
|
)
|
||||||
|
|
||||||
type RRC struct {
|
type RRC struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user