Files
sjy01-image-proc/cmd/test.go
2024-11-01 09:19:42 +08:00

53 lines
1.3 KiB
Go

package main
import (
"github.com/airbusgeo/godal"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"gocv.io/x/gocv"
"starwiz.cn/sjy01/image-proc/pkg/producer"
"starwiz.cn/sjy01/image-proc/pkg/utils"
)
var (
input0 string
)
var testCmd = &cobra.Command{
Use: "test",
Short: "test command",
Long: `test command`,
Run: func(cmd *cobra.Command, args []string) {
godal.RegisterAll()
input0_mat, err := utils.ReadTifftoMat(input0)
if err != nil {
logrus.Error(err)
return
}
mv := gocv.Split(*input0_mat)
// for i := 0; i < len(mv); i++ {
// out := producer.CV_Sobel(mv[i])
// utils.SavePanToGDALGTiff(out, 0, 0, "data/temp/out_"+strconv.Itoa(i)+".tif", 1.3)
// }
index := len(mv) - 1
for i := index - 1; i >= 0; i-- {
mv[i] = producer.CV_ECCAlign(mv[index], mv[i])
}
out := gocv.NewMat()
mv[index].ConvertTo(&mv[index], gocv.MatTypeCV16U)
gocv.Merge(mv, &out)
utils.SaveBGRToGDALGTiff(out, 4, 0, 0, 5.2,
[]godal.ColorInterp{godal.CIBlue, godal.CIGreen, godal.CIRed, godal.CIUndefined},
"data/temp/ecc.tif")
},
}
func init() {
rootCmd.AddCommand(testCmd)
testCmd.Flags().StringVarP(&input0, "input0", "i", "/Users/lan/workspace/sjy01/image-proc/data/002438/L1A/ROI_7000_10500/MSS/SJY01_MSS_20241014_121246_002438_018_ROI_7000_10500_L1A.tiff", "input0")
}