default channel order of OpenCV is BGR
This commit is contained in:
@@ -114,7 +114,7 @@ func (r *Registrator) SaveScenesToTiff(panScenes []*Scene, mssScenes []*Scene) e
|
||||
rgbirImage, _ := r.MergeMSSToBGRNIR(scene.Mat)
|
||||
err := SaveBGRToGDALGTiff(rgbirImage,
|
||||
4, 5,
|
||||
[]godal.ColorInterp{godal.CIBlue, godal.CIGreen, godal.CIRed, godal.CIAlpha},
|
||||
[]godal.ColorInterp{godal.CIBlue, godal.CIGreen, godal.CIRed, godal.CIUndefined},
|
||||
scene.Tiff)
|
||||
if err != nil {
|
||||
log.Errorf("save mss scene %d to tiff failed: %v", i+1, err)
|
||||
@@ -143,24 +143,11 @@ func (r *Registrator) MergeMSSToBGRNIR(channels []gocv.Mat) (gocv.Mat, error) {
|
||||
if len(channels) != 4 {
|
||||
return rgbirImage, fmt.Errorf("mss channels count not match")
|
||||
}
|
||||
width := channels[0].Cols()
|
||||
height := channels[0].Rows()
|
||||
|
||||
// 创建合并后的图像(RGBIR)
|
||||
rgbirImage = gocv.NewMatWithSize(height, width, gocv.MatTypeCV16UC4) // 4通道,16位
|
||||
|
||||
for y := 0; y < height; y++ {
|
||||
for x := 0; x < width; x++ {
|
||||
blue := channels[0].GetShortAt(y, x)
|
||||
green := channels[1].GetShortAt(y, x)
|
||||
red := channels[2].GetShortAt(y, x)
|
||||
ir := channels[3].GetShortAt(y, x)
|
||||
rgbirImage.SetShortAt(y, x*4+0, blue)
|
||||
rgbirImage.SetShortAt(y, x*4+1, green)
|
||||
rgbirImage.SetShortAt(y, x*4+2, red)
|
||||
rgbirImage.SetShortAt(y, x*4+3, ir)
|
||||
}
|
||||
}
|
||||
rgbirImage = gocv.NewMat()
|
||||
gocv.Merge(channels, &rgbirImage)
|
||||
log.Printf("merge mss to bgr nir image, channels: %d, height: %d, width: %d",
|
||||
rgbirImage.Channels(), rgbirImage.Rows(), rgbirImage.Cols())
|
||||
|
||||
return rgbirImage, nil
|
||||
|
||||
|
||||
Reference in New Issue
Block a user